summaryrefslogtreecommitdiffstats
path: root/tests/for.test
diff options
context:
space:
mode:
authorstanton <stanton>1999-05-22 01:20:10 (GMT)
committerstanton <stanton>1999-05-22 01:20:10 (GMT)
commitac39508cf97576cd9747c5630c4a13d794663b4a (patch)
tree4b7c61e6c670f227cf4d603907157fb6246d2d50 /tests/for.test
parent21bd132482f68735f5a4381934f56ee911904e87 (diff)
downloadtcl-ac39508cf97576cd9747c5630c4a13d794663b4a.zip
tcl-ac39508cf97576cd9747c5630c4a13d794663b4a.tar.gz
tcl-ac39508cf97576cd9747c5630c4a13d794663b4a.tar.bz2
Merged changes from scriptics-tclpro-1-3-b2 branch
Diffstat (limited to 'tests/for.test')
-rw-r--r--tests/for.test129
1 files changed, 66 insertions, 63 deletions
diff --git a/tests/for.test b/tests/for.test
index 4503c0b..e60f17a 100644
--- a/tests/for.test
+++ b/tests/for.test
@@ -9,7 +9,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: for.test,v 1.3 1999/04/16 00:47:27 stanton Exp $
+# RCS: @(#) $Id: for.test,v 1.4 1999/05/22 01:20:14 stanton Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
source [file join [pwd] [file dirname [info script]] defs.tcl]
@@ -584,45 +584,77 @@ test for-4.1 {break must reset the interp result} {
set j
} {}
-# Basic "for" operation with computed command names.
-test for-5.1 {for cmd with computed command names: missing initial command} {
- set z for
- list [catch {$z} msg] $msg
-} {1 {wrong # args: should be "for start test next command"}}
-test for-5.2 {for cmd with computed command names: error in initial command} {
+# Test for incorrect "double evaluation" semantics
+
+test for-5.1 {possible delayed substitution of increment command} {knownBug} {
+ # Increment should be 5, and lappend should always append 5
+ catch {unset a}
+ catch {unset i}
+ set a 5
+ set i {}
+ for {set a 1} {$a < 12} "incr a $a" {lappend i $a}
+ set i
+} {1 6 11}
+
+test for-5.2 {possible delayed substitution of body command} {knownBug} {
+ # Increment should be 5, and lappend should always append 5
+ set a 5
+ set i {}
+ for {set a 1} {$a < 12} {incr a $a} "lappend i $a"
+ set i
+} {5 5 5 5}
+
+# In the following tests we need to bypass the bytecode compiler by
+# substituting the command from a variable. This ensures that command
+# procedure is invoked directly.
+
+test for-6.1 {Tcl_ForObjCmd: number of args} {
set z for
- list [catch {$z {set}} msg] $msg $errorInfo
-} {1 {wrong # args: should be "for start test next command"} {wrong # args: should be "for start test next command"
- while executing
-"$z {set}"}}
-test for-5.3 {for cmd with computed command names: missing test expression} {
+ catch {$z} msg
+ set msg
+} {wrong # args: should be "for start test next command"}
+test for-6.2 {Tcl_ForObjCmd: number of args} {
set z for
catch {$z {set i 0}} msg
set msg
} {wrong # args: should be "for start test next command"}
-test for-5.4 {for cmd with computed command names: error in test expression} {
- set z for
- catch {$z {set i 0} {$i<}} msg
- set errorInfo
-} {wrong # args: should be "for start test next command"
- while executing
-"$z {set i 0} {$i<}"}
-test for-5.5 {for cmd with computed command names: test expression is enclosed in quotes} {
- set z for
- set i 0
- $z {} "$i > 5" {incr i} {}
-} {}
-test for-5.6 {for cmd with computed command names: missing "next" command} {
+test for-6.3 {Tcl_ForObjCmd: number of args} {
set z for
catch {$z {set i 0} {$i < 5}} msg
set msg
} {wrong # args: should be "for start test next command"}
-test for-5.7 {for cmd with computed command names: missing command body} {
+test for-6.4 {Tcl_ForObjCmd: number of args} {
set z for
catch {$z {set i 0} {$i < 5} {incr i}} msg
set msg
} {wrong # args: should be "for start test next command"}
-test for-5.8 {for cmd with computed command names: error executing command body} {
+test for-6.5 {Tcl_ForObjCmd: number of args} {
+ set z for
+ catch {$z {set i 0} {$i < 5} {incr i} {body} extra} msg
+ set msg
+} {wrong # args: should be "for start test next command"}
+test for-6.6 {Tcl_ForObjCmd: error in initial command} {
+ set z for
+ list [catch {$z {set} {$i < 5} {incr i} {body}} msg] $msg $errorInfo
+} {1 {wrong # args: should be "set varName ?newValue?"} {wrong # args: should be "set varName ?newValue?"
+ while compiling
+"set"
+ ("for" initial command)
+ invoked from within
+"$z {set} {$i < 5} {incr i} {body}"}}
+test for-6.7 {Tcl_ForObjCmd: error in test expression} {
+ set z for
+ list [catch {$z {set i 0} {i < 5} {incr i} {body}} msg] $msg $errorInfo
+} {1 {syntax error in expression "i < 5"} {syntax error in expression "i < 5"
+ while executing
+"$z {set i 0} {i < 5} {incr i} {body}"}}
+test for-6.8 {Tcl_ForObjCmd: test expression is enclosed in quotes} {
+ set z for
+ set i 0
+ $z {set i 6} "$i > 5" {incr i} {set y $i}
+ set i
+} 6
+test for-6.9 {Tcl_ForObjCmd: error executing command body} {
set z for
catch {$z {set i 0} {$i < 5} {incr i} {set}} msg
set errorInfo
@@ -632,7 +664,7 @@ test for-5.8 {for cmd with computed command names: error executing command body}
("for" body line 1)
invoked from within
"$z {set i 0} {$i < 5} {incr i} {set}"}
-test for-5.9 {for cmd with computed command names: simple command body} {
+test for-6.10 {Tcl_ForObjCmd: simple command body} {
set z for
set a {}
$z {set i 1} {$i<6} {set i [expr $i+1]} {
@@ -641,13 +673,13 @@ test for-5.9 {for cmd with computed command names: simple command body} {
}
set a
} {1 2 3}
-test for-5.10 {for cmd with computed command names: command body in quotes} {
+test for-6.11 {Tcl_ForObjCmd: command body in quotes} {
set z for
set a {}
$z {set i 1} {$i<6} {set i [expr $i+1]} "append a x"
set a
} {xxxxx}
-test for-5.11 {for cmd with computed command names: computed command body} {
+test for-6.12 {Tcl_ForObjCmd: computed command body} {
set z for
catch {unset x1}
catch {unset bb}
@@ -659,7 +691,7 @@ test for-5.11 {for cmd with computed command names: computed command body} {
$z {set i 1} {$i<6} {set i [expr $i+1]} $x1$bb$x2
set a
} {x1}
-test for-5.12 {for cmd with computed command names: error in "next" command} {
+test for-6.13 {Tcl_ForObjCmd: error in "next" command} {
set z for
catch {$z {set i 0} {$i < 5} {set} {set j 4}} msg
set errorInfo
@@ -669,7 +701,7 @@ test for-5.12 {for cmd with computed command names: error in "next" command} {
("for" loop-end command)
invoked from within
"$z {set i 0} {$i < 5} {set} {set j 4}"}
-test for-5.13 {for cmd with computed command names: long command body} {
+test for-6.14 {Tcl_ForObjCmd: long command body} {
set z for
set a {}
$z {set i 1} {$i<6} {set i [expr $i+1]} {
@@ -704,49 +736,20 @@ test for-5.13 {for cmd with computed command names: long command body} {
}
set a
} {1 2 3}
-test for-5.14 {for cmd with computed command names: for command result} {
+test for-6.15 {Tcl_ForObjCmd: for command result} {
set z for
set a [$z {set i 0} {$i < 5} {incr i} {}]
set a
} {}
-test for-5.15 {for cmd with computed command names: for command result} {
+test for-6.16 {Tcl_ForObjCmd: for command result} {
set z for
set a [$z {set i 0} {$i < 5} {incr i} {if $i==3 break}]
set a
} {}
-# Test for incorrect "double evaluation" semantics
-test for-6.1 {possible delayed substitution of increment command} {knownBug} {
- # Increment should be 5, and lappend should always append 5
- catch {unset a}
- catch {unset i}
- set a 5
- set i {}
- for {set a 1} {$a < 12} "incr a $a" {lappend i $a}
- set i
-} {1 6 11}
-
-test for-6.2 {possible delayed substitution of body command} {knownBug} {
- # Increment should be 5, and lappend should always append 5
- set a 5
- set i {}
- for {set a 1} {$a < 12} {incr a $a} "lappend i $a"
- set i
-} {5 5 5 5}
# cleanup
::tcltest::cleanupTests
return
-
-
-
-
-
-
-
-
-
-
-