| ︙ | | | ︙ | |
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
# Copyright (c) 2006 ActiveState
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: info.test,v 1.44 2007/05/18 18:39:31 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
namespace import -force ::tcltest::*
}
# Set up namespaces needed to test operation of "info args", "info body",
|
|
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
# Copyright (c) 2006 ActiveState
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: info.test,v 1.45 2007/06/12 12:34:04 dkf Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
namespace import -force ::tcltest::*
}
# Set up namespaces needed to test operation of "info args", "info body",
|
| ︙ | | | ︙ | |
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
proc t1 {{a default1} {bbb default2} {c default3} args} {return foo}
info a t1
} {a bbb c args}
test info-1.3 {info args option} {
proc t1 "" {return foo}
info args t1
} {}
test info-1.4 {info args option} {
catch {rename t1 {}}
list [catch {info args t1} msg] $msg
} {1 {"t1" isn't a procedure}}
test info-1.5 {info args option} {
list [catch {info args set} msg] $msg
} {1 {"set" isn't a procedure}}
test info-1.6 {info args option} {
proc t1 {a b} {set c 123; set d $c}
t1 1 2
info args t1
} {a b}
test info-1.7 {info args option} {
catch {namespace delete test_ns_info2}
namespace eval test_ns_info2 {
namespace import ::test_ns_info1::*
list [info args p] [info args q]
}
} {x {y z}}
test info-2.1 {info body option} {
proc t1 {} {body of t1}
info body t1
} {body of t1}
test info-2.2 {info body option} {
list [catch {info body set} msg] $msg
} {1 {"set" isn't a procedure}}
test info-2.3 {info body option} {
list [catch {info args set 1} msg] $msg
} {1 {wrong # args: should be "info args procname"}}
test info-2.4 {info body option} {
catch {namespace delete test_ns_info2}
namespace eval test_ns_info2 {
namespace import ::test_ns_info1::*
list [info body p] [info body q]
}
} {{return "x=$x"} {return "y=$y"}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
proc t1 {{a default1} {bbb default2} {c default3} args} {return foo}
info a t1
} {a bbb c args}
test info-1.3 {info args option} {
proc t1 "" {return foo}
info args t1
} {}
test info-1.4 {info args option} -body {
catch {rename t1 {}}
info args t1
} -returnCodes error -result {"t1" isn't a procedure}
test info-1.5 {info args option} -body {
info args set
} -returnCodes error -result {"set" isn't a procedure}
test info-1.6 {info args option} {
proc t1 {a b} {set c 123; set d $c}
t1 1 2
info args t1
} {a b}
test info-1.7 {info args option} {
catch {namespace delete test_ns_info2}
namespace eval test_ns_info2 {
namespace import ::test_ns_info1::*
list [info args p] [info args q]
}
} {x {y z}}
test info-2.1 {info body option} {
proc t1 {} {body of t1}
info body t1
} {body of t1}
test info-2.2 {info body option} -body {
info body set
} -returnCodes error -result {"set" isn't a procedure}
test info-2.3 {info body option} -body {
info args set 1
} -returnCodes error -result {wrong # args: should be "info args procname"}
test info-2.4 {info body option} {
catch {namespace delete test_ns_info2}
namespace eval test_ns_info2 {
namespace import ::test_ns_info1::*
list [info body p] [info body q]
}
} {{return "x=$x"} {return "y=$y"}}
|
| ︙ | | | ︙ | |
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
set x [info cmdcount]
set y 12345
set z [info cm]
expr $z-$x
}
test info-3.1 {info cmdcount compiled} {
testinfocmdcount
} 3
test info-3.2 {info cmdcount evaled} {
set x [info cmdcount]
set y 12345
set z [info cm]
expr $z-$x
} 3
test info-3.3 {info cmdcount evaled} [info body testinfocmdcount] 3
test info-3.4 {info cmdcount option} {
list [catch {info cmdcount 1} msg] $msg
} {1 {wrong # args: should be "info cmdcount"}}
test info-4.1 {info commands option} {
proc t1 {} {}
proc t2 {} {}
set x " [info commands] "
list [string match {* t1 *} $x] [string match {* t2 *} $x] \
[string match {* set *} $x] [string match {* list *} $x]
|
|
|
|
|
|
|
|
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
set x [info cmdcount]
set y 12345
set z [info cm]
expr $z-$x
}
test info-3.1 {info cmdcount compiled} {
testinfocmdcount
} 4
test info-3.2 {info cmdcount evaled} {
set x [info cmdcount]
set y 12345
set z [info cm]
expr $z-$x
} 4
test info-3.3 {info cmdcount evaled} [info body testinfocmdcount] 4
test info-3.4 {info cmdcount option} -body {
info cmdcount 1
} -returnCodes error -result {wrong # args: should be "info cmdcount"}
test info-4.1 {info commands option} {
proc t1 {} {}
proc t2 {} {}
set x " [info commands] "
list [string match {* t1 *} $x] [string match {* t2 *} $x] \
[string match {* set *} $x] [string match {* list *} $x]
|
| ︙ | | | ︙ | |
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
test info-4.4 {info commands option} {
proc _t1_ {} {}
proc _t2_ {} {}
lsort [info commands _t*]
} {_t1_ _t2_}
catch {rename _t1_ {}}
catch {rename _t2_ {}}
test info-4.5 {info commands option} {
list [catch {info commands a b} msg] $msg
} {1 {wrong # args: should be "info commands ?pattern?"}}
# Also some tests in namespace.test
test info-5.1 {info complete option} {
list [catch {info complete} msg] $msg
} {1 {wrong # args: should be "info complete command"}}
test info-5.2 {info complete option} {
info complete abc
} 1
test info-5.3 {info complete option} {
info complete "\{abcd "
} 0
test info-5.4 {info complete option} {
|
|
|
|
|
|
|
|
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
test info-4.4 {info commands option} {
proc _t1_ {} {}
proc _t2_ {} {}
lsort [info commands _t*]
} {_t1_ _t2_}
catch {rename _t1_ {}}
catch {rename _t2_ {}}
test info-4.5 {info commands option} -returnCodes error -body {
info commands a b
} -result {wrong # args: should be "info commands ?pattern?"}
# Also some tests in namespace.test
test info-5.1 {info complete option} -body {
info complete
} -returnCodes error -result {wrong # args: should be "info complete command"}
test info-5.2 {info complete option} {
info complete abc
} 1
test info-5.3 {info complete option} {
info complete "\{abcd "
} 0
test info-5.4 {info complete option} {
|
| ︙ | | | ︙ | |
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
} d
test info-6.5 {info default option} {
proc t1 {a b {c d} {e "long default value"}} {}
set value 12345
set x [info default t1 e value]
list $x $value
} {1 {long default value}}
test info-6.6 {info default option} {
list [catch {info default a b} msg] $msg
} {1 {wrong # args: should be "info default procname arg varname"}}
test info-6.7 {info default option} {
list [catch {info default _nonexistent_ a b} msg] $msg
} {1 {"_nonexistent_" isn't a procedure}}
test info-6.8 {info default option} {
proc t1 {a b} {}
list [catch {info default t1 x value} msg] $msg
} {1 {procedure "t1" doesn't have an argument "x"}}
test info-6.9 {info default option} {
catch {unset a}
set a(0) 88
proc t1 {a b} {}
list [catch {info default t1 a a} msg] $msg
} {1 {couldn't store default value in variable "a"}}
test info-6.10 {info default option} {
catch {unset a}
set a(0) 88
proc t1 {{a 18} b} {}
list [catch {info default t1 a a} msg] $msg
} {1 {couldn't store default value in variable "a"}}
test info-6.11 {info default option} {
catch {namespace delete test_ns_info2}
namespace eval test_ns_info2 {
namespace import ::test_ns_info1::*
list [info default p x foo] $foo [info default q y bar] $bar
}
} {0 {} 1 27}
|
|
|
|
|
|
|
|
|
|
|
>
|
|
|
>
|
|
|
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
} d
test info-6.5 {info default option} {
proc t1 {a b {c d} {e "long default value"}} {}
set value 12345
set x [info default t1 e value]
list $x $value
} {1 {long default value}}
test info-6.6 {info default option} -returnCodes error -body {
info default a b
} -result {wrong # args: should be "info default procname arg varname"}
test info-6.7 {info default option} -returnCodes error -body {
info default _nonexistent_ a b
} -result {"_nonexistent_" isn't a procedure}
test info-6.8 {info default option} -returnCodes error -body {
proc t1 {a b} {}
info default t1 x value
} -result {procedure "t1" doesn't have an argument "x"}
test info-6.9 {info default option} -returnCodes error -setup {
catch {unset a}
} -body {
set a(0) 88
proc t1 {a b} {}
info default t1 a a
} -returnCodes error -result {couldn't store default value in variable "a"}
test info-6.10 {info default option} -setup {
catch {unset a}
} -body {
set a(0) 88
proc t1 {{a 18} b} {}
info default t1 a a
} -returnCodes error -result {couldn't store default value in variable "a"}
test info-6.11 {info default option} {
catch {namespace delete test_ns_info2}
namespace eval test_ns_info2 {
namespace import ::test_ns_info1::*
list [info default p x foo] $foo [info default q y bar] $bar
}
} {0 {} 1 27}
|
| ︙ | | | ︙ | |
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
}
t1 2
} 1
test info-7.6 {info exists option} {
proc t1 {x} {return [info exists value]}
t1 2
} 0
test info-7.7 {info exists option} {
catch {unset x}
set x(2) 44
list [info exists x] [info exists x(1)] [info exists x(2)]
} {1 0 1}
catch {unset x}
test info-7.8 {info exists option} {
list [catch {info exists} msg] $msg
} {1 {wrong # args: should be "info exists varName"}}
test info-7.9 {info exists option} {
list [catch {info exists 1 2} msg] $msg
} {1 {wrong # args: should be "info exists varName"}}
test info-8.1 {info globals option} {
set x 1
set y 2
set value 23
set a " [info globals] "
list [string match {* x *} $a] [string match {* y *} $a] \
[string match {* value *} $a] [string match {* _foobar_ *} $a]
} {1 1 1 0}
test info-8.2 {info globals option} {
set _xxx1 1
set _xxx2 2
lsort [info g _xxx*]
} {_xxx1 _xxx2}
test info-8.3 {info globals option} {
list [catch {info globals 1 2} msg] $msg
} {1 {wrong # args: should be "info globals ?pattern?"}}
test info-8.4 {info globals option: may have leading namespace qualifiers} {
set x 0
list [info globals x] [info globals :x] [info globals ::x] [info globals :::x] [info globals ::::x]
} {x {} x x x}
test info-8.5 {info globals option: only return existing global variables} {
-setup {
catch {unset ::NO_SUCH_VAR}
|
|
>
|
|
|
|
|
|
|
|
|
|
|
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
}
t1 2
} 1
test info-7.6 {info exists option} {
proc t1 {x} {return [info exists value]}
t1 2
} 0
test info-7.7 {info exists option} -setup {
catch {unset x}
} -body {
set x(2) 44
list [info exists x] [info exists x(1)] [info exists x(2)]
} -result {1 0 1}
catch {unset x}
test info-7.8 {info exists option} -body {
info exists
} -returnCodes error -result {wrong # args: should be "info exists varName"}
test info-7.9 {info exists option} -body {
info exists 1 2
} -returnCodes error -result {wrong # args: should be "info exists varName"}
test info-8.1 {info globals option} {
set x 1
set y 2
set value 23
set a " [info globals] "
list [string match {* x *} $a] [string match {* y *} $a] \
[string match {* value *} $a] [string match {* _foobar_ *} $a]
} {1 1 1 0}
test info-8.2 {info globals option} {
set _xxx1 1
set _xxx2 2
lsort [info g _xxx*]
} {_xxx1 _xxx2}
test info-8.3 {info globals option} -returnCodes error -body {
info globals 1 2
} -result {wrong # args: should be "info globals ?pattern?"}
test info-8.4 {info globals option: may have leading namespace qualifiers} {
set x 0
list [info globals x] [info globals :x] [info globals ::x] [info globals :::x] [info globals ::::x]
} {x {} x x x}
test info-8.5 {info globals option: only return existing global variables} {
-setup {
catch {unset ::NO_SUCH_VAR}
|
| ︙ | | | ︙ | |
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
|
proc t1 {} {
set x [info level]
set y [info level 1]
list $x $y
}
t1
} {1 t1}
test info-9.5 {info level option} {
list [catch {info level 1 2} msg] $msg
} {1 {wrong # args: should be "info level ?number?"}}
test info-9.6 {info level option} {
list [catch {info level 123a} msg] $msg
} {1 {expected integer but got "123a"}}
test info-9.7 {info level option} {
list [catch {info level 0} msg] $msg
} {1 {bad level "0"}}
test info-9.8 {info level option} {
proc t1 {} {info level -1}
list [catch {t1} msg] $msg
} {1 {bad level "-1"}}
test info-9.9 {info level option} {
proc t1 {x} {info level $x}
list [catch {t1 -3} msg] $msg
} {1 {bad level "-3"}}
test info-9.10 {info level option, namespaces} {
set msg [namespace eval t {info level 0}]
namespace delete t
set msg
} {namespace eval t {info level 0}}
test info-9.11 {info level option, aliases} -constraints knownBug -setup {
proc w {x y z} {info level 0}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
|
proc t1 {} {
set x [info level]
set y [info level 1]
list $x $y
}
t1
} {1 t1}
test info-9.5 {info level option} -body {
info level 1 2
} -returnCodes error -result {wrong # args: should be "info level ?number?"}
test info-9.6 {info level option} -body {
info level 123a
} -returnCodes error -result {expected integer but got "123a"}
test info-9.7 {info level option} -body {
info level 0
} -returnCodes error -result {bad level "0"}
test info-9.8 {info level option} -body {
proc t1 {} {info level -1}
t1
} -returnCodes error -result {bad level "-1"}
test info-9.9 {info level option} -body {
proc t1 {x} {info level $x}
t1 -3
} -returnCodes error -result {bad level "-3"}
test info-9.10 {info level option, namespaces} {
set msg [namespace eval t {info level 0}]
namespace delete t
set msg
} {namespace eval t {info level 0}}
test info-9.11 {info level option, aliases} -constraints knownBug -setup {
proc w {x y z} {info level 0}
|
| ︙ | | | ︙ | |
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
|
a foo 1 2 3
} -cleanup {
rename a {}
rename w {}
} -result {a foo 1 2 3}
set savedLibrary $tcl_library
test info-10.1 {info library option} {
list [catch {info library x} msg] $msg
} {1 {wrong # args: should be "info library"}}
test info-10.2 {info library option} {
set tcl_library 12345
info library
} {12345}
test info-10.3 {info library option} {
unset tcl_library
list [catch {info library} msg] $msg
} {1 {no library has been specified for Tcl}}
set tcl_library $savedLibrary
test info-11.1 {info loaded option} {
list [catch {info loaded a b} msg] $msg
} {1 {wrong # args: should be "info loaded ?interp?"}}
test info-11.2 {info loaded option} {
list [catch {info loaded {}}] [catch {info loaded gorp} msg] $msg
} {0 1 {could not find interpreter "gorp"}}
test info-12.1 {info locals option} {
set a 22
proc t1 {x y} {
|
|
|
|
|
|
|
|
|
|
|
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
|
a foo 1 2 3
} -cleanup {
rename a {}
rename w {}
} -result {a foo 1 2 3}
set savedLibrary $tcl_library
test info-10.1 {info library option} -body {
info library x
} -returnCodes error -result {wrong # args: should be "info library"}
test info-10.2 {info library option} {
set tcl_library 12345
info library
} {12345}
test info-10.3 {info library option} -body {
unset tcl_library
info library
} -returnCodes error -result {no library has been specified for Tcl}
set tcl_library $savedLibrary
test info-11.1 {info loaded option} -body {
info loaded a b
} -returnCodes error -result {wrong # args: should be "info loaded ?interp?"}
test info-11.2 {info loaded option} {
list [catch {info loaded {}}] [catch {info loaded gorp} msg] $msg
} {0 1 {could not find interpreter "gorp"}}
test info-12.1 {info locals option} {
set a 22
proc t1 {x y} {
|
| ︙ | | | ︙ | |
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
|
set xx1 2
set xx2 3
set y 4
return [info loc x*]
}
lsort [t1 2 3]
} {x xx1 xx2}
test info-12.3 {info locals option} {
list [catch {info locals 1 2} msg] $msg
} {1 {wrong # args: should be "info locals ?pattern?"}}
test info-12.4 {info locals option} {
info locals
} {}
test info-12.5 {info locals option} {
proc t1 {} {return [info locals]}
t1
} {}
|
|
|
|
|
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
|
set xx1 2
set xx2 3
set y 4
return [info loc x*]
}
lsort [t1 2 3]
} {x xx1 xx2}
test info-12.3 {info locals option} -body {
info locals 1 2
} -returnCodes error -result {wrong # args: should be "info locals ?pattern?"}
test info-12.4 {info locals option} {
info locals
} {}
test info-12.5 {info locals option} {
proc t1 {} {return [info locals]}
t1
} {}
|
| ︙ | | | ︙ | |
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
|
proc t1 {} {
foreach a {b c} {}
info locals
}
t1
} {a}
test info-13.1 {info nameofexecutable option} {
list [catch {info nameofexecutable foo} msg] $msg
} {1 {wrong # args: should be "info nameofexecutable"}}
test info-14.1 {info patchlevel option} {
set a [info patchlevel]
regexp {[0-9]+\.[0-9]+([p[0-9]+)?} $a
} 1
test info-14.2 {info patchlevel option} {
list [catch {info patchlevel a} msg] $msg
} {1 {wrong # args: should be "info patchlevel"}}
test info-14.3 {info patchlevel option} {
set t $tcl_patchLevel
unset tcl_patchLevel
set result [list [catch {info patchlevel} msg] $msg]
set tcl_patchLevel $t
set result
} {1 {can't read "tcl_patchLevel": no such variable}}
test info-15.1 {info procs option} {
proc t1 {} {}
proc t2 {} {}
set x " [info procs] "
list [string match {* t1 *} $x] [string match {* t2 *} $x] \
[string match {* _undefined_ *} $x]
} {1 1 0}
test info-15.2 {info procs option} {
proc _tt1 {} {}
proc _tt2 {} {}
lsort [info pr _tt*]
} {_tt1 _tt2}
catch {rename _tt1 {}}
catch {rename _tt2 {}}
test info-15.3 {info procs option} {
list [catch {info procs 2 3} msg] $msg
} {1 {wrong # args: should be "info procs ?pattern?"}}
test info-15.4 {info procs option} {
catch {namespace delete test_ns_info2}
namespace eval test_ns_info2 {
namespace import ::test_ns_info1::*
proc r {} {}
list [info procs] [info procs p*]
}
} {{p q r} p}
test info-15.5 {info procs option with a proc in a namespace} {
catch {namespace delete test_ns_info2}
namespace eval test_ns_info2 {
proc p1 { arg } {
puts cmd
}
proc p2 { arg } {
puts cmd
}
}
info procs ::test_ns_info2::p1
} {::test_ns_info2::p1}
test info-15.6 {info procs option with a pattern in a namespace} {
catch {namespace delete test_ns_info2}
namespace eval test_ns_info2 {
proc p1 { arg } {
puts cmd
}
proc p2 { arg } {
puts cmd
}
}
lsort [info procs ::test_ns_info2::p*]
} [lsort [list ::test_ns_info2::p1 ::test_ns_info2::p2]]
test info-15.7 {info procs option with a global shadowing proc} {
catch {namespace delete test_ns_info2}
proc string_cmd { arg } {
puts cmd
}
namespace eval test_ns_info2 {
proc string_cmd { arg } {
puts cmd
}
}
info procs test_ns_info2::string*
} {::test_ns_info2::string_cmd}
# This regression test is currently commented out because it requires
# that the implementation of "info procs" looks into the global namespace,
# which it does not (in contrast to "info commands")
test info-15.8 {info procs option with a global shadowing proc} knownBug {
catch {namespace delete test_ns_info2}
proc string_cmd { arg } {
puts cmd
}
proc string_cmd2 { arg } {
puts cmd
}
namespace eval test_ns_info2 {
proc string_cmd { arg } {
puts cmd
}
}
namespace eval test_ns_info2 {
lsort [info procs string*]
}
} [lsort [list string_cmd string_cmd2]]
test info-16.1 {info script option} {
list [catch {info script x x} msg] $msg
} {1 {wrong # args: should be "info script ?filename?"}}
test info-16.2 {info script option} {
file tail [info sc]
} "info.test"
set gorpfile [makeFile "info script\n" gorp.info]
test info-16.3 {info script option} {
list [source $gorpfile] [file tail [info script]]
} [list $gorpfile info.test]
|
|
|
|
|
|
|
|
>
|
>
<
|
|
|
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
|
|
|
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
|
proc t1 {} {
foreach a {b c} {}
info locals
}
t1
} {a}
test info-13.1 {info nameofexecutable option} -returnCodes error -body {
info nameofexecutable foo
} -result {wrong # args: should be "info nameofexecutable"}
test info-14.1 {info patchlevel option} {
set a [info patchlevel]
regexp {[0-9]+\.[0-9]+([p[0-9]+)?} $a
} 1
test info-14.2 {info patchlevel option} -returnCodes error -body {
info patchlevel a
} -result {wrong # args: should be "info patchlevel"}
test info-14.3 {info patchlevel option} -setup {
set t $tcl_patchLevel
} -body {
unset tcl_patchLevel
info patchlevel
} -cleanup {
set tcl_patchLevel $t
} -returnCodes error -result {can't read "tcl_patchLevel": no such variable}
test info-15.1 {info procs option} {
proc t1 {} {}
proc t2 {} {}
set x " [info procs] "
list [string match {* t1 *} $x] [string match {* t2 *} $x] \
[string match {* _undefined_ *} $x]
} {1 1 0}
test info-15.2 {info procs option} {
proc _tt1 {} {}
proc _tt2 {} {}
lsort [info pr _tt*]
} {_tt1 _tt2}
catch {rename _tt1 {}}
catch {rename _tt2 {}}
test info-15.3 {info procs option} -body {
info procs 2 3
} -returnCodes error -result {wrong # args: should be "info procs ?pattern?"}
test info-15.4 {info procs option} -setup {
catch {namespace delete test_ns_info2}
} -body {
namespace eval test_ns_info2 {
namespace import ::test_ns_info1::*
proc r {} {}
list [info procs] [info procs p*]
}
} -result {{p q r} p}
test info-15.5 {info procs option with a proc in a namespace} -setup {
catch {namespace delete test_ns_info2}
} -body {
namespace eval test_ns_info2 {
proc p1 { arg } {
puts cmd
}
proc p2 { arg } {
puts cmd
}
}
info procs ::test_ns_info2::p1
} -result {::test_ns_info2::p1}
test info-15.6 {info procs option with a pattern in a namespace} -setup {
catch {namespace delete test_ns_info2}
} -body {
namespace eval test_ns_info2 {
proc p1 { arg } {
puts cmd
}
proc p2 { arg } {
puts cmd
}
}
lsort [info procs ::test_ns_info2::p*]
} -result [lsort [list ::test_ns_info2::p1 ::test_ns_info2::p2]]
test info-15.7 {info procs option with a global shadowing proc} -setup {
catch {namespace delete test_ns_info2}
} -body {
proc string_cmd { arg } {
puts cmd
}
namespace eval test_ns_info2 {
proc string_cmd { arg } {
puts cmd
}
}
info procs test_ns_info2::string*
} -result {::test_ns_info2::string_cmd}
# This regression test is currently commented out because it requires
# that the implementation of "info procs" looks into the global namespace,
# which it does not (in contrast to "info commands")
test info-15.8 {info procs option with a global shadowing proc} -setup {
catch {namespace delete test_ns_info2}
} -constraints knownBug -body {
proc string_cmd { arg } {
puts cmd
}
proc string_cmd2 { arg } {
puts cmd
}
namespace eval test_ns_info2 {
proc string_cmd { arg } {
puts cmd
}
}
namespace eval test_ns_info2 {
lsort [info procs string*]
}
} -result [lsort [list string_cmd string_cmd2]]
test info-16.1 {info script option} -returnCodes error -body {
info script x x
} -result {wrong # args: should be "info script ?filename?"}
test info-16.2 {info script option} {
file tail [info sc]
} "info.test"
set gorpfile [makeFile "info script\n" gorp.info]
test info-16.3 {info script option} {
list [source $gorpfile] [file tail [info script]]
} [list $gorpfile info.test]
|
| ︙ | | | ︙ | |
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
|
removeFile gorp.info
set gorpfile [makeFile {list [info script] [info script foo.bar]} gorp.info]
test info-16.8 {info script option} {
list [source $gorpfile] [file tail [info script]]
} [list [list $gorpfile foo.bar] info.test]
removeFile gorp.info
test info-17.1 {info sharedlibextension option} {
list [catch {info sharedlibextension foo} msg] $msg
} {1 {wrong # args: should be "info sharedlibextension"}}
test info-18.1 {info tclversion option} {
set x [info tclversion]
scan $x "%d.%d%c" a b c
} 2
test info-18.2 {info tclversion option} {
list [catch {info t 2} msg] $msg
} {1 {wrong # args: should be "info tclversion"}}
test info-18.3 {info tclversion option} {
set t $tcl_version
unset tcl_version
set result [list [catch {info tclversion} msg] $msg]
set tcl_version $t
set result
} {1 {can't read "tcl_version": no such variable}}
test info-19.1 {info vars option} {
set a 1
set b 2
proc t1 {x y} {
global a b
set c 33
|
|
|
|
|
<
|
|
|
|
<
|
>
>
>
<
|
|
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
|
removeFile gorp.info
set gorpfile [makeFile {list [info script] [info script foo.bar]} gorp.info]
test info-16.8 {info script option} {
list [source $gorpfile] [file tail [info script]]
} [list [list $gorpfile foo.bar] info.test]
removeFile gorp.info
test info-17.1 {info sharedlibextension option} -returnCodes error -body {
info sharedlibextension foo
} -result {wrong # args: should be "info sharedlibextension"}
test info-18.1 {info tclversion option} {
scan [info tclversion] "%d.%d%c" a b c
} 2
test info-18.2 {info tclversion option} -body {
info t 2
} -returnCodes error -result {wrong # args: should be "info tclversion"}
test info-18.3 {info tclversion option} -body {
unset tcl_version
info tclversion
} -returnCodes error -setup {
set t $tcl_version
} -cleanup {
set tcl_version $t
} -result {can't read "tcl_version": no such variable}
test info-19.1 {info vars option} {
set a 1
set b 2
proc t1 {x y} {
global a b
set c 33
|
| ︙ | | | ︙ | |
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
|
return [info vars x*]
}
lsort [t1 18 19]
} {xxa xxx1 xxx2}
test info-19.3 {info vars option} {
lsort [info vars]
} [lsort [info globals]]
test info-19.4 {info vars option} {
list [catch {info vars a b} msg] $msg
} {1 {wrong # args: should be "info vars ?pattern?"}}
test info-19.5 {info vars with temporary variables} {
proc t1 {} {
foreach a {b c} {}
info vars
}
t1
} {a}
|
|
|
|
|
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
|
return [info vars x*]
}
lsort [t1 18 19]
} {xxa xxx1 xxx2}
test info-19.3 {info vars option} {
lsort [info vars]
} [lsort [info globals]]
test info-19.4 {info vars option} -returnCodes error -body {
info vars a b
} -result {wrong # args: should be "info vars ?pattern?"}
test info-19.5 {info vars with temporary variables} {
proc t1 {} {
foreach a {b c} {}
info vars
}
t1
} {a}
|
| ︙ | | | ︙ | |
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
|
test info-20.2 {info functions option} {lsort [info functions]} $functions
test info-20.3 {info functions option} {
lsort [info functions a*]
} {abs acos asin atan atan2}
test info-20.4 {info functions option} {
lsort [info functions *tan*]
} {atan atan2 tan tanh}
test info-20.5 {info functions option} {
list [catch {info functions raise an error} msg] $msg
} {1 {wrong # args: should be "info functions ?pattern?"}}
test info-21.1 {miscellaneous error conditions} {
list [catch {info} msg] $msg
} {1 {wrong # args: should be "info option ?arg arg ...?"}}
test info-21.2 {miscellaneous error conditions} {
list [catch {info gorp} msg] $msg
} {1 {bad option "gorp": must be args, body, cmdcount, commands, complete, default, exists, frame, functions, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}}
test info-21.3 {miscellaneous error conditions} {
list [catch {info c} msg] $msg
} {1 {ambiguous option "c": must be args, body, cmdcount, commands, complete, default, exists, frame, functions, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}}
test info-21.4 {miscellaneous error conditions} {
list [catch {info l} msg] $msg
} {1 {ambiguous option "l": must be args, body, cmdcount, commands, complete, default, exists, frame, functions, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}}
test info-21.5 {miscellaneous error conditions} {
list [catch {info s} msg] $msg
} {1 {ambiguous option "s": must be args, body, cmdcount, commands, complete, default, exists, frame, functions, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}}
##
# ### ### ### ######### ######### #########
## info frame
## Helper
# For the more complex results we cut the file name down to remove
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
|
test info-20.2 {info functions option} {lsort [info functions]} $functions
test info-20.3 {info functions option} {
lsort [info functions a*]
} {abs acos asin atan atan2}
test info-20.4 {info functions option} {
lsort [info functions *tan*]
} {atan atan2 tan tanh}
test info-20.5 {info functions option} -returnCodes error -body {
info functions raise an error
} -result {wrong # args: should be "info functions ?pattern?"}
test info-21.1 {miscellaneous error conditions} -returnCodes error -body {
info
} -result {wrong # args: should be "info subcommand ?argument ...?"}
test info-21.2 {miscellaneous error conditions} -returnCodes error -body {
info gorp
} -result {unknown or ambiguous subcommand "gorp": must be args, body, cmdcount, commands, complete, default, exists, frame, functions, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}
test info-21.3 {miscellaneous error conditions} -returnCodes error -body {
info c
} -result {unknown or ambiguous subcommand "c": must be args, body, cmdcount, commands, complete, default, exists, frame, functions, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}
test info-21.4 {miscellaneous error conditions} -returnCodes error -body {
info l
} -result {unknown or ambiguous subcommand "l": must be args, body, cmdcount, commands, complete, default, exists, frame, functions, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}
test info-21.5 {miscellaneous error conditions} -returnCodes error -body {
info s
} -result {unknown or ambiguous subcommand "s": must be args, body, cmdcount, commands, complete, default, exists, frame, functions, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}
##
# ### ### ### ######### ######### #########
## info frame
## Helper
# For the more complex results we cut the file name down to remove
|
| ︙ | | | ︙ | |
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
|
}
##
test info-22.0 {info frame, levels} {!singleTestInterp} {
info frame
} 7
test info-22.1 {info frame, bad level relative} {!singleTestInterp} {
# catch is another level!, i.e. we have 8, not 7
catch {info frame -8} msg
set msg
} {bad level "-8"}
test info-22.2 {info frame, bad level absolute} {!singleTestInterp} {
# catch is another level!, i.e. we have 8, not 7
catch {info frame 9} msg
set msg
} {bad level "9"}
test info-22.3 {info frame, current, relative} {
info frame 0
} {type eval line 2 cmd {info frame 0}}
test info-22.4 {info frame, current, relative, nested} {
set res [info frame 0]
} {type eval line 2 cmd {info frame 0}}
test info-22.5 {info frame, current, absolute} {!singleTestInterp} {
reduce [info frame 7]
} {type eval line 2 cmd {info frame 7}}
test info-22.6 {info frame, global, relative} {!singleTestInterp} {
reduce [info frame -6]
} {type source line 755 file info.test cmd test\ info-22.6\ \{info\ frame,\ global,\ relative\}\ \{!singleTestInter level 0}
test info-22.7 {info frame, global, absolute} {!singleTestInterp} {
reduce [info frame 1]
} {type source line 759 file info.test cmd test\ info-22.7\ \{info\ frame,\ global,\ absolute\}\ \{!singleTestInter level 0}
test info-22.8 {info frame, basic trace} {!singleTestInterp} {
join [etrace] \n
} {8 {type source line 719 file info.test cmd {info frame $level} proc ::etrace level 0}
7 {type eval line 2 cmd etrace}
6 {type source line 2299 file tcltest.tcl cmd {uplevel 1 $script} proc ::tcltest::RunTest}
5 {type eval line 1 cmd {::tcltest::RunTest info-22}}
4 {type source line 1621 file tcltest.tcl cmd {uplevel 1 $script} proc ::tcltest::Eval}
3 {type eval line 1 cmd ::tcltest::Eval\ \{::tcltest::RunTest\ info-22}
2 {type source line 1967 file tcltest.tcl cmd {uplevel 1 [list [namespace origin Eval] $command 1]} proc ::tcltest::test}
1 {type source line 763 file info.test cmd test\ info-22.8\ \{info\ frame,\ basic\ trace\}\ \{!singleTestInter level 1}}
## The line 1967 is off by 5 from the true value of 1972. This is a knownBug, see testcase 30.0
test info-23.0 {eval'd info frame} {!singleTestInterp} {
eval {info frame}
} 8
test info-23.1 {eval'd info frame, semi-dynamic} {!singleTestInterp} {
eval info frame
} 8
test info-23.2 {eval'd info frame, dynamic} {!singleTestInterp} {
set script {info frame}
eval $script
} 8
test info-23.3 {eval'd info frame, literal} {
eval {
info frame 0
}
} {type eval line 2 cmd {info frame 0}}
test info-23.4 {eval'd info frame, semi-dynamic} {
eval info frame 0
} {type eval line 1 cmd {info frame 0}}
test info-23.5 {eval'd info frame, dynamic} {
set script {info frame 0}
eval $script
} {type eval line 1 cmd {info frame 0}}
test info-23.6 {eval'd info frame, trace} {!singleTestInterp} {
set script {etrace}
join [eval $script] \n
} {9 {type source line 719 file info.test cmd {info frame $level} proc ::etrace level 0}
8 {type eval line 1 cmd etrace}
7 {type eval line 3 cmd {eval $script}}
6 {type source line 2299 file tcltest.tcl cmd {uplevel 1 $script} proc ::tcltest::RunTest}
5 {type eval line 1 cmd {::tcltest::RunTest info-23}}
4 {type source line 1621 file tcltest.tcl cmd {uplevel 1 $script} proc ::tcltest::Eval}
3 {type eval line 1 cmd ::tcltest::Eval\ \{::tcltest::RunTest\ info-23}
2 {type source line 1967 file tcltest.tcl cmd {uplevel 1 [list [namespace origin Eval] $command 1]} proc ::tcltest::test}
1 {type source line 802 file info.test cmd test\ info-23.6\ \{eval'd\ info\ frame,\ trace\}\ \{!singleTestInter level 1}}
## The line 1967 is off by 5 from the true value of 1972. This is a knownBug, see testcase 30.0
# -------------------------------------------------------------------------
# Procedures defined in scripts which are arguments to control
# structures (like 'namespace eval', 'interp eval', 'if', 'while',
# 'switch', 'catch', 'for', 'foreach', etc.) have no absolute
# location. The command implementations execute such scripts through
# Tcl_EvalObjEx. Flag 0 causes it to use the bytecode compiler. This
# causes the connection to the context to be lost. Currently only
# procedure bodies are able to remember their context.
# -------------------------------------------------------------------------
namespace eval foo {
proc bar {} {info frame 0}
}
test info-24.0 {info frame, interaction, namespace eval} {
reduce [foo::bar]
} {type source line 828 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
set flag 1
if {$flag} {
namespace eval foo {}
proc ::foo::bar {} {info frame 0}
}
test info-24.1 {info frame, interaction, if} {
reduce [foo::bar]
} {type source line 842 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
set flag 1
while {$flag} {
namespace eval foo {}
proc ::foo::bar {} {info frame 0}
set flag 0
}
test info-24.2 {info frame, interaction, while} {
reduce [foo::bar]
} {type source line 856 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
catch {
namespace eval foo {}
proc ::foo::bar {} {info frame 0}
}
test info-24.3 {info frame, interaction, catch} {
reduce [foo::bar]
} {type source line 870 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
foreach var val {
namespace eval foo {}
proc ::foo::bar {} {info frame 0}
break
}
test info-24.4 {info frame, interaction, foreach} {
reduce [foo::bar]
} {type source line 883 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
for {} {1} {} {
namespace eval foo {}
proc ::foo::bar {} {info frame 0}
break
}
test info-24.5 {info frame, interaction, for} {
reduce [foo::bar]
} {type source line 897 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
eval {
proc bar {} {info frame 0}
}
test info-25.0 {info frame, proc in eval} {
reduce [bar]
} {type source line 910 file info.test cmd {info frame 0} proc ::bar level 0}
proc bar {} {info frame 0}
test info-25.1 {info frame, regular proc} {
reduce [bar]
} {type source line 917 file info.test cmd {info frame 0} proc ::bar level 0}
rename bar {}
# -------------------------------------------------------------------------
test info-30.0 {bs+nl in literal words} knownBug {
if {1} {
set res \
|
<
<
<
<
<
<
|
<
|
<
|
|
>
<
<
<
<
<
<
|
|
>
>
|
<
|
|
>
|
<
|
|
>
|
<
|
|
>
|
<
|
|
>
|
<
|
|
>
|
<
|
|
>
|
>
>
|
>
|
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
|
}
##
test info-22.0 {info frame, levels} {!singleTestInterp} {
info frame
} 7
test info-22.1 {info frame, bad level relative} {!singleTestInterp} {
# catch is another level!, i.e. we have 8, not 7
catch {info frame -8} msg
set msg
} {bad level "-8"}
test info-22.2 {info frame, bad level absolute} {!singleTestInterp} {
# catch is another level!, i.e. we have 8, not 7
catch {info frame 9} msg
set msg
} {bad level "9"}
test info-22.3 {info frame, current, relative} {
info frame 0
} {type eval line 2 cmd {info frame 0}}
test info-22.4 {info frame, current, relative, nested} {
set res [info frame 0]
} {type eval line 2 cmd {info frame 0}}
test info-22.5 {info frame, current, absolute} {!singleTestInterp} {
reduce [info frame 7]
} {type eval line 2 cmd {info frame 7}}
test info-22.6 {info frame, global, relative} {!singleTestInterp} {
reduce [info frame -6]
} {type source line 758 file info.test cmd test\ info-22.6\ \{info\ frame,\ global,\ relative\}\ \{!singleTestInter level 0}
test info-22.7 {info frame, global, absolute} {!singleTestInterp} {
reduce [info frame 1]
} {type source line 761 file info.test cmd test\ info-22.7\ \{info\ frame,\ global,\ absolute\}\ \{!singleTestInter level 0}
test info-22.8 {info frame, basic trace} {!singleTestInterp} {
join [etrace] \n
} {8 {type source line 728 file info.test cmd {info frame $level} proc ::etrace level 0}
7 {type eval line 2 cmd etrace}
6 {type source line 2299 file tcltest.tcl cmd {uplevel 1 $script} proc ::tcltest::RunTest}
5 {type eval line 1 cmd {::tcltest::RunTest info-22}}
4 {type source line 1621 file tcltest.tcl cmd {uplevel 1 $script} proc ::tcltest::Eval}
3 {type eval line 1 cmd ::tcltest::Eval\ \{::tcltest::RunTest\ info-22}
2 {type source line 1967 file tcltest.tcl cmd {uplevel 1 [list [namespace origin Eval] $command 1]} proc ::tcltest::test}
1 {type source line 764 file info.test cmd test\ info-22.8\ \{info\ frame,\ basic\ trace\}\ \{!singleTestInter level 1}}
## The line 1967 is off by 5 from the true value of 1972. This is a knownBug, see testcase 30.0
test info-23.0 {eval'd info frame} {!singleTestInterp} {
eval {info frame}
} 8
test info-23.1 {eval'd info frame, semi-dynamic} {!singleTestInterp} {
eval info frame
} 8
test info-23.2 {eval'd info frame, dynamic} {!singleTestInterp} {
set script {info frame}
eval $script
} 8
test info-23.3 {eval'd info frame, literal} {
eval {
info frame 0
}
} {type eval line 2 cmd {info frame 0}}
test info-23.4 {eval'd info frame, semi-dynamic} {
eval info frame 0
} {type eval line 1 cmd {info frame 0}}
test info-23.5 {eval'd info frame, dynamic} {
set script {info frame 0}
eval $script
} {type eval line 1 cmd {info frame 0}}
test info-23.6 {eval'd info frame, trace} {!singleTestInterp} {
set script {etrace}
join [eval $script] \n
} {9 {type source line 728 file info.test cmd {info frame $level} proc ::etrace level 0}
8 {type eval line 1 cmd etrace}
7 {type eval line 3 cmd {eval $script}}
6 {type source line 2299 file tcltest.tcl cmd {uplevel 1 $script} proc ::tcltest::RunTest}
5 {type eval line 1 cmd {::tcltest::RunTest info-23}}
4 {type source line 1621 file tcltest.tcl cmd {uplevel 1 $script} proc ::tcltest::Eval}
3 {type eval line 1 cmd ::tcltest::Eval\ \{::tcltest::RunTest\ info-23}
2 {type source line 1967 file tcltest.tcl cmd {uplevel 1 [list [namespace origin Eval] $command 1]} proc ::tcltest::test}
1 {type source line 798 file info.test cmd test\ info-23.6\ \{eval'd\ info\ frame,\ trace\}\ \{!singleTestInter level 1}}
## The line 1967 is off by 5 from the true value of 1972. This is a knownBug, see testcase 30.0
# -------------------------------------------------------------------------
# Procedures defined in scripts which are arguments to control
# structures (like 'namespace eval', 'interp eval', 'if', 'while',
# 'switch', 'catch', 'for', 'foreach', etc.) have no absolute
# location. The command implementations execute such scripts through
# Tcl_EvalObjEx. Flag 0 causes it to use the bytecode compiler. This
# causes the connection to the context to be lost. Currently only
# procedure bodies are able to remember their context.
# NOTE THAT THESE DO NOT USE THE -setup OPTION TO [test]
# -------------------------------------------------------------------------
namespace eval foo {
proc bar {} {info frame 0}
}
test info-24.0 {info frame, interaction, namespace eval} -body {
reduce [foo::bar]
} -cleanup {
namespace delete foo
} -result {type source line 826 file info.test cmd {info frame 0} proc ::foo::bar level 0}
# -------------------------------------------------------------------------
set flag 1
if {$flag} {
namespace eval foo {}
proc ::foo::bar {} {info frame 0}
}
test info-24.1 {info frame, interaction, if} -body {
reduce [foo::bar]
} -cleanup {
namespace delete foo
} -result {type source line 840 file info.test cmd {info frame 0} proc ::foo::bar level 0}
# -------------------------------------------------------------------------
set flag 1
while {$flag} {
namespace eval foo {}
proc ::foo::bar {} {info frame 0}
set flag 0
}
test info-24.2 {info frame, interaction, while} -body {
reduce [foo::bar]
} -cleanup {
namespace delete foo
} -result {type source line 854 file info.test cmd {info frame 0} proc ::foo::bar level 0}
# -------------------------------------------------------------------------
catch {
namespace eval foo {}
proc ::foo::bar {} {info frame 0}
}
test info-24.3 {info frame, interaction, catch} -body {
reduce [foo::bar]
} -cleanup {
namespace delete foo
} -result {type source line 868 file info.test cmd {info frame 0} proc ::foo::bar level 0}
# -------------------------------------------------------------------------
foreach var val {
namespace eval foo {}
proc ::foo::bar {} {info frame 0}
break
}
test info-24.4 {info frame, interaction, foreach} -body {
reduce [foo::bar]
} -cleanup {
namespace delete foo
} -result {type source line 881 file info.test cmd {info frame 0} proc ::foo::bar level 0}
# -------------------------------------------------------------------------
for {} {1} {} {
namespace eval foo {}
proc ::foo::bar {} {info frame 0}
break
}
test info-24.5 {info frame, interaction, for} -body {
reduce [foo::bar]
} -cleanup {
namespace delete foo
} -result {type source line 895 file info.test cmd {info frame 0} proc ::foo::bar level 0}
# -------------------------------------------------------------------------
eval {
proc bar {} {info frame 0}
}
test info-25.0 {info frame, proc in eval} {
reduce [bar]
} {type source line 908 file info.test cmd {info frame 0} proc ::bar level 0}
# Don't need to clean up yet...
proc bar {} {info frame 0}
test info-25.1 {info frame, regular proc} {
reduce [bar]
} {type source line 916 file info.test cmd {info frame 0} proc ::bar level 0}
rename bar {}
# -------------------------------------------------------------------------
test info-30.0 {bs+nl in literal words} knownBug {
if {1} {
set res \
|
| ︙ | | | ︙ | |
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
|
set x foo
switch -exact -- $x {
foo {
proc ::foo::bar {} {info frame 0}
}
}
test info-24.6.0 {info frame, interaction, switch, list body} {
reduce [foo::bar]
} {type source line 992 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
unset x
# -------------------------------------------------------------------------
namespace eval foo {}
set x foo
switch -exact -- $x foo {
proc ::foo::bar {} {info frame 0}
}
test info-24.6.1 {info frame, interaction, switch, multi-body} {
reduce [foo::bar]
} {type source line 1008 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
unset x
# -------------------------------------------------------------------------
namespace eval foo {}
set x foo
switch -exact -- $x [list foo {
proc ::foo::bar {} {info frame 0}
}]
test info-24.6.2 {info frame, interaction, switch, list body, dynamic} {
reduce [foo::bar]
} {type proc line 1 cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
unset x
# -------------------------------------------------------------------------
set body {
foo {
proc ::foo::bar {} {info frame 0}
}
}
namespace eval foo {}
set x foo
switch -exact -- $x $body
test info-31.7 {info frame, interaction, switch, dynamic} {
reduce [foo::bar]
} {type proc line 1 cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
unset x
# -------------------------------------------------------------------------
set body {
proc ::foo::bar {} {info frame 0}
}
namespace eval foo {}
eval $body
test info-32.0 {info frame, dynamic procedure} {
reduce [foo::bar]
} {type proc line 1 cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
namespace {*}{
eval
foo
{proc bar {} {info frame 0}}
}
test info-33.0 {{*}, literal, direct} {
reduce [foo::bar]
} {type source line 1072 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
namespace eval foo {}
proc foo::bar {} {
set flag 1
if {*}{
{$flag}
{info frame 0}
}
}
test info-33.1 {{*}, literal, simple, bytecompiled} {
reduce [foo::bar]
} {type source line 1087 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
set body {
eval
foo
{proc bar {} {
|
|
<
|
|
|
>
|
<
|
|
|
>
|
<
|
|
|
>
|
<
|
|
|
>
|
<
|
|
>
|
<
|
|
>
|
<
|
|
>
|
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
|
set x foo
switch -exact -- $x {
foo {
proc ::foo::bar {} {info frame 0}
}
}
test info-24.6.0 {info frame, interaction, switch, list body} -body {
reduce [foo::bar]
} -cleanup {
namespace delete foo
unset x
} -result {type source line 993 file info.test cmd {info frame 0} proc ::foo::bar level 0}
# -------------------------------------------------------------------------
namespace eval foo {}
set x foo
switch -exact -- $x foo {
proc ::foo::bar {} {info frame 0}
}
test info-24.6.1 {info frame, interaction, switch, multi-body} -body {
reduce [foo::bar]
} -cleanup {
namespace delete foo
unset x
} -result {type source line 1009 file info.test cmd {info frame 0} proc ::foo::bar level 0}
# -------------------------------------------------------------------------
namespace eval foo {}
set x foo
switch -exact -- $x [list foo {
proc ::foo::bar {} {info frame 0}
}]
test info-24.6.2 {info frame, interaction, switch, list body, dynamic} -body {
reduce [foo::bar]
} -cleanup {
namespace delete foo
unset x
} -result {type proc line 1 cmd {info frame 0} proc ::foo::bar level 0}
# -------------------------------------------------------------------------
set body {
foo {
proc ::foo::bar {} {info frame 0}
}
}
namespace eval foo {}
set x foo
switch -exact -- $x $body
test info-31.7 {info frame, interaction, switch, dynamic} -body {
reduce [foo::bar]
} -cleanup {
namespace delete foo
unset x
} -result {type proc line 1 cmd {info frame 0} proc ::foo::bar level 0}
# -------------------------------------------------------------------------
set body {
proc ::foo::bar {} {info frame 0}
}
namespace eval foo {}
eval $body
test info-32.0 {info frame, dynamic procedure} -body {
reduce [foo::bar]
} -cleanup {
namespace delete foo
} -result {type proc line 1 cmd {info frame 0} proc ::foo::bar level 0}
# -------------------------------------------------------------------------
namespace {*}{
eval
foo
{proc bar {} {info frame 0}}
}
test info-33.0 {{*}, literal, direct} -body {
reduce [foo::bar]
} -cleanup {
namespace delete foo
} -result {type source line 1073 file info.test cmd {info frame 0} proc ::foo::bar level 0}
# -------------------------------------------------------------------------
namespace eval foo {}
proc foo::bar {} {
set flag 1
if {*}{
{$flag}
{info frame 0}
}
}
test info-33.1 {{*}, literal, simple, bytecompiled} -body {
reduce [foo::bar]
} -cleanup {
namespace delete foo
} -result {type source line 1088 file info.test cmd {info frame 0} proc ::foo::bar level 0}
# -------------------------------------------------------------------------
set body {
eval
foo
{proc bar {} {
|
| ︙ | | | ︙ | |
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
|
apply {
{x y}
{info frame 0}
} 0 0
}
test info-35.0 {apply, literal} {
reduce [foo]
} {type source line 1136 file info.test cmd {info frame 0} lambda {
{x y}
{info frame 0}
} level 0}
rename foo {}
set lambda {
{x y}
|
|
|
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
|
apply {
{x y}
{info frame 0}
} 0 0
}
test info-35.0 {apply, literal} {
reduce [foo]
} {type source line 1137 file info.test cmd {info frame 0} lambda {
{x y}
{info frame 0}
} level 0}
rename foo {}
set lambda {
{x y}
|
| ︙ | | | ︙ | |
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
|
namespace eval foo {}
dict for {k v} {foo bar} {
proc ::foo::bar {} {info frame 0}
}
test info-24.7 {info frame, interaction, dict for} {
reduce [foo::bar]
} {type source line 1163 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
namespace eval foo {}
set thedict {foo bar}
dict with thedict {
proc ::foo::bar {} {info frame 0}
}
test info-24.8 {info frame, interaction, dict with} {
reduce [foo::bar]
} {type source line 1177 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
unset thedict
# -------------------------------------------------------------------------
namespace eval foo {}
dict filter {foo bar} script {k v} {
proc ::foo::bar {} {info frame 0}
set x 1
}
test info-24.9 {info frame, interaction, dict filter} {
reduce [foo::bar]
} {type source line 1191 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
unset x
# -------------------------------------------------------------------------
namespace eval foo {}
proc foo::bar {} {
dict for {k v} {foo bar} {
set x [info frame 0]
}
set x
}
test info-36.0 {info frame, dict for, bcc} {
reduce [foo::bar]
} {type source line 1207 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
namespace eval foo {}
proc foo::bar {} {
set x foo
switch -exact -- $x {
foo {set y [info frame 0]}
}
set y
}
test info-36.1.0 {switch, list literal, bcc} {
reduce [foo::bar]
} {type source line 1223 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
namespace eval foo {}
proc foo::bar {} {
set x foo
switch -exact -- $x foo {set y [info frame 0]}
set y
}
test info-36.1.1 {switch, multi-body literals, bcc} {
reduce [foo::bar]
} {type source line 1239 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
namespace {*}"
eval
foo
{proc bar {} {info frame 0}}
"
test info-33.2 {{*}, literal, direct} {
reduce [foo::bar]
} {type source line 1254 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
namespace {*}"eval\nfoo\n{proc bar {} {info frame 0}}\n"
|
|
|
|
|
|
|
|
|
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
|
namespace eval foo {}
dict for {k v} {foo bar} {
proc ::foo::bar {} {info frame 0}
}
test info-24.7 {info frame, interaction, dict for} {
reduce [foo::bar]
} {type source line 1164 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
namespace eval foo {}
set thedict {foo bar}
dict with thedict {
proc ::foo::bar {} {info frame 0}
}
test info-24.8 {info frame, interaction, dict with} {
reduce [foo::bar]
} {type source line 1178 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
unset thedict
# -------------------------------------------------------------------------
namespace eval foo {}
dict filter {foo bar} script {k v} {
proc ::foo::bar {} {info frame 0}
set x 1
}
test info-24.9 {info frame, interaction, dict filter} {
reduce [foo::bar]
} {type source line 1192 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
unset x
# -------------------------------------------------------------------------
namespace eval foo {}
proc foo::bar {} {
dict for {k v} {foo bar} {
set x [info frame 0]
}
set x
}
test info-36.0 {info frame, dict for, bcc} {
reduce [foo::bar]
} {type source line 1208 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
namespace eval foo {}
proc foo::bar {} {
set x foo
switch -exact -- $x {
foo {set y [info frame 0]}
}
set y
}
test info-36.1.0 {switch, list literal, bcc} {
reduce [foo::bar]
} {type source line 1224 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
namespace eval foo {}
proc foo::bar {} {
set x foo
switch -exact -- $x foo {set y [info frame 0]}
set y
}
test info-36.1.1 {switch, multi-body literals, bcc} {
reduce [foo::bar]
} {type source line 1240 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
namespace {*}"
eval
foo
{proc bar {} {info frame 0}}
"
test info-33.2 {{*}, literal, direct} {
reduce [foo::bar]
} {type source line 1255 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
namespace {*}"eval\nfoo\n{proc bar {} {info frame 0}}\n"
|
| ︙ | | | ︙ | |
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
|
if {*}"
{1}
{info frame 0}
"
}
test info-33.3 {{*}, literal, simple, bytecompiled} {
reduce [foo::bar]
} {type source line 1279 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
namespace eval foo {}
proc foo::bar {} {
|
|
|
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
|
if {*}"
{1}
{info frame 0}
"
}
test info-33.3 {{*}, literal, simple, bytecompiled} {
reduce [foo::bar]
} {type source line 1280 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
namespace eval foo {}
proc foo::bar {} {
|
| ︙ | | | ︙ | |