summary refs log tree commit diff
path: root/Test
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2015-11-11 22:14:16 +0000
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2015-11-11 22:14:16 +0000
commit7a951ef93ef2cc6baac9ec3b51909ad44e4bfe15 (patch)
tree995acd45740444f3a14801d2c8b057225aa1826c /Test
parent830d54e629e8e12eb5a219a65a013876662e7b3e (diff)
downloadzsh-7a951ef93ef2cc6baac9ec3b51909ad44e4bfe15.tar.gz
zsh-7a951ef93ef2cc6baac9ec3b51909ad44e4bfe15.tar.xz
zsh-7a951ef93ef2cc6baac9ec3b51909ad44e4bfe15.zip
37094: Further tweaks to parameter name references.
Safety in array test.

Make nested references work.

Add parameter tests.
Diffstat (limited to 'Test')
-rw-r--r--Test/D04parameter.ztst49
1 files changed, 49 insertions, 0 deletions
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 694b613c5..6f325d293 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -1798,3 +1798,52 @@
 >1: x bar y
 >1: x bar bar y
 >1: x bar y
+
+  testfn() {
+    local scalar=obfuscation
+    local -a array=(alpha bravo charlie delta echo foxtrot)
+    local -A assoc=(one eins two zwei three drei four vier)
+    local name subscript
+    for name subscript in scalar 3 array 5 assoc three; do
+      print ${${(P)name}[$subscript]}
+    done
+  }
+  testfn
+0:${(P)...} with normal subscripting
+>f
+>echo
+>drei
+
+  testfn() {
+    local s1=foo s2=bar
+    local -a val=(s1)
+    print ${${(P)val}[1,3]}
+    val=(s1 s2)
+    print ${${(P)val}[1,3]}
+  }
+  testfn
+1:${(P)...} with array as name
+>foo
+?testfn:5: parameter name reference used with array
+
+  testfn() {
+    local -A assoc=(one buckle two show three knock four door)
+    local name='assoc[two]'
+    print ${${(P)name}[2,3]}
+  }
+  testfn
+0:${(P)...} with internal subscripting
+>ho
+
+  testfn() {
+    local one=two
+    local two=three
+    local three=four
+    local -a four=(all these worlds belong to foo)
+    print ${${(P)${(P)${(P)one}}}}
+    print ${${(P)${(P)${(P)one}}}[3]}
+  }
+  testfn
+0:nested parameter name references
+>all these worlds belong to foo
+>worlds