diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/try.test | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/try.test b/tests/try.test new file mode 100644 index 0000000..3cc86fb --- /dev/null +++ b/tests/try.test @@ -0,0 +1,65 @@ +source testing.tcl + +test try-1.1 "Simple case" { + try { + set x 0 + } finally { + incr x + } +} 0 + +test try-1.2 "Error in body" { + list [catch { + try { + set x 0 + error message + } finally { + incr x + } + } msg] $msg $x +} {1 message 1} + +test try-1.3 "Error in finally" { + list [catch { + try { + set x 0 + } finally { + incr x + error finally + } + } msg] $msg $x +} {1 finally 1} + +test try-1.4 "Error in both" { + list [catch { + try { + set x 0 + error message + } finally { + incr x + error finally + } + } msg] $msg $x +} {1 message 1} + +test try-1.5 "break in body" { + list [catch { + try { + set x 0 + break + } finally { + incr x + } + } msg] $msg $x +} {3 {} 1} + +test try-1.6 "break in finally" { + list [catch { + try { + set x 0 + } finally { + incr x + break + } + } msg] $msg $x +} {3 {} 1} |