summary refs log tree commit diff
path: root/Test
diff options
context:
space:
mode:
Diffstat (limited to 'Test')
-rw-r--r--Test/B02typeset.ztst145
-rw-r--r--Test/D01prompt.ztst2
-rw-r--r--Test/E01options.ztst11
3 files changed, 156 insertions, 2 deletions
diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst
index 57a7caa12..4afb18962 100644
--- a/Test/B02typeset.ztst
+++ b/Test/B02typeset.ztst
@@ -22,6 +22,8 @@
 
 %prep
 
+  mkdir typeset.tmp && cd typeset.tmp
+
   setopt noglob
 
   scalar=scalar
@@ -231,7 +233,7 @@
 
  typeset -T THIS will not work
 1:Tied array syntax
-?(eval):typeset:1: -T requires names of scalar and array
+?(eval):typeset:1: too many arguments for -T
 
  local array[2]=x
 1:Illegal local array element assignment
@@ -508,3 +510,144 @@
 >a2=(three four)
 >typeset -r r1=yes
 >typeset -r r2=no
+
+  one=hidden two=hidden three=hidden four=hidden five=hidden
+  fn() {
+     local bleugh="four=vier"
+     typeset -R10 one=eins two=(zwei dio) three $bleugh five=(cinq cinque)
+     three=drei
+     print -l $one $two $three $four $five
+  }
+  fn
+  print -l $one $two $three $four $five
+0:typeset reserved word interface: basic
+>      eins
+>zwei
+>dio
+>      drei
+>      vier
+>cinq
+>cinque
+>hidden
+>hidden
+>hidden
+>hidden
+>hidden
+
+  (
+  setopt glob
+  mkdir -p arrayglob
+  touch arrayglob/{one,two,three,four,five,six,seven}
+  fn() {
+    typeset array=(arrayglob/[tf]*)
+    print -l ${array:t}
+    #
+    typeset {first,second,third}=the_same_value array=(
+    extends
+    over
+    multiple
+    lines
+    )
+    print -l $first $second $third "$array"
+    #
+    integer i=$(echo 1 + 2 + 3 + 4)
+    print $i
+    #
+    # only noted by accident this was broken..
+    # we need to turn off special recognition
+    # of assignments within assignments...
+    typeset careful=( i=1 j=2 k=3 )
+    print -l $careful
+  }
+  fn
+  )
+0:typeset reserved word, more complicated cases
+>five
+>four
+>three
+>two
+>the_same_value
+>the_same_value
+>the_same_value
+>extends over multiple lines
+>10
+>i=1
+>j=2
+>k=3
+
+  (
+     # reserved word is recognised at parsing.
+     # yes, this is documented.
+     # anyway, that means we need to
+     # re-eval the function...
+     fn='
+     fn() {
+        typeset foo=`echo one word=two`
+        print $foo
+        print $word
+     }
+     '
+     print reserved
+     eval $fn; fn
+     print builtin
+     disable -r typeset
+     eval $fn; fn
+     enable -r typeset
+     disable typeset
+     print reserved
+     eval $fn; fn
+  )
+0:reserved word and builtin interfaces
+>reserved
+>one word=two
+>
+>builtin
+>one
+>two
+>reserved
+>one word=two
+>
+
+  fn() {
+    emulate -L zsh
+    setopt typeset_silent
+    local k
+    typeset -A hash=(k1 v1 k2 v2)
+    typeset foo=word array=(more than one word)
+    for k in ${(ko)hash}; do
+      print $k $hash[$k]
+    done
+    print -l $foo $array
+    typeset -A hash
+    typeset foo array
+    for k in ${(ko)hash}; do
+      print $k $hash[$k]
+    done
+    print -l $foo $array
+    typeset hash=(k3 v3 k4 v4) array=(odd number here)
+    for k in ${(ko)hash}; do
+      print $k $hash[$k]
+    done
+    print -l $array
+  }
+  fn
+0:typeset preserves existing variable types
+>k1 v1
+>k2 v2
+>word
+>more
+>than
+>one
+>word
+>k1 v1
+>k2 v2
+>word
+>more
+>than
+>one
+>word
+>k3 v3
+>k4 v4
+>odd
+>number
+>here
diff --git a/Test/D01prompt.ztst b/Test/D01prompt.ztst
index 3074efe60..2638e2438 100644
--- a/Test/D01prompt.ztst
+++ b/Test/D01prompt.ztst
@@ -199,5 +199,5 @@
 ?+zsh_directory_name:4> [[ d == n ]]
 ?+zsh_directory_name:12> [[ <parent>/very_long_directory_name == (#b)(*)/very_long_directory_name ]]
 ?+zsh_directory_name:14> return 0
-?+fn:7> local 'd=~[<parent>:l]'
+?+fn:7> local d='~[<parent>:l]'
 ?+fn:8> print '~[<parent>:l]'
diff --git a/Test/E01options.ztst b/Test/E01options.ztst
index d64f7ac68..ca3f06ca8 100644
--- a/Test/E01options.ztst
+++ b/Test/E01options.ztst
@@ -570,6 +570,15 @@
 >unset
 >globassign
 
+  # This test is now somewhat artificial as
+  # KSH_TYPESET only applies to the builtin
+  # interface.  Tests to the more standard
+  # reserved word interface appear elsewhere.
+  (
+  # reserved words are handled during parsing,
+  # hence eval...
+  disable -r typeset
+  eval '
   setopt kshtypeset
   ktvars=(ktv1 ktv2)
   typeset ktfoo=`echo arg1 arg2` $ktvars
@@ -580,6 +589,8 @@
   print $noktfoo
   print $+noktarg1 $+noktarg2
   unset ktfoo ktv1 ktv2 noktfoo noktarg2
+  '
+  )
 0:KSH_TYPESET option
 >1 1 0
 >arg1 arg2