summaryrefslogtreecommitdiffstats
path: root/tests/for.test
diff options
context:
space:
mode:
authormdejong <mdejong>2005-06-20 07:48:52 (GMT)
committermdejong <mdejong>2005-06-20 07:48:52 (GMT)
commit1ffccc907f8947bb84f4ccd20460b5122be83c9a (patch)
treeee1c355ba23b428babc4af24558cc67d779747dc /tests/for.test
parent6c01aeca56323105bfa7810baba82c7da8ee928d (diff)
downloadtcl-1ffccc907f8947bb84f4ccd20460b5122be83c9a.zip
tcl-1ffccc907f8947bb84f4ccd20460b5122be83c9a.tar.gz
tcl-1ffccc907f8947bb84f4ccd20460b5122be83c9a.tar.bz2
* generic/tclCmdMZ.c (Tcl_SwitchObjCmd): Generate
an error if a mode argument like -exact is passed more than once to the switch command. The previous implementation silently accepted invalid switch invocations like [switch -exact -glob $str ...]. * tests/for.test: Check some error cases when invoking continue and break inside a for loop next script. * tests/switch.test: Add checks for shortened version of a mode argument like -exact. Add test for more than one mode argument. Add test for odd case of passing a variable as a body script.
Diffstat (limited to 'tests/for.test')
-rw-r--r--tests/for.test53
1 files changed, 51 insertions, 2 deletions
diff --git a/tests/for.test b/tests/for.test
index 0217f78..7c968f6 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.11 2005/05/10 18:35:20 kennykb Exp $
+# RCS: @(#) $Id: for.test,v 1.12 2005/06/20 07:49:11 mdejong Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -763,7 +763,56 @@ test for-6.16 {Tcl_ForObjCmd: for command result} {
set a [$z {set i 0} {$i < 5} {incr i} {if $i==3 break}]
set a
} {}
-
+test for-6.17 {Tcl_ForObjCmd: for command result} {
+ list \
+ [catch {for {break} {1} {} {}} err] $err \
+ [catch {for {continue} {1} {} {}} err] $err \
+ [catch {for {} {[break]} {} {}} err] $err \
+ [catch {for {} {[continue]} {} {}} err] $err \
+ [catch {for {} {1} {break} {}} err] $err \
+ [catch {for {} {1} {continue} {}} err] $err \
+} [list \
+ 3 {} \
+ 4 {} \
+ 3 {} \
+ 4 {} \
+ 0 {} \
+ 4 {} \
+ ]
+test for-6.18 {Tcl_ForObjCmd: for command result} {
+ proc p6181 {} {
+ for {break} {1} {} {}
+ }
+ proc p6182 {} {
+ for {continue} {1} {} {}
+ }
+ proc p6183 {} {
+ for {} {[break]} {} {}
+ }
+ proc p6184 {} {
+ for {} {[continue]} {} {}
+ }
+ proc p6185 {} {
+ for {} {1} {break} {}
+ }
+ proc p6186 {} {
+ for {} {1} {continue} {}
+ }
+ list \
+ [catch {p6181} err] $err \
+ [catch {p6182} err] $err \
+ [catch {p6183} err] $err \
+ [catch {p6184} err] $err \
+ [catch {p6185} err] $err \
+ [catch {p6186} err] $err
+} [list \
+ 1 {invoked "break" outside of a loop} \
+ 1 {invoked "continue" outside of a loop} \
+ 1 {invoked "break" outside of a loop} \
+ 1 {invoked "continue" outside of a loop} \
+ 0 {} \
+ 1 {invoked "continue" outside of a loop} \
+ ]
# cleanup