diff options
Diffstat (limited to 'tests/info.test')
-rw-r--r-- | tests/info.test | 297 |
1 files changed, 285 insertions, 12 deletions
diff --git a/tests/info.test b/tests/info.test index 53a0e76..65d71bc 100644 --- a/tests/info.test +++ b/tests/info.test @@ -13,7 +13,7 @@ # 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.64 2009/07/14 16:34:09 andreas_kupries Exp $ +# RCS: @(#) $Id: info.test,v 1.65 2009/08/25 21:03:25 andreas_kupries Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -767,7 +767,7 @@ test info-22.8 {info frame, basic trace} -match glob -body { * {type source line 765 file info.test cmd etrace proc ::tcltest::RunTest} * {type source line * file tcltest* 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.0 {eval'd info frame} {!singleTestInterp} { eval {info frame} } 8 @@ -806,7 +806,7 @@ test info-23.6 {eval'd info frame, trace} -match glob -body { } -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}} -## 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 @@ -1011,20 +1011,20 @@ test info-25.1 {info frame, regular proc} { rename bar {} # ------------------------------------------------------------------------- - -test info-30.0 {bs+nl in literal words} knownBug { +# More info-30.x test cases at the end of the file. +test info-30.0 {bs+nl in literal words} { if {1} { set res \ - [reduce [info frame 0]] + [reduce [info frame 0]];#1018 } set res - # This is reporting line 3 instead of the correct 4 because the + # This was reporting line 3 instead of the correct 4 because the # bs+nl combination is subst by the parser before the 'if' - # command, and the the bcc sees the word. To fix record the - # offsets of all bs+nl sequences in literal words, then use the - # information in the bcc to bump line numbers when parsing over - # the location. Also affected: testcases 22.8 and 23.6. -} {type eval line 4 cmd {info frame 0} proc ::tcltest::RunTest} + # command, and the bcc, see the word. Fixed by recording the + # offsets of all bs+nl sequences in literal words, then using the + # information in the bcc and other places to bump line numbers when + # parsing over the location. Also affected: testcases 22.8 and 23.6. +} {type source line 1018 file info.test cmd {info frame 0} proc ::tcltest::RunTest} # ------------------------------------------------------------------------- # See 24.0 - 24.5 for similar situations, using literal scripts. @@ -1436,6 +1436,279 @@ type source line 1427 file info.test cmd {info frame 0} proc ::foo::bar level 0 type source line 1428 file info.test cmd {info frame 0} proc ::foo::bar level 0} # ------------------------------------------------------------------------- +# Additional tests for info-30.*, handling of continuation lines (bs+nl sequences). + +test info-30.1 {bs+nl in literal words, procedure body, compiled} { + proc abra {} { + if {1} \ + { + return \ + [reduce [info frame 0]];# line 1446 + } + } + set res [abra] + rename abra {} + set res +} {type source line 1446 file info.test cmd {info frame 0} proc ::abra level 0} + +test info-30.2 {bs+nl in literal words, namespace script} { + namespace eval xxx { + set res \ + [reduce [info frame 0]];# line 1457 + } + set res +} {type source line 1457 file info.test cmd {info frame 0} level 0} + +test info-30.3 {bs+nl in literal words, namespace multi-word script} { + namespace eval xxx set res \ + [list [reduce [info frame 0]]];# line 1464 + set res +} {type source line 1464 file info.test cmd {info frame 0} proc ::tcltest::RunTest} + +test info-30.4 {bs+nl in literal words, eval script} { + eval { + set ::res \ + [reduce [info frame 0]];# line 1471 + } + set res +} {type source line 1471 file info.test cmd {info frame 0} proc ::tcltest::RunTest} + +test info-30.5 {bs+nl in literal words, eval script, with nested words} { + eval { + if {1} \ + { + set ::res \ + [reduce [info frame 0]];# line 1481 + } + } + set res +} {type source line 1481 file info.test cmd {info frame 0} proc ::tcltest::RunTest} + +test info-30.6 {bs+nl in computed word} { + set res "\ +[reduce [info frame 0]]";# line 1489 +} { type source line 1489 file info.test cmd {info frame 0} proc ::tcltest::RunTest} + +test info-30.7 {bs+nl in computed word, in proc} { + proc abra {} { + return "\ +[reduce [info frame 0]]";# line 1495 + } + set res [abra] + rename abra {} + set res +} { type source line 1495 file info.test cmd {info frame 0} proc ::abra level 0} + +test info-30.8 {bs+nl in computed word, nested eval} { + eval { + set \ + res "\ +[reduce [info frame 0]]";# line 1506 +} +} { type source line 1506 file info.test cmd {info frame 0} proc ::tcltest::RunTest} + +test info-30.9 {bs+nl in computed word, nested eval} { + eval { + set \ + res "\ +[reduce \ + [info frame 0]]";# line 1515 +} +} { type source line 1515 file info.test cmd {info frame 0} proc ::tcltest::RunTest} + +test info-30.10 {bs+nl in computed word, key to array} { + set tmp([set \ + res "\ +[reduce \ + [info frame 0]]"]) x ; #1523 + unset tmp + set res +} { type source line 1523 file info.test cmd {info frame 0} proc ::tcltest::RunTest} + +test info-30.11 {bs+nl in subst arguments, no true counting} { + subst {[set \ + res "\ +[reduce \ + [info frame 0]]"]} +} { type eval line 1 cmd {info frame 0} proc ::tcltest::RunTest} + +test info-30.12 {bs+nl in computed word, nested eval} { + eval { + set \ + res "\ +[set x {}] \ +[reduce \ + [info frame 0]]";# line 1541 +} +} { type source line 1541 file info.test cmd {info frame 0} proc ::tcltest::RunTest} + +test info-30.13 {bs+nl in literal words, uplevel script, with nested words} { + uplevel #0 { + if {1} \ + { + set ::res \ + [reduce [info frame 0]];# line 1550 + } + } + set res +} {type source line 1550 file info.test cmd {info frame 0} proc ::tcltest::RunTest} + +test info-30.14 {bs+nl, literal word, uplevel through proc} { + proc abra {script} { + uplevel 1 $script + } + set res [abra { + return "\ +[reduce [info frame 0]]";# line 1562 + }] + rename abra {} + set res +} { type source line 1562 file info.test cmd {info frame 0} proc ::abra} + +test info-30.15 {bs+nl in literal words, nested proc body, compiled} { + proc a {} { + proc b {} { + if {1} \ + { + return \ + [reduce [info frame 0]];# line 1574 + } + } + } + a ; set res [b] + rename a {} + rename b {} + set res +} {type source line 1574 file info.test cmd {info frame 0} proc ::b level 0} + +test info-30.16 {bs+nl in multi-body switch, compiled} { + proc a {value} { + switch -regexp -- $value \ + ^key { info frame 0; # 1587 } \ + \t### { info frame 0; # 1588 } \ + {[0-9]*} { info frame 0; # 1589 } + } + set res {} + lappend res [reduce [a {key }]] + lappend res [reduce [a {1alpha}]] + set res "\n[join $res \n]" +} { +type source line 1587 file info.test cmd {info frame 0} proc ::a level 0 +type source line 1589 file info.test cmd {info frame 0} proc ::a level 0} + +test info-30.17 {bs+nl in multi-body switch, direct} { + switch -regexp -- {key } \ + ^key { reduce [info frame 0] ;# 1601 } \ + \t### { } \ + {[0-9]*} { } +} {type source line 1601 file info.test cmd {info frame 0} proc ::tcltest::RunTest} + +test info-30.18 {bs+nl, literal word, uplevel through proc, appended, loss of primary tracking data} { + proc abra {script} { + append script "\n# end of script" + uplevel 1 $script + } + set res [abra { + return "\ +[reduce [info frame 0]]";# line 1613, still line of 3 appended script + }] + rename abra {} + set res +} { type eval line 3 cmd {info frame 0} proc ::abra} +# { type source line 1606 file info.test cmd {info frame 0} proc ::abra} + +test info-30.19 {bs+nl in single-body switch, compiled} { + proc a {value} { + switch -regexp -- $value { + ^key { reduce \ + [info frame 0] } + \t { reduce \ + [info frame 0] } + {[0-9]*} { reduce \ + [info frame 0] } + } + } + set res {} + lappend res [a {key }] + lappend res [a {1alpha}] + set res "\n[join $res \n]" +} { +type source line 1624 file info.test cmd {info frame 0} proc ::a level 0 +type source line 1628 file info.test cmd {info frame 0} proc ::a level 0} + +test info-30.20 {bs+nl in single-body switch, direct} { + switch -regexp -- {key } { \ + + ^key { reduce \ + [info frame 0] } + \t### { } + {[0-9]*} { } + } +} {type source line 1643 file info.test cmd {info frame 0} proc ::tcltest::RunTest} + +test info-30.21 {bs+nl in if, full compiled} { + proc a {value} { + if {$value} \ + {info frame 0} \ + {info frame 0} ; # 1653 + } + set res {} + lappend res [reduce [a 1]] + lappend res [reduce [a 0]] + set res "\n[join $res \n]" +} { +type source line 1652 file info.test cmd {info frame 0} proc ::a level 0 +type source line 1653 file info.test cmd {info frame 0} proc ::a level 0} + +test info-30.22 {bs+nl in computed word, key to array, compiled} { + proc a {} { + set tmp([set \ + res "\ +[reduce \ + [info frame 0]]"]) x ; #1668 + unset tmp + set res + } + set res [a] + rename a {} + set res +} { type source line 1668 file info.test cmd {info frame 0} proc ::a level 0} + +test info-30.23 {bs+nl in multi-body switch, full compiled} { + proc a {value} { + switch -exact -- $value \ + key { info frame 0; # 1680 } \ + xxx { info frame 0; # 1681 } \ + 000 { info frame 0; # 1682 } + } + set res {} + lappend res [reduce [a key]] + lappend res [reduce [a 000]] + set res "\n[join $res \n]" +} { +type source line 1680 file info.test cmd {info frame 0} proc ::a level 0 +type source line 1682 file info.test cmd {info frame 0} proc ::a level 0} + +test info-30.24 {bs+nl in single-body switch, full compiled} { + proc a {value} { + switch -exact -- $value { + key { reduce \ + [info frame 0] } + xxx { reduce \ + [info frame 0] } + 000 { reduce \ + [info frame 0] } + } + } + set res {} + lappend res [a key] + lappend res [a 000] + set res "\n[join $res \n]" +} { +type source line 1696 file info.test cmd {info frame 0} proc ::a level 0 +type source line 1700 file info.test cmd {info frame 0} proc ::a level 0} + +# ------------------------------------------------------------------------- # cleanup catch {namespace delete test_ns_info1 test_ns_info2} |