about summary refs log tree commit diff
path: root/Test
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2004-06-22 13:09:55 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2004-06-22 13:09:55 +0000
commitd591334e9d616830fbd24909db2e21ac4b959742 (patch)
tree65b44f10e6995c95605c8a56c3ca0fd9bfe6ad9d /Test
parent6a1d913bd6214d7ca7f8cf1a82efef1fa4bae101 (diff)
downloadzsh-d591334e9d616830fbd24909db2e21ac4b959742.tar.gz
zsh-d591334e9d616830fbd24909db2e21ac4b959742.tar.xz
zsh-d591334e9d616830fbd24909db2e21ac4b959742.zip
20076, 20084: { ... } always { ... } syntax.
Diffstat (limited to 'Test')
-rw-r--r--Test/A01grammar.ztst79
1 files changed, 79 insertions, 0 deletions
diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst
index 6f40c98ab..a856b8ccc 100644
--- a/Test/A01grammar.ztst
+++ b/Test/A01grammar.ztst
@@ -263,6 +263,85 @@
 0:basic [[ ... ]] test
 
 #
+# Current shell execution with try/always form.
+# We put those with errors in subshells so that any unhandled error doesn't
+# propagate.
+#
+
+  {
+     print The try block.
+  } always {
+     print The always block.
+  }
+  print After the always block.
+0:Basic `always' syntax
+>The try block.
+>The always block.
+>After the always block.
+
+  ({
+    print Position one.
+    print ${*this is an error*}
+    print Position two.
+  } always {
+    if (( TRY_BLOCK_ERROR )); then
+      print An error occurred.
+    else
+      print No error occurred.
+    fi
+  }
+  print Position three)
+1:Always block with error not reset
+>Position one.
+>An error occurred.
+?(eval):3: bad substitution
+
+  ({
+    print Stelle eins.
+    print ${*voici une erreur}
+    print Posizione due.
+  } always {
+    if (( TRY_BLOCK_ERROR )); then
+      print Erratum factum est. Retro ponetur.
+      (( TRY_BLOCK_ERROR = 0 ))
+    else
+      print unray touay foay anguageslay
+    fi
+  }
+  print Status after always block is $?.)
+0:Always block with error reset
+>Stelle eins.
+>Erratum factum est. Retro ponetur.
+>Status after always block is 1.
+?(eval):3: bad substitution
+
+# Outputting of structures from the wordcode is distinctly non-trivial,
+# we probably ought to have more like the following...
+  fn1() { { echo foo; } }
+  fn2() { { echo foo; } always { echo bar; } }
+  fn3() { ( echo foo; ) }
+  functions fn1 fn2 fn3
+0:Output of syntactic structures with and without always blocks
+>fn1 () {
+>	{
+>		echo foo
+>	}
+>}
+>fn2 () {
+>	{
+>		echo foo
+>	} always {
+>		echo bar
+>	}
+>}
+>fn3 () {
+>	(
+>		echo foo
+>	)
+>}
+
+
+#
 # Tests for `Alternate Forms For Complex Commands'
 #