| ︙ | | |
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
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.56 2008/07/25 22:11:21 andreas_kupries Exp $
# RCS: @(#) $Id: info.test,v 1.57 2008/07/25 23:06:21 andreas_kupries 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",
|
| ︙ | | |
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
|
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
|
-
+
+
+
+
-
+
+
+
+
-
+
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
|
test info-22.8 {info frame, basic trace} -match glob -body {
join [lrange [etrace] 0 2] \n
} -result {* {type source line 728 file info.test cmd {info frame $level} proc ::etrace level 0}
* {type source line 765 file info.test cmd etrace proc ::tcltest::RunTest}
* {type source line * file tcltest.tcl cmd {uplevel 1 $script} proc ::tcltest::RunTest}}
## 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} {
test info-23.0.0 {eval'd info frame} {!singleTestInterp} {
eval {info frame}
} 8
test info-23.0.1 {eval'd info frame} -constraints {singleTestInterp} -match glob -body {
eval {info frame}
} -result {1[12]} ;# SingleTestInterp results changes depending on running the whole suite, or info.test alone.
test info-23.1 {eval'd info frame, semi-dynamic} {!singleTestInterp} {
test info-23.1.0 {eval'd info frame, semi-dynamic} {!singleTestInterp} {
eval info frame
} 8
test info-23.1.1 {eval'd info frame, semi-dynamic} -constraints {singleTestInterp} -match glob -body {
eval info frame
} -result {1[12]}
test info-23.2 {eval'd info frame, dynamic} {!singleTestInterp} {
test info-23.2.0 {eval'd info frame, dynamic} {!singleTestInterp} {
set script {info frame}
eval $script
} 8
test info-23.2.1 {eval'd info frame, dynamic} -constraints {singleTestInterp} -match glob -body {
set script {info frame}
eval $script
} -result {1[12]}
test info-23.3 {eval'd info frame, literal} {
eval {
info frame 0
}
} {type eval line 2 cmd {info frame 0} proc ::tcltest::RunTest}
test info-23.4 {eval'd info frame, semi-dynamic} {
eval info frame 0
} {type eval line 1 cmd {info frame 0} proc ::tcltest::RunTest}
test info-23.5 {eval'd info frame, dynamic} {
set script {info frame 0}
eval $script
} {type eval line 1 cmd {info frame 0} proc ::tcltest::RunTest}
test info-23.6 {eval'd info frame, trace} -constraints {!singleTestInterp} -match glob -body {
test info-23.6 {eval'd info frame, trace} -match glob -body {
set script {etrace}
join [eval $script] \n
} -result {9 {type source line 728 file info.test cmd {info frame $level} proc ::etrace level 0}
8 {type eval line 1 cmd etrace proc ::tcltest::RunTest}
7 {type source line 800 file info.test cmd {eval $script} proc ::tcltest::RunTest}
join [lrange [eval $script] 0 2] \n
} -result {* {type source line 728 file info.test cmd {info frame $level} proc ::etrace level 0}
* {type eval line 1 cmd etrace proc ::tcltest::RunTest}
* {type source line 805 file info.test cmd {eval $script} proc ::tcltest::RunTest}}
6 {type source line * file tcltest.tcl cmd {uplevel 1 $script} proc ::tcltest::RunTest}
5 {type eval line 1 cmd {::tcltest::RunTest info-23} proc ::tcltest::Eval}
4 {type source line * file tcltest.tcl cmd {uplevel 1 $script} proc ::tcltest::Eval}
3 {type eval line 1 cmd ::tcltest::Eval\\ \\\{::tcltest::RunTest\\ info-23 proc ::tcltest::test}
2 {type source line * 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} -constraints {!singleTestInterp} -match glob -bo} 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
|
| ︙ | | |
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
929
930
931
932
933
934
935
936
937
|
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
929
930
931
932
933
934
935
936
937
938
939
940
941
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
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}
} -result {type source line 825 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}
} -result {type source line 839 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}
} -result {type source line 853 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}
} -result {type source line 867 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}
} -result {type source line 880 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}
} -result {type source line 894 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.0 {info frame, interaction, switch, list body} -body {
reduce [foo::bar]
} -cleanup {
namespace delete foo
unset x
} -result {type source line 911 file info.test cmd {info frame 0} proc ::foo::bar level 0}
} -result {type source line 910 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 927 file info.test cmd {info frame 0} proc ::foo::bar level 0}
} -result {type source line 926 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}
|
| ︙ | | |
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
|
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
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
|
-
+
-
+
-
+
-
+
-
+
|
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 956 file info.test cmd {info frame 0} proc ::foo::bar level 0}
} {type source line 955 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 970 file info.test cmd {info frame 0} proc ::foo::bar level 0}
} {type source line 969 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 984 file info.test cmd {info frame 0} proc ::foo::bar level 0}
} {type source line 983 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
unset x
# -------------------------------------------------------------------------
eval {
proc bar {} {info frame 0}
}
test info-25.0 {info frame, proc in eval} {
reduce [bar]
} {type source line 998 file info.test cmd {info frame 0} proc ::bar level 0}
} {type source line 997 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 1006 file info.test cmd {info frame 0} proc ::bar level 0}
} {type source line 1005 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} {
|
| ︙ | | |
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
|
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
|
-
+
-
+
-
+
|
foo
{proc bar {} {info frame 0}}
}
test info-33.0 {{*}, literal, direct} -body {
reduce [foo::bar]
} -cleanup {
namespace delete foo
} -result {type source line 1116 file info.test cmd {info frame 0} proc ::foo::bar level 0}
} -result {type source line 1115 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 1131 file info.test cmd {info frame 0} proc ::foo::bar level 0}
} -result {type source line 1130 file info.test cmd {info frame 0} proc ::foo::bar level 0}
# -------------------------------------------------------------------------
namespace {*}"
eval
foo
{proc bar {} {info frame 0}}
"
test info-33.2 {{*}, literal, direct} {
reduce [foo::bar]
} {type source line 1145 file info.test cmd {info frame 0} proc ::foo::bar level 0}
} {type source line 1144 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"
|
| ︙ | | |
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
|
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
|
-
+
|
if {*}"
{1}
{info frame 0}
"
}
test info-33.3 {{*}, literal, simple, bytecompiled} {
reduce [foo::bar]
} {type source line 1170 file info.test cmd {info frame 0} proc ::foo::bar level 0}
} {type source line 1169 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
namespace eval foo {}
proc foo::bar {} {
|
| ︙ | | |
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
|
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
|
-
+
|
apply {
{x y}
{info frame 0}
} 0 0
}
test info-35.0 {apply, literal} {
reduce [foo]
} {type source line 1232 file info.test cmd {info frame 0} lambda {
} {type source line 1231 file info.test cmd {info frame 0} lambda {
{x y}
{info frame 0}
} level 0}
rename foo {}
set lambda {
{x y}
|
| ︙ | | |
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
|
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
|
-
+
-
+
-
+
|
dict for {k v} {foo bar} {
set x [info frame 0]
}
set x
}
test info-36.0 {info frame, dict for, bcc} -body {
reduce [foo::bar]
} -result {type source line 1260 file info.test cmd {info frame 0} proc ::foo::bar level 0}
} -result {type source line 1259 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} -body {
reduce [foo::bar]
} -result {type source line 1276 file info.test cmd {info frame 0} proc ::foo::bar level 0}
} -result {type source line 1275 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} -body {
reduce [foo::bar]
} -result {type source line 1292 file info.test cmd {info frame 0} proc ::foo::bar level 0}
} -result {type source line 1291 file info.test cmd {info frame 0} proc ::foo::bar level 0}
namespace delete foo
# -------------------------------------------------------------------------
test info-37.0 {eval pure list, single line} -match glob -body {
# Basically, counting the newline in the word seen through $foo
|
| ︙ | | |
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
|
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
|
-
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
|
set script {
set y DV.
etrace
}
join [lrange [uplevel \#0 $script] 0 2] \n
} -result {* {type source line 728 file info.test cmd {info frame $level} proc ::etrace level 0}
* {type eval line 3 cmd etrace proc ::tcltest::RunTest}
* {type source line 1362 file info.test cmd {uplevel \\#0 $script} proc ::tcltest::RunTest}}
* {type source line 1361 file info.test cmd {uplevel \\#0 $script} proc ::tcltest::RunTest}}
test info-38.2 {location information for uplevel, dl, direct-literal} -match glob -body {
join [lrange [uplevel \#0 {
set y DL.
etrace
}] 0 2] \n
} -result {* {type source line 728 file info.test cmd {info frame $level} proc ::etrace level 0}
* {type source line 1370 file info.test cmd etrace proc ::tcltest::RunTest}
* {type source line 1368 file info.test cmd uplevel\\ \\\\ proc ::tcltest::RunTest}}
* {type source line 1369 file info.test cmd etrace proc ::tcltest::RunTest}
* {type source line 1367 file info.test cmd uplevel\\ \\\\ proc ::tcltest::RunTest}}
test info-38.3 {location information for uplevel, dpv, direct-proc-var} -match glob -body {
set script {
set y DPV
etrace
}
join [lrange [control y $script] 0 3] \n
} -result {* {type source line 728 file info.test cmd {info frame $level} proc ::etrace level 0}
* {type eval line 3 cmd etrace proc ::control}
* {type source line 1339 file info.test cmd {uplevel 1 $script} proc ::control}
* {type source line 1381 file info.test cmd {control y $script} proc ::tcltest::RunTest}}
* {type source line 1338 file info.test cmd {uplevel 1 $script} proc ::control}
* {type source line 1380 file info.test cmd {control y $script} proc ::tcltest::RunTest}}
test info-38.4 {location information for uplevel, dpv, direct-proc-literal} -match glob -body {
join [lrange [control y {
set y DPL
etrace
}] 0 3] \n
} -result {* {type source line 728 file info.test cmd {info frame $level} proc ::etrace level 0}
* {type source line 1390 file info.test cmd etrace proc ::control}
* {type source line 1339 file info.test cmd {uplevel 1 $script} proc ::control}
* {type source line 1388 file info.test cmd control proc ::tcltest::RunTest}}
* {type source line 1389 file info.test cmd etrace proc ::control}
* {type source line 1338 file info.test cmd {uplevel 1 $script} proc ::control}
* {type source line 1387 file info.test cmd control proc ::tcltest::RunTest}}
test info-38.5 {location information for uplevel, ppv, proc-proc-var} -match glob -body {
join [lrange [datav] 0 4] \n
} -result {* {type source line 728 file info.test cmd {info frame $level} proc ::etrace level 0}
* {type eval line 3 cmd etrace proc ::control}
* {type source line 1339 file info.test cmd {uplevel 1 $script} proc ::control}
* {type source line 1354 file info.test cmd {control y $script} proc ::datav level 1}
* {type source line 1398 file info.test cmd datav proc ::tcltest::RunTest}}
* {type source line 1338 file info.test cmd {uplevel 1 $script} proc ::control}
* {type source line 1353 file info.test cmd {control y $script} proc ::datav level 1}
* {type source line 1397 file info.test cmd datav proc ::tcltest::RunTest}}
test info-38.6 {location information for uplevel, ppl, proc-proc-literal} -match glob -body {
join [lrange [datal] 0 4] \n
} -result {* {type source line 728 file info.test cmd {info frame $level} proc ::etrace level 0}
* {type source line 1345 file info.test cmd etrace proc ::control}
* {type source line 1339 file info.test cmd {uplevel 1 $script} proc ::control}
* {type source line 1343 file info.test cmd control proc ::datal level 1}
* {type source line 1406 file info.test cmd datal proc ::tcltest::RunTest}}
* {type source line 1344 file info.test cmd etrace proc ::control}
* {type source line 1338 file info.test cmd {uplevel 1 $script} proc ::control}
* {type source line 1342 file info.test cmd control proc ::datal level 1}
* {type source line 1405 file info.test cmd datal proc ::tcltest::RunTest}}
# -------------------------------------------------------------------------
# cleanup
catch {namespace delete test_ns_info1 test_ns_info2}
::tcltest::cleanupTests
return
|