summaryrefslogtreecommitdiffstats
path: root/tests/result.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/result.test')
-rw-r--r--tests/result.test22
1 files changed, 16 insertions, 6 deletions
diff --git a/tests/result.test b/tests/result.test
index 22419e3..9e8a66b 100644
--- a/tests/result.test
+++ b/tests/result.test
@@ -13,6 +13,9 @@
package require tcltest 2
namespace import ::tcltest::*
+::tcltest::loadTestedCommands
+catch [list package require -exact Tcltest [info patchlevel]]
+
# Some tests require the testsaveresult command
testConstraint testsaveresult [llength [info commands testsaveresult]]
@@ -45,7 +48,6 @@ test result-1.8 {Tcl_SaveInterpResult} {testsaveresult} {
testsaveresult object {set x 42} 1
} {42 different}
-
# Tcl_RestoreInterpResult is mostly tested by the previous tests except
# for the following case
@@ -56,9 +58,9 @@ test result-2.1 {Tcl_RestoreInterpResult} {testsaveresult} {
# Tcl_DiscardInterpResult is mostly tested by the previous tests except
# for the following cases
-test result-3.1 {Tcl_DiscardInterpResult} {testsaveresult} {
- list [catch {testsaveresult append {cd _foobar} 1} msg] $msg
-} {1 {couldn't change working directory to "_foobar": no such file or directory}}
+test result-3.1 {Tcl_DiscardInterpResult} -constraints testsaveresult -body {
+ testsaveresult append {cd _foobar} 1
+} -returnCodes error -result {couldn't change working directory to "_foobar": no such file or directory}
test result-3.2 {Tcl_DiscardInterpResult} {testsaveresult} {
testsaveresult free {set x 42} 1
} {42}
@@ -129,9 +131,17 @@ test result-6.2 {Bug 1649062} -setup {
rename foo {}
} -result {foo {} {}}
test result-6.3 {Bug 2383005} {
- catch {return -code error -errorcode {{}a} eek} m
- set m
+ catch {return -code error -errorcode {{}a} eek} m
+ set m
} {bad -errorcode value: expected a list but got "{}a"}
+test result-6.4 {non-list -errorstack} -body {
+ catch {return -code error -errorstack {{}a} eek} m o
+ list $m [dict get $o -errorcode] [dict get $o -errorstack]
+} -match glob -result {{bad -errorstack value: expected a list but got "{}a"} {TCL RESULT NONLIST_ERRORSTACK} {INNER * UP 1}}
+test result-6.5 {odd-sized-list -errorstack} -body {
+ catch {return -code error -errorstack a eek} m o
+ list $m [dict get $o -errorcode] [dict get $o -errorstack]
+} -match glob -result {{forbidden odd-sized list for -errorstack: "a"} {TCL RESULT ODDSIZEDLIST_ERRORSTACK} {INNER * UP 1}}
# cleanup
cleanupTests
return