diff options
author | Steve Bennett <steveb@workware.net.au> | 2023-01-13 10:23:19 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2023-02-13 10:43:00 +1000 |
commit | 517d85974c7cf8d4f894f46251462e14b6fc562f (patch) | |
tree | 2e4eebd4f75671687827d484803e1a2da1d60d88 /tests/infoframe.test | |
parent | db26fe46ea9a35d403067498f4b85eee82b431b0 (diff) | |
download | jimtcl-517d85974c7cf8d4f894f46251462e14b6fc562f.zip jimtcl-517d85974c7cf8d4f894f46251462e14b6fc562f.tar.gz jimtcl-517d85974c7cf8d4f894f46251462e14b6fc562f.tar.bz2 |
Tcl-compatible 'info frame'
Returns a dictionary with file, line, cmd, (possibly) proc and level.
And support 'info frame 0' for the current command.
Note that now all evaluation frames are captured, not just call frames.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tests/infoframe.test')
-rw-r--r-- | tests/infoframe.test | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/tests/infoframe.test b/tests/infoframe.test index 0bfd7a9..9490589 100644 --- a/tests/infoframe.test +++ b/tests/infoframe.test @@ -2,10 +2,10 @@ source [file dirname [info script]]/testing.tcl needs constraint jim proc a {n} { if {$n eq "trace"} { - basename-stacktrace [stacktrace] - } else { - basename-stacktrace [info frame $n] + # strip the frame levels for test and uplevel + return [basename-stacktrace [lrange [stacktrace] 0 end-6]] } + set frame [info frame $n]; list [dict getdef $frame proc {}] [file tail [dict get $frame file]] [dict get $frame line] } proc b {n} { @@ -18,20 +18,24 @@ proc c {n} { # --- Don't change line numbers above -test info-frame-1.1 "Current proc" { +test info-frame-1.1 "Current command" { c 0 -} {a infoframe.test 12} +} {a infoframe.test 8} -test info-frame-1.2 "Caller" { +test info-frame-1.2 "Current Proc" { c -1 -} {b infoframe.test 16} +} {b infoframe.test 12} -test info-frame-1.3 "Caller of Caller" { +test info-frame-1.3 "Caller" { c -2 -} {c infoframe.test 30} +} {c infoframe.test 16} + +test info-frame-1.4 "Caller of Caller" { + c -3 +} {test infoframe.test 34} test stacktrace-1.1 "Full stack trace" { c trace -} {a infoframe.test 12 b infoframe.test 16 c infoframe.test 34} +} {a infoframe.test 12 b infoframe.test 16 c infoframe.test 38} testreport |