aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/error.test2
-rw-r--r--tests/misc.test48
2 files changed, 49 insertions, 1 deletions
diff --git a/tests/error.test b/tests/error.test
index 66df7c2..a059ba3 100644
--- a/tests/error.test
+++ b/tests/error.test
@@ -49,5 +49,5 @@ test error-1.2 "Modify stacktrace" {
# Package should be able to invoke exit, which should exit if not caught
test error-2.1 "Exit from package" {
- list [catch {package require exitpackage} msg] $msg
+ list [catch -exit {package require exitpackage} msg] $msg
} {6 {Can't load package 'exitpackage'}}
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