about summary refs log tree commit diff
path: root/Test/C03traps.ztst
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-01-12 23:10:15 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-01-12 23:10:15 +0000
commitb4a7ad8269676f0fa281dab1ca1d09ed2a93a799 (patch)
treecc8668ca03b61166ce2b1267b93010e3ec9bb99c /Test/C03traps.ztst
parente8b56578db3d971b18d59a5c579ae19b70ec50a1 (diff)
downloadzsh-b4a7ad8269676f0fa281dab1ca1d09ed2a93a799.tar.gz
zsh-b4a7ad8269676f0fa281dab1ca1d09ed2a93a799.tar.xz
zsh-b4a7ad8269676f0fa281dab1ca1d09ed2a93a799.zip
23101: various combinations of ZERR with function returns were feature-ridden
Diffstat (limited to 'Test/C03traps.ztst')
-rw-r--r--Test/C03traps.ztst63
1 files changed, 63 insertions, 0 deletions
diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst
index 82e401fd1..252ccc4cb 100644
--- a/Test/C03traps.ztst
+++ b/Test/C03traps.ztst
@@ -287,6 +287,69 @@
 >child exiting
 >wait #2 finished, gotsig=0, status=33
 
+  fn1() {
+    setopt errexit
+    trap 'echo error1' ZERR
+    false
+    print Shouldn\'t get here 1a
+  }
+  fn2() {
+    setopt errexit
+    trap 'echo error2' ZERR
+    return 1
+    print Shouldn\'t get here 2a
+  }
+  fn3() {
+    setopt errexit
+    TRAPZERR() { echo error3; }
+    false
+    print Shouldn\'t get here 3a
+  }
+  fn4() {
+    setopt errexit
+    TRAPZERR() { echo error4; }
+    return 1
+    print Shouldn\'t get here 4a
+  }
+  (fn1; print Shouldn\'t get here 1b)
+  (fn2; print Shouldn\'t get here 2b)
+  (fn3; print Shouldn\'t get here 3b)
+  (fn4; print Shouldn\'t get here 4b)
+1: Combination of ERR_EXIT and ZERR trap
+>error1
+>error2
+>error3
+>error4
+
+   fn1() { TRAPZERR() { print trap; return 42; }; false; print Broken; }
+   (fn1)
+   print Working $?
+0: Force return of containing function from TRAPZERR.
+>trap
+>Working 42
+
+   fn2() { trap 'print trap; return 42' ZERR; false; print Broken }
+   (fn2)
+   print Working $?
+0: Return with non-zero status triggered from within trap '...' ZERR.
+>trap
+>Working 42
+
+   fn3() { TRAPZERR() { print trap; return 0; }; false; print OK this time; }
+   (fn3)
+   print Working $?
+0: Normal return from TRAPZERR.
+>trap
+>OK this time
+>Working 0
+
+   fn4() { trap 'print trap; return 0' ZERR; false; print Broken; }
+   (fn4)
+   print Working $?
+0: Return with zero status triggered from within trap '...' ZERR.
+>trap
+>Working 0
+
 %clean
 
   rm -f TRAPEXIT