1 # Commands covered: while
3 # This file contains the original set of tests for Tcl's while command.
4 # Since the while command is now compiled, a new set of tests covering
5 # the new implementation is in the file "while.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.
11 # Copyright (c) 1998-1999 by Scriptics Corporation.
13 # See the file "license.terms" for information on usage and redistribution
14 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
16 # RCS: @(#) $Id: while-old.test,v 1.6 2000/04/10 17:19:06 ericm Exp $
18 source [file dirname [info script]]/testing.tcl
20 test while-old-1.1 {basic while loops} {
22 while {$count < 10} {set count [expr $count+1]}
25 test while-old-1.2 {basic while loops} {
27 while {2 > 3} {set value yyy}
30 test while-old-1.3 {basic while loops} {
40 test while-old-1.4 {basic while loops, multiline test expr} {
42 while {($tcl_platform(platform) != "foobar1") && \
43 ($tcl_platform(platform) != "foobar2")} {
49 test while-old-1.5 {basic while loops, test expr in quotes} {
51 while "0 < 3" {set value 2; break}
55 test while-old-2.1 {continue in while loop} {
60 if {$index == 2} {set index [expr $index+1]; continue}
61 set result [concat $result [lindex $list $index]]
62 set index [expr $index+1]
67 test while-old-3.1 {break in while loop} {
72 if {$index == 3} break
73 set result [concat $result [lindex $list $index]]
74 set index [expr $index+1]
79 test while-old-4.1 {errors in while loops} {
80 set err [catch {while} msg]
83 test while-old-4.2 {errors in while loops} {
84 set err [catch {while 1} msg]
87 test while-old-4.3 {errors in while loops} {
88 set err [catch {while 1 2 3} msg]
91 test while-old-4.4 {errors in while loops} {
92 set err [catch {while {"a"+"b"} {error "loop aborted"}} msg]
95 test while-old-4.5 {errors in while loops} {
98 set err [catch {while {$x} {set x foo}} msg]
101 test while-old-4.6 {errors in while loops} {
102 set err [catch {while {1} {error "loop aborted"}} msg]
106 test while-old-5.1 {while return result} {
107 while {0} {set a 400}
109 test while-old-5.2 {while return result} {
113 test while-old-5.3 {while return result} {