summaryrefslogtreecommitdiff
path: root/tcl/tests/compile.test
diff options
context:
space:
mode:
Diffstat (limited to 'tcl/tests/compile.test')
-rw-r--r--tcl/tests/compile.test65
1 files changed, 51 insertions, 14 deletions
diff --git a/tcl/tests/compile.test b/tcl/tests/compile.test
index a245084007c..efbca87fb9e 100644
--- a/tcl/tests/compile.test
+++ b/tcl/tests/compile.test
@@ -5,13 +5,17 @@
# generates output for errors. No output means no errors were found.
#
# Copyright (c) 1997 by Sun Microsystems, Inc.
+# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id$
-if {[string compare test [info procs test]] == 1} then {source defs}
+if {[lsearch [namespace children] ::tcltest] == -1} {
+ package require tcltest
+ namespace import -force ::tcltest::*
+}
# The following tests are very incomplete, although the rest of the
# test suite covers this file fairly well.
@@ -69,6 +73,15 @@ test compile-2.4 {TclCompileDollarVar: global scalar name with ::s} {
list [p] $::a(1) [expr {[lsearch -exact [info globals] a] != 0}]
} {1 1 1}
+test compile-3.1 {TclCompileCatchCmd: only catch cmds with scalar vars are compiled inline} {
+ catch {unset a}
+ set a(1) xyzzyx
+ proc p {} {
+ global a
+ catch {set x 123} a(1)
+ }
+ list [p] $a(1)
+} {0 123}
test compile-3.2 {TclCompileCatchCmd: non-local variables} {
set ::foo 1
proc catch-test {} {
@@ -78,8 +91,7 @@ test compile-3.2 {TclCompileCatchCmd: non-local variables} {
set ::foo
} 3
-
-test compile-1.16 {TclCompileForCmd: command substituted test expression} {
+test compile-4.1 {TclCompileForCmd: command substituted test expression} {
set i 0
set j 0
# Should be "forever"
@@ -90,7 +102,7 @@ test compile-1.16 {TclCompileForCmd: command substituted test expression} {
set j
} {4}
-test compile-3.1 {TclCompileForeachCmd: exception stack} {
+test compile-5.1 {TclCompileForeachCmd: exception stack} {
proc foreach-exception-test {} {
foreach array(index) [list 1 2 3] break
foreach array(index) [list 1 2 3] break
@@ -98,7 +110,7 @@ test compile-3.1 {TclCompileForeachCmd: exception stack} {
}
list [catch foreach-exception-test result] $result
} {0 {}}
-test compile-3.2 {TclCompileForeachCmd: non-local variables} {
+test compile-5.2 {TclCompileForeachCmd: non-local variables} {
set ::foo 1
proc foreach-test {} {
foreach ::foo {1 2 3} {}
@@ -107,7 +119,7 @@ test compile-3.2 {TclCompileForeachCmd: non-local variables} {
set ::foo
} 3
-test compile-4.1 {TclCompileSetCmd: global scalar names with ::s} {
+test compile-6.1 {TclCompileSetCmd: global scalar names with ::s} {
catch {unset x}
catch {unset y}
set x 123
@@ -118,7 +130,7 @@ test compile-4.1 {TclCompileSetCmd: global scalar names with ::s} {
list $::x [expr {[lsearch -exact [info globals] x] != 0}] \
[p] $::y [expr {[lsearch -exact [info globals] y] != 0}]
} {123 1 789 789 1}
-test compile-4.2 {TclCompileSetCmd: global array names with ::s} {
+test compile-6.2 {TclCompileSetCmd: global array names with ::s} {
catch {unset a}
set ::a(1) 2
proc p {} {
@@ -127,7 +139,7 @@ test compile-4.2 {TclCompileSetCmd: global array names with ::s} {
}
list $::a(1) [p] [set ::a($::a(1)) 3] $::a(1) [expr {[lsearch -exact [info globals] a] != 0}]
} {2 1 3 3 1}
-test compile-4.3 {TclCompileSetCmd: namespace var names with ::s} {
+test compile-6.3 {TclCompileSetCmd: namespace var names with ::s} {
catch {namespace delete test_ns_compile}
catch {unset x}
namespace eval test_ns_compile {
@@ -139,7 +151,7 @@ test compile-4.3 {TclCompileSetCmd: namespace var names with ::s} {
list $::x $::test_ns_compile::arr(1)
} {hello 123}
-test compile-1.15 {TclCompileWhileCmd: command substituted test expression} {
+test compile-7.1 {TclCompileWhileCmd: command substituted test expression} {
set i 0
set j 0
# Should be "forever"
@@ -150,17 +162,17 @@ test compile-1.15 {TclCompileWhileCmd: command substituted test expression} {
set j
} {4}
-test compile-5.1 {CollectArgInfo: binary data} {
+test compile-8.1 {CollectArgInfo: binary data} {
list [catch "string length \000foo" msg] $msg
} {0 4}
-test compile-5.2 {CollectArgInfo: binary data} {
+test compile-8.2 {CollectArgInfo: binary data} {
list [catch "string length foo\000" msg] $msg
} {0 4}
-test compile-5.3 {CollectArgInfo: handle "]" at end of command properly} {
+test compile-8.3 {CollectArgInfo: handle "]" at end of command properly} {
set x ]
} {]}
-test compile-6.1 {UpdateStringOfByteCode: called for duplicate of compiled empty object} {
+test compile-9.1 {UpdateStringOfByteCode: called for duplicate of compiled empty object} {
proc p {} {
set x {}
eval $x
@@ -170,10 +182,35 @@ test compile-6.1 {UpdateStringOfByteCode: called for duplicate of compiled empty
p
} {}
+test compile-10.1 {BLACKBOX: exception stack overflow} {
+ set x {{0}}
+ set y 0
+ while {$y < 100} {
+ if !$x {incr y}
+ }
+} {}
+
+
+
+# cleanup
catch {rename p ""}
catch {namespace delete test_ns_compile}
catch {unset x}
catch {unset y}
catch {unset a}
-
+::tcltest::cleanupTests
return
+
+
+
+
+
+
+
+
+
+
+
+
+
+