From c1468b897df2e62147dc89c8dbdab4fc7c415fe0 Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 22 Aug 2006 18:10:43 +0000 Subject: More test flexibility --- tests/for.test | 9 ++------- tests/if.test | 40 +++++++++------------------------------- tests/while.test | 16 ++++------------ 3 files changed, 15 insertions(+), 50 deletions(-) diff --git a/tests/for.test b/tests/for.test index a3a2d7d..0266de4 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.14 2006/08/22 04:03:24 dgp Exp $ +# RCS: @(#) $Id: for.test,v 1.15 2006/08/22 18:10:43 dgp Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -663,12 +663,7 @@ test for-6.7 {Tcl_ForObjCmd: error in test expression} -body { set z for catch {$z {set i 0} {i < 5} {incr i} {body}} set errorInfo -} -result {invalid bareword "i" -in expression "i < 5"; -should be "$i" or "{i}" or "i(...)" or ... - (parsing expression "i < 5") - invoked from within -"$z {set i 0} {i < 5} {incr i} {body}"} +} -match glob -result {*"$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 diff --git a/tests/if.test b/tests/if.test index bbf10bc..5f625b9 100644 --- a/tests/if.test +++ b/tests/if.test @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: if.test,v 1.10 2006/08/22 04:03:24 dgp Exp $ +# RCS: @(#) $Id: if.test,v 1.11 2006/08/22 18:10:44 dgp Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -28,12 +28,7 @@ test if-1.2 {TclCompileIfCmd: error in if/elseif test} { } {1 {error in condition}} test if-1.3 {TclCompileIfCmd: error in if/elseif test} -body { list [catch {if {1+}} msg] $msg $errorInfo -} -result {1 {missing operand at _@_ -in expression "1+_@_"} {missing operand at _@_ -in expression "1+_@_" - (parsing expression "1+") - invoked from within -"if {1+}"}} +} -match glob -result {1 * {*"if {1+}"}} test if-1.4 {TclCompileIfCmd: if/elseif test in braces} { set a {} if {1<2} {set a 1} @@ -179,12 +174,7 @@ test if-2.3 {TclCompileIfCmd: missing expression after "elseif"} { test if-2.4 {TclCompileIfCmd: error in expression after "elseif"} -body { set a {} list [catch {if 3>4 {set a 1} elseif {1>}} msg] $msg $errorInfo -} -result {1 {missing operand at _@_ -in expression "1>_@_"} {missing operand at _@_ -in expression "1>_@_" - (parsing expression "1>") - invoked from within -"if 3>4 {set a 1} elseif {1>}"}} +} -match glob -result {1 * {*"if 3>4 {set a 1} elseif {1>}"}} test if-2.5 {TclCompileIfCmd: test jumpFalse instruction replacement after long "elseif" body} { catch {unset i} set a {} @@ -507,15 +497,10 @@ test if-5.2 {if cmd with computed command names: error in if/elseif test} { set z if list [catch {$z {[error "error in condition"]} foo} msg] $msg } {1 {error in condition}} -test if-5.3 {if cmd with computed command names: error in if/elseif test} { +test if-5.3 {if cmd with computed command names: error in if/elseif test} -body { set z if list [catch {$z {1+}} msg] $msg $errorInfo -} {1 {missing operand at _@_ -in expression "1+_@_"} {missing operand at _@_ -in expression "1+_@_" - (parsing expression "1+") - invoked from within -"$z {1+}"}} +} -match glob -result {1 * {*"$z {1+}"}} test if-5.4 {if cmd with computed command names: if/elseif test in braces} { set z if set a {} @@ -677,16 +662,11 @@ test if-6.3 {if cmd with computed command names: missing expression after "elsei catch {$z 1<2 {set a 1} elseif} msg set msg } {wrong # args: no expression after "elseif" argument} -test if-6.4 {if cmd with computed command names: error in expression after "elseif"} { +test if-6.4 {if cmd with computed command names: error in expression after "elseif"} -body { set z if set a {} list [catch {$z 3>4 {set a 1} elseif {1>}} msg] $msg $errorInfo -} {1 {missing operand at _@_ -in expression "1>_@_"} {missing operand at _@_ -in expression "1>_@_" - (parsing expression "1>") - invoked from within -"$z 3>4 {set a 1} elseif {1>}"}} +} -match glob -result {1 * {*"$z 3>4 {set a 1} elseif {1>}"}} test if-6.5 {if cmd with computed command names: test jumpFalse instruction replacement after long "elseif" body} { set z if catch {unset i} @@ -1094,7 +1074,7 @@ test if-10.5 {substituted control words} { set elseif elseif; proc elseif {} {return badelseif} list [catch {if 1 $then {if 0 {} $elseif 1 {if 0 {} $else {list ok}}}} a] $a } {0 ok} -test if-10.6 {double invocation of variable traces} { +test if-10.6 {double invocation of variable traces} -body { set iftracecounter 0 proc iftraceproc {args} { upvar #0 iftracecounter counter @@ -1112,9 +1092,7 @@ test if-10.6 {double invocation of variable traces} { list [catch {if "$iftracevar + 20" {}} a] $a \ [catch {if "$iftracevar + 20" {}} b] $b \ [unset iftracevar iftracecounter] -} {1 {invalid bareword "oops" -in expression "1 oops 10 + 20"; -should be "$oops" or "{oops}" or "oops(...)" or ...} 0 {} {}} +} -match glob -result {1 {*} 0 {} {}} # cleanup ::tcltest::cleanupTests diff --git a/tests/while.test b/tests/while.test index 411ba20..562a2aa 100644 --- a/tests/while.test +++ b/tests/while.test @@ -10,7 +10,7 @@ # 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.11 2006/08/22 04:03:24 dgp Exp $ +# RCS: @(#) $Id: while.test,v 1.12 2006/08/22 18:10:44 dgp Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -30,11 +30,7 @@ test while-1.2 {TclCompileWhileCmd: error in test expression} -body { set i 0 catch {while {$i<} break} msg set errorInfo -} -result {missing operand at _@_ -in expression "$i<_@_" - (parsing expression "$i<") - invoked from within -"while {$i<} break"} +} -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 @@ -303,16 +299,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 -} {missing operand at _@_ -in expression "$i<_@_" - (parsing expression "$i<") - invoked from within -"$z {$i<} {set x 1}"} +} -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] -- cgit v0.12