diff options
author | Steve Bennett <steveb@workware.net.au> | 2010-01-24 10:53:36 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2010-10-15 11:02:39 +1000 |
commit | 6ef810ae664dccd457fe1ed750f7d509b6f60878 (patch) | |
tree | 13f3ab69416d1fc7f5d10db06c1bf83aa0153e4f /tests/error.test | |
parent | a0017cc44c22a83df8f92600317ad8ccd635e2a1 (diff) | |
download | jimtcl-6ef810ae664dccd457fe1ed750f7d509b6f60878.zip jimtcl-6ef810ae664dccd457fe1ed750f7d509b6f60878.tar.gz jimtcl-6ef810ae664dccd457fe1ed750f7d509b6f60878.tar.bz2 |
Bugs, features and tests
source fails with zero length file
unknown can't be called recursively
*: This can be useful when using unknown to dynamically load code,
which may in turn want to dynamically load code
*: Limit it to 50 recursions though
Allow string greater/less comparison
*: Comparing two strings for order did not work
Implement file join
*: It's not to hard and is handy when working with the current dir, ""
Don't omit [unknown] completely from stack trace
*: Since we lose valuable informtion, just omit the name
Fix return from case
Turn regexp patterns into real objects
*: Thus caching the compiled regexps
Allow error to rethrow an error
Replace bcopy() with more standard memcpy()
Fixes to parray, improve errorInfo
*: errorInfo takes an optional stack trace
Add tests for rethrowing errors via errorInfo
Fix ndelay
*: Was looking at wrong param
*: Also fix usage/help for aio.socket
Package should be able to call exit
*: Currently any return from a package is changed to JIM_ERR
Line counting is incorrect for backlash newline
Diffstat (limited to 'tests/error.test')
-rw-r--r-- | tests/error.test | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/error.test b/tests/error.test new file mode 100644 index 0000000..0bcd0da --- /dev/null +++ b/tests/error.test @@ -0,0 +1,53 @@ +package require testing + +proc a {} { + error "error thrown from a" +} + +proc b {} { + set rc [catch {a} msg] + if {$rc} { + error $msg [info stacktrace] + } +} + +test error-1.1 "Rethrow caught error" { + set rc [catch {b} msg] + #puts stderr "error-1.1\n[errorInfo $msg]\n" + + list $rc $msg [info stacktrace] +} {1 {error thrown from a} {{} error.test 4 a error.test 8 b error.test 15}} + +proc c {} { + a +} + +proc d {} { + c +} + +proc e {} { + d +} + +test error-1.2 "Modify stacktrace" { + set rc [catch {e} msg] + set st [info stacktrace] + # Now elide one entry from the stacktrace + #puts [errorInfo $msg] + set newst {} + foreach {p f l} $st { + if {$p ne "d"} { + lappend newst $p $f $l + } + } + # Now rethrow with the new stack + set rc [catch {error $msg $newst} msg] + #puts [errorInfo $msg] + info stacktrace +} {{} error.test 4 a error.test 22 c error.test 26 e error.test 34} + +# 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 +} {7 {Can't find package 'exitpackage'}} |