about summary refs log tree commit diff
path: root/Test
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2015-01-02 21:16:41 +0000
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2015-01-02 21:16:41 +0000
commitb83aa727ca745137817e40e766ada815beb93d88 (patch)
treee2bcff594f6c45b6c8986d6c6075a81baef9a654 /Test
parent2194da18c74ac9ca7e8adc9ec7151c59bf9aafe4 (diff)
downloadzsh-b83aa727ca745137817e40e766ada815beb93d88.tar.gz
zsh-b83aa727ca745137817e40e766ada815beb93d88.tar.xz
zsh-b83aa727ca745137817e40e766ada815beb93d88.zip
34077: further tests for return status from "for" loops
Diffstat (limited to 'Test')
-rw-r--r--Test/A07control.ztst53
1 files changed, 53 insertions, 0 deletions
diff --git a/Test/A07control.ztst b/Test/A07control.ztst
index 397a821f1..b1a248732 100644
--- a/Test/A07control.ztst
+++ b/Test/A07control.ztst
@@ -110,3 +110,56 @@
   done
 1:break error case -1
 ?(eval):break:2: argument is not positive: -1
+
+  false
+  for x in; do
+    print nothing executed
+  done
+0:Status 0 from for with explicit empty list
+
+  set --
+  false
+  for x; do
+    print nothing executed
+  done
+0:Status 0 from for with implicit empty list
+
+  (exit 2)
+  for x in 1 2; do
+    print $?
+  done
+0:Status from previous command propagated into for loop
+>2
+>0
+
+  false
+  for x in $(echo 1 2; (exit 3)); do
+    print $?
+  done
+0:Status from expansion propagated into for loop
+>3
+>0
+
+  false
+  for x in $(exit 4); do
+    print not executed
+  done
+0:Status from expansion not propagated after unexecuted for loop
+  
+  false
+  for x in NonExistentFilePrefix*(N); do
+    print not executed, either
+  done
+0:Status from before for loop not propagated if empty after expansion
+
+  for x in $(echo 1; false); do
+  done
+0:Status reset by empty list in for loop
+
+  false
+  for x in $(echo 1; false); do
+    echo $?
+    (exit 4)  
+  done
+4:Last status from loop body is kept even with other funny business going on
+>1