about summary refs log tree commit diff
path: root/Test
diff options
context:
space:
mode:
authorBart Schaefer <schaefer@zsh.org>2023-03-06 20:01:04 -0800
committerBart Schaefer <schaefer@zsh.org>2023-03-06 20:01:04 -0800
commit8d009d35a9eeacb1bbe9399316d2649a47102014 (patch)
tree54b21c0628dd1196c32bc83b8db7f50a9308e4cd /Test
parent0562be0af8127bb728774de47e4e8851461bd8e2 (diff)
downloadzsh-8d009d35a9eeacb1bbe9399316d2649a47102014.tar.gz
zsh-8d009d35a9eeacb1bbe9399316d2649a47102014.tar.xz
zsh-8d009d35a9eeacb1bbe9399316d2649a47102014.zip
51510: Skip namespaces in "set"/"typeset" output, add tests, fix bug
Diffstat (limited to 'Test')
-rw-r--r--Test/K02parameter.ztst106
1 files changed, 106 insertions, 0 deletions
diff --git a/Test/K02parameter.ztst b/Test/K02parameter.ztst
new file mode 100644
index 000000000..8a1be1e36
--- /dev/null
+++ b/Test/K02parameter.ztst
@@ -0,0 +1,106 @@
+# Test parameter expansion with namespace syntax
+# (heavily borrowed from D04parameter.ztst)
+
+%prep
+
+%test
+
+  .k02.foo='the first parameter'
+  .k02.bar='the second parameter'
+  print -l $.k02.foo ${.k02.bar}
+0:Basic scalars with namespace
+F:Braces are required
+>$.k02.foo
+>the second parameter
+
+  typeset .k02.bar='the second parameter'
+  print -l ${.k02.bar}
+0:Scalar but with typeset
+>the second parameter
+
+  .k02.array1=(the first array)
+  .k02.array2=(the second array)
+  print -l $.k02.array1 ${.k02.array2}
+0:Basic arrays with namespace
+>$.k02.array1
+>the
+>second
+>array
+
+  typeset -a .k02.array2=(the second array)
+  print -l ${.k02.array2}
+0:Array but with typeset
+>the
+>second
+>array
+
+  setopt ksharrays
+  print -l ${.k02.array2}
+  unsetopt ksharrays
+0:Basic ksharray with namespace
+>the
+
+  setopt shwordsplit
+  print -l ${.k02.foo} ${==.k02.bar}
+  unsetopt shwordsplit
+0:Basic shwordsplit with namespace
+>the
+>first
+>parameter
+>the second parameter
+
+  print ${+.k02.foo} ${+.k02.notappearinginthistest}
+0:$+... and namespace
+>1 0
+
+  .k02.x=()
+  print ${+.k02.x} ${+.k02.x[1]} ${+.k02.x[(r)foo]} ${+.k02.x[(r)bar]}
+  .k02.x=(foo)
+  print ${+.k02.x} ${+.k02.x[1]} ${+.k02.x[(r)foo]} ${+.k02.x[(r)bar]}
+0:$+... with arrays and namespace
+>1 0 0 0
+>1 1 1 0
+
+  # See D04 for complete explanation.
+  # For K02 we're just testing that flag syntax works.
+  .k02.foo='<five> {six} (seven) >eight< }nine{ |forty-two| $many$ )ten( more'
+  .k02.array=(${(z).k02.foo})
+  print -l ${(Q).k02.array}
+0:${(z)...} and ${(Q)...} for some hard to parse cases
+><
+>five
+>>
+>{six}
+>(
+>seven
+>)
+>>
+>eight
+><
+>}nine{
+>|
+>forty-two
+>|
+>$many$
+>)
+>ten( more
+
+  .k02.array=(characters in an array)
+  print ${(c)#.k02.array}
+0:${(c)#...}
+>22
+
+  () {
+    typeset -n .k02.ref=.k02.array
+    emulate -L ksh
+    print -l ${!.k02.ref} ${(!).k02.ref} ${.k02.ref}
+  }
+0:namerefs with namespaces
+>.k02.array
+>.k02.array
+>characters
+
+  k.2=test
+  print ${k.2}
+0:Parse without leading dot (future proofing)
+>test