1 # Commands covered: for, continue, break
3 # This file contains the original set of tests for Tcl's for command.
4 # Since the for command is now compiled, a new set of tests covering
5 # the new implementation is in the file "for.test". Sourcing this file
6 # into Tcl runs the tests and generates output for errors.
7 # No output means no errors were found.
9 # Copyright (c) 1991-1993 The Regents of the University of California.
10 # Copyright (c) 1994-1996 Sun Microsystems, Inc.
12 # See the file "license.terms" for information on usage and redistribution
13 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
17 if {[lsearch [namespace children] ::tcltest] == -1} {
18 package require tcltest
19 namespace import -force ::tcltest::*
22 # Check "for" and its use of continue and break.
25 test for-old-1.1 {for tests} {
27 for {set i 1} {$i<6} {set i [expr $i+1]} {
32 test for-old-1.2 {for tests} {
34 for {set i 1} {$i<6} {set i [expr $i+1]} {
40 test for-old-1.3 {for tests} {
42 for {set i 1} {$i<6} {set i [expr $i+1]} {
48 test for-old-1.4 {for tests} {catch {for 1 2 3} msg} 1
49 test for-old-1.5 {for tests} {
52 } {wrong # args: should be "for start test next command"}
53 test for-old-1.6 {for tests} {catch {for 1 2 3 4 5} msg} 1
54 test for-old-1.7 {for tests} {
55 catch {for 1 2 3 4 5} msg
57 } {wrong # args: should be "for start test next command"}
58 test for-old-1.8 {for tests} {
60 for {set i 1} {$i<6} {set i [expr $i+1]} {}
63 test for-old-1.9 {for tests} {
65 for {set i 1} {$i<6} {set i [expr $i+1]; if $i==4 break} {
72 ::tcltest::cleanupTests