summary refs log tree commit diff
path: root/Test/C03traps.ztst
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2005-02-06 20:36:09 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2005-02-06 20:36:09 +0000
commit05b06b1c08263af07b2297aac0c842dafca39445 (patch)
treef64a8e7c40efd43221cfa4bd8f0391e0c993765d /Test/C03traps.ztst
parent64c2db0ca242269c92fac5cc8637580364c2b6f6 (diff)
downloadzsh-05b06b1c08263af07b2297aac0c842dafca39445.tar.gz
zsh-05b06b1c08263af07b2297aac0c842dafca39445.tar.xz
zsh-05b06b1c08263af07b2297aac0c842dafca39445.zip
fix autoloaded trap bug; rejig use of trapfuncs
(now traplists); improve trap tests
Diffstat (limited to 'Test/C03traps.ztst')
-rw-r--r--Test/C03traps.ztst34
1 files changed, 32 insertions, 2 deletions
diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst
index 3ef399efd..f75c47c4d 100644
--- a/Test/C03traps.ztst
+++ b/Test/C03traps.ztst
@@ -183,17 +183,21 @@
   }
   testunset
   f
-1: more sophisticated error trapping
+  print status $?
+  unfunction TRAPZERR
+0: more sophisticated error trapping
 >f
 >ERR-or!
 >f
 >t
+>f
 >t
 >f
 >ERR-or!
 >testunset
 >f
 >ERR-or!
+>status 1
 
   f() {
     setopt localtraps
@@ -216,6 +220,32 @@
   fn
 1: ksh-style EXIT traps preserve return value
 
-  inner() { trap 'return 3' EXIT; return 2: }
+  inner() { trap 'return 3' EXIT; return 2; }
   outer() { inner; return 1; }
+  outer
 3: ksh-style EXIT traps can force return status of enclosing function
+
+# Autoloaded traps are horrid, but unfortunately people expect
+# them to work if we support them.
+  echo "print Running exit trap" >TRAPEXIT
+  $ZTST_testdir/../Src/zsh -fc '
+    fpath=(. $fpath)
+    autoload TRAPEXIT
+    print "Exiting, attempt 1"
+    exit
+    print "What?"
+  '
+  $ZTST_testdir/../Src/zsh -fc '
+    fpath=(. $fpath)
+    autoload TRAPEXIT;
+    fn() { print Some function }
+    fn
+    print "Exiting, attempt 2"
+    exit
+  '
+0: autoloaded TRAPEXIT (exit status > 128 indicates an old bug is back)
+>Exiting, attempt 1
+>Running exit trap
+>Some function
+>Exiting, attempt 2
+>Running exit trap