File: infoframe.test

package info (click to toggle)
jimtcl 0.83-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 17,432 kB
  • sloc: ansic: 207,301; tcl: 5,862; sh: 4,834; cpp: 1,671; makefile: 288
file content (50 lines) | stat: -rw-r--r-- 1,355 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
source [file dirname [info script]]/testing.tcl

proc a {n args} {
	if {$n eq "trace"} {
		return [basename-stacktrace [stacktrace {*}$args]]
	}
	set frame [info frame $n]
	if {![dict exists $frame proc]} {
		dict set frame proc {}
	}
	basename-stacktrace [list [dict get $frame proc] [file tail [dict get $frame file]] [dict get $frame line] [dict get $frame cmd]]
}

proc b {args} {
	a {*}$args
}

proc c {args} {
	b {*}$args
}

# --- Don't change line numbers above

test info-frame-1.1 {Current command} -body {
	c 0
} -result {a infoframe.test 7 {info frame 0}}

test info-frame-1.2 {Current Proc} -body {
	c -1
} -result {b infoframe.test 15 {a -1}}

test info-frame-1.3 Caller -body {
	c -2
} -result {c infoframe.test 19 {b -2}}

test info-frame-1.4 {Caller of Caller} -body {
	c -3
} -result {test infoframe.test 37 {c -3}}

test stacktrace-1.1 {Full stack trace} -body {
	c trace
} -result {a infoframe.test 5 stacktrace b infoframe.test 15 {a trace} c infoframe.test 19 {b trace} test infoframe.test 41 {c trace} {} infoframe.test 40 test\ stacktrace-1.1\ \{...}

test stacktrace-1.2 {Stack trace with limited depth} -body {
	# This will limit the stack trace to omit "this" level and below
	c trace 0 [info frame]
} -result {a infoframe.test 5 {stacktrace 0 2} b infoframe.test 15 {a trace 0 2} c infoframe.test 19 {b trace 0 2}}


testreport