about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-01-24 10:19:49 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-01-24 10:19:49 +0000
commit3be13f0b14401e6b420f7a35c300b485cbc8b97a (patch)
tree2c937b0cd057eb273fb67de41fea9fb610be1356
parent61a5c826c8472a8d9058ebb93e5fbbc5796cd46d (diff)
downloadzsh-3be13f0b14401e6b420f7a35c300b485cbc8b97a.tar.gz
zsh-3be13f0b14401e6b420f7a35c300b485cbc8b97a.tar.xz
zsh-3be13f0b14401e6b420f7a35c300b485cbc8b97a.zip
23131: new tests for command substitution
-rw-r--r--ChangeLog5
-rw-r--r--Test/.distfiles2
-rw-r--r--Test/D08cmdsubst.ztst83
3 files changed, 89 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index fc9ceeddf..dc6d1644f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-01-24  Peter Stephenson  <pws@csr.com>
+
+	* 23131: Test/.distfiles, Test/D08cmdsubst.ztst: new tests for
+	command substitution.
+
 2007-01-23  Peter Stephenson  <pws@csr.com>
 
 	* 23126, modified: Src/lex.c: errors when deciding between
diff --git a/Test/.distfiles b/Test/.distfiles
index dc73eabeb..4668c7e3a 100644
--- a/Test/.distfiles
+++ b/Test/.distfiles
@@ -7,7 +7,7 @@ A02alias.ztst        C03traps.ztst        E02xtrace.ztst
 A03quoting.ztst      C04funcdef.ztst      Makefile.in          ztst.zsh
 A04redirect.ztst     D01prompt.ztst       V02zregexparse.ztst
 A05execution.ztst    D02glob.ztst         Y01completion.ztst
-D06subscript.ztst    D07multibyte.ztst
+D06subscript.ztst    D07multibyte.ztst    D08cmdsubst.ztst
 V01zmodload.ztst     E01options.ztst
 B02typeset.ztst      B03print.ztst        A06assign.ztst       B04read.ztst
 V03mathfunc.ztst
diff --git a/Test/D08cmdsubst.ztst b/Test/D08cmdsubst.ztst
new file mode 100644
index 000000000..6cbcbf929
--- /dev/null
+++ b/Test/D08cmdsubst.ztst
@@ -0,0 +1,83 @@
+# Tests for command substitution.
+
+%prep
+  mkdir cmdsubst.tmp
+  touch cmdsubst.tmp/file{1,2}.txt
+
+%test
+  foo="two words"
+  print -l `echo $foo bar`
+0:Basic `...` substitution
+>two
+>words
+>bar
+
+  foo="two words"
+  print -l $(echo $foo bar)
+0:Basic $(...) substitution
+>two
+>words
+>bar
+
+  foo='intricate buffoonery'
+  print -l "`echo $foo and licentiousness`"
+0:Quoted `...` substitution
+>intricate buffoonery and licentiousness
+
+  foo="more words"
+  print -l "$(echo $foo here)"
+0:Quoted $(...) substitution
+>more words here
+
+# we used never to get this one right, but I think it is now...
+  print -r "`print -r \\\\\\\\`"
+0:Stripping of backslasshes in quoted `...`
+>\\
+
+  print -r "$(print -r \\\\\\\\)"
+0:Stripping of backslashes in quoted $(...)
+>\\\\
+
+  fnify() { print \"$*\"; }
+  print `fnify \`fnify understatement\``
+0:Nested `...`
+>""understatement""
+
+  print $(fnify $(fnify overboard))
+0:Nested $(...)
+>""overboard""
+
+  fructify() { print \'$*\'; }
+  print "`fructify \`fructify indolence\``"
+0:Nested quoted `...`
+>''indolence''
+
+  print "$(fructify $(fructify obtuseness))"
+0:Nested quoted $(...)
+>''obtuseness''
+
+  gesticulate() { print \!$*\!; }
+  print $((gesticulate wildly); gesticulate calmly)
+0:$(( ... ) ... ) is not arithmetic
+>!wildly! !calmly!
+
+  commencify() { print +$*+; }
+  print "$((commencify output); commencify input)"
+0:quoted $(( ... ) .. ) is not arithmetic
+>+output+
+>+input+
+
+  (
+  cd cmdsubst.tmp
+  print first: ${$(print \*)}
+  print second: ${~$(print \*)}
+  print third: ${$(print *)}
+  print fourth: "${~$(print \*)}"
+  print fifth: ${~"$(print \*)"}
+  )
+0:mixing $(...) with parameter substitution and globbing
+>first: *
+>second: file1.txt file2.txt
+>third: file1.txt file2.txt
+>fourth: *
+>fifth: file1.txt file2.txt