aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMason Jones <20848827+smj-edison@users.noreply.github.com>2025-04-21 21:01:28 -0700
committerSteve Bennett <steveb@workware.net.au>2025-04-22 04:54:23 +0000
commitf659fc4ec46f34c5c4a59a3f2223db6463e1d97d (patch)
tree029602d6cbbf38b245ebc6bbe9fb7f1a14bd97e5 /tests
parent9eaf6be68bade1f74302b78cd8c2f68fddf20442 (diff)
downloadjimtcl-master.zip
jimtcl-master.tar.gz
jimtcl-master.tar.bz2
try: Fix bug with `errorCode` being shorter than `match`HEADmaster
Currently jimtcl compares each element of `errorCode` against each `match` element. But, it doesn't account for the situation where `errorCode` is shorter than `match`. In this case the match should always fail (rather than segfaulting).
Diffstat (limited to 'tests')
-rw-r--r--tests/try.test9
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/try.test b/tests/try.test
index 0d76865..36a9bf9 100644
--- a/tests/try.test
+++ b/tests/try.test
@@ -104,7 +104,7 @@ test try-2.1 "try ... trap" -body {
try {
a
} trap CUSTOM {msg opts} {
- list $msg $opts(-code) $opts(-errorcode)
+ list $msg [dict get $opts -code] [dict get $opts -errorcode]
}
} -result {{custom errorcode} 1 {CUSTOM RESULT}}
@@ -140,6 +140,13 @@ test try-2.5 "trap match first but not second" -body {
}
} -returnCodes error -result failed
+test try-2.6 "trap match too long" -body {
+ try {
+ apply {{} {return -code error -errorcode {FOO BAR} failed}}
+ } trap {FOO BAR BAZ} {msg opts} {
+ list trapped
+ }
+} -returnCodes error -result failed
proc c {} {
try {