diff options
Diffstat (limited to 'tests/while.test')
| -rw-r--r-- | tests/while.test | 67 |
1 files changed, 26 insertions, 41 deletions
diff --git a/tests/while.test b/tests/while.test index f34bf64..4ad966e 100644 --- a/tests/while.test +++ b/tests/while.test @@ -9,11 +9,9 @@ # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -# -# RCS: @(#) $Id: while.test,v 1.6 2000/04/10 17:19:06 ericm Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest + package require tcltest 2 namespace import -force ::tcltest::* } @@ -26,14 +24,11 @@ test while-1.1 {TclCompileWhileCmd: missing test expression} { catch {while } msg set msg } {wrong # args: should be "while test command"} -test while-1.2 {TclCompileWhileCmd: error in test expression} { +test while-1.2 {TclCompileWhileCmd: error in test expression} -body { set i 0 catch {while {$i<} break} msg - set errorInfo -} {syntax error in expression "$i<" - ("while" test expression) - while compiling -"while {$i<} break"} + set ::errorInfo +} -match glob -result {*"while {$i<} break"} test while-1.3 {TclCompileWhileCmd: error in test expression} { set err [catch {while {"a"+"b"} {error "loop aborted"}} msg] list $err $msg @@ -66,16 +61,13 @@ test while-1.7 {TclCompileWhileCmd: missing command body} { catch {while {$i < 5} } msg set msg } {wrong # args: should be "while test command"} -test while-1.8 {TclCompileWhileCmd: error compiling command body} { +test while-1.8 {TclCompileWhileCmd: error compiling command body} -body { set i 0 catch {while {$i < 5} {set}} msg - set errorInfo -} {wrong # args: should be "set varName ?newValue?" - while compiling -"set" - ("while" body line 1) - while compiling -"while {$i < 5} {set}"} + set ::errorInfo +} -match glob -result {wrong # args: should be "set varName ?newValue?" + while *ing +"set"*} test while-1.9 {TclCompileWhileCmd: simple command body} { set a {} set i 1 @@ -305,14 +297,12 @@ test while-4.2 {while (not compiled): missing test expression} { catch {$z } msg set msg } {wrong # args: should be "while test command"} -test while-4.3 {while (not compiled): error in test expression} { +test while-4.3 {while (not compiled): error in test expression} -body { set i 0 set z while catch {$z {$i<} {set x 1}} msg - set errorInfo -} {syntax error in expression "$i<" - while executing -"$z {$i<} {set x 1}"} + set ::errorInfo +} -match glob -result {*"$z {$i<} {set x 1}"} test while-4.4 {while (not compiled): error in test expression} { set z while set err [catch {$z {"a"+"b"} {error "loop aborted"}} msg] @@ -350,13 +340,13 @@ test while-4.8 {while (not compiled): missing command body} { catch {$z {$i < 5} } msg set msg } {wrong # args: should be "while test command"} -test while-4.9 {while (not compiled): error compiling command body} { +test while-4.9 {while (not compiled): error compiling command body} -body { set i 0 set z while catch {$z {$i < 5} {set}} msg - set errorInfo -} {wrong # args: should be "set varName ?newValue?" - while compiling + set ::errorInfo +} -match glob -result {wrong # args: should be "set varName ?newValue?" + while *ing "set" ("while" body line 1) invoked from within @@ -609,26 +599,21 @@ test while-6.5 {continue tests, long command body with computed command names} { # Test for incorrect "double evaluation" semantics -test while-7.1 {delayed substitution of body} {knownBug} { +test while-7.1 {delayed substitution of body} { set i 0 while {[incr i] < 10} " set result $i " - set result -} {0} + proc p {} { + set i 0 + while {[incr i] < 10} " + set result $i + " + set result + } + append result [p] +} {00} # cleanup ::tcltest::cleanupTests return - - - - - - - - - - - - |
