diff options
author | Steve Bennett <steveb@workware.net.au> | 2010-01-24 13:46:32 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2010-10-15 11:02:45 +1000 |
commit | ee6dbe0a8d66f8f17a5da82e8dad810d88e33bf6 (patch) | |
tree | 994b59d11b3199f697adaea8303ae8b5dc438397 /tests/misc.test | |
parent | 541fe7c30691ace08847a35280d9cc8bc02e9a72 (diff) | |
download | jimtcl-ee6dbe0a8d66f8f17a5da82e8dad810d88e33bf6.zip jimtcl-ee6dbe0a8d66f8f17a5da82e8dad810d88e33bf6.tar.gz jimtcl-ee6dbe0a8d66f8f17a5da82e8dad810d88e33bf6.tar.bz2 |
Allow catch to specify what is caught
*: Default to the same as Tcl. Not signal, eval, exit.
*: Use 'catch -exit' to also catch exit.
*: Also map for standard return codes: [info returncodes]
*: Also Jim_ReturnCode()
*: Add Jim_FindByName() for searching in a char* array
*: Fix 'info nameofexectutable' if $::jim_argv0 is not set
Diffstat (limited to 'tests/misc.test')
-rw-r--r-- | tests/misc.test | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/misc.test b/tests/misc.test index eda2879..cb46591 100644 --- a/tests/misc.test +++ b/tests/misc.test @@ -237,4 +237,52 @@ test incr-1.4 "incr array element - shimmering" { incr a(2) } 2 +test catch-1.1 "catch ok" { + list [catch {set abc 2} result] $result +} {0 2} + +test catch-1.2 "catch error" { + list [catch {error 3} result] $result +} {1 3} + +test catch-1.3 "catch break" { + list [catch {break} result] $result +} {3 {}} + +test catch-1.4 "catch -nobreak" { + set result {} + foreach x {a b c} { + lappend result $x + # This acts just like break since it won't be caught by catch + catch -nobreak {break} tmp + } + set result +} {a} + +test catch-1.5 "catch -no3" { + set result {} + foreach x {a b c} { + lappend result $x + # Same as above, but specify as an integer + catch -no3 {break} tmp + } + set result +} {a} + +test catch-1.6 "catch break" { + set result {} + foreach x {a b c} { + lappend result $x + # This does nothing since the break is caught + catch {break} tmp + } + set result +} {a b c} + + +test catch-1.7 "catch exit" { + # Normally exit would not be caught + dict get [info returncodes] [catch -exit {exit 5} result] +} {exit} + testreport |