diff options
Diffstat (limited to 'tests/expr-old.test')
-rw-r--r-- | tests/expr-old.test | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/tests/expr-old.test b/tests/expr-old.test index f4e2a4c..be7d3c2 100644 --- a/tests/expr-old.test +++ b/tests/expr-old.test @@ -13,13 +13,17 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: expr-old.test,v 1.35 2006/07/05 05:34:45 dgp Exp $ +# RCS: @(#) $Id: expr-old.test,v 1.36 2006/08/02 20:03:37 das Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2.1 namespace import -force ::tcltest::* } +# Constraint set on tests that depend on the exact format of the error messages +# of the pre-2006/07/05 expression parser (-DOLD_EXPR_PARSER=1) +testConstraint oldExprParser [expr {![testConstraint newExprParser]}] + testConstraint testexprlong [llength [info commands testexprlong]] testConstraint testexprdouble [llength [info commands testexprdouble]] testConstraint testexprstring [llength [info commands testexprstring]] @@ -495,10 +499,10 @@ test expr-old-25.20 {type conversions} {expr 10.0} 10.0 test expr-old-26.1 {error conditions} { list [catch {expr 2+"a"} msg] $msg } {1 {can't use non-numeric string as operand of "+"}} -test expr-old-26.2 {error conditions} { +test expr-old-26.2 {error conditions} {oldExprParser} { list [catch {expr 2+4*} msg] $msg } {1 {syntax error in expression "2+4*": premature end of expression}} -test expr-old-26.3 {error conditions} { +test expr-old-26.3 {error conditions} {oldExprParser} { list [catch {expr 2+4*(} msg] $msg } {1 {syntax error in expression "2+4*(": premature end of expression}} catch {unset _non_existent_} @@ -512,7 +516,7 @@ test expr-old-26.5 {error conditions} { test expr-old-26.6 {error conditions} { list [catch {expr {2+[set a]}} msg] $msg } {1 {can't use non-numeric string as operand of "+"}} -test expr-old-26.7 {error conditions} { +test expr-old-26.7 {error conditions} {oldExprParser} { list [catch {expr {2+(4}} msg] $msg } {1 {syntax error in expression "2+(4": looking for close parenthesis}} test expr-old-26.8 {error conditions} { @@ -527,31 +531,31 @@ test expr-old-26.10a {error conditions} !ieeeFloatingPoint { test expr-old-26.10b {error conditions} ieeeFloatingPoint { list [catch {expr 2.0/0.0} msg] $msg } {0 Inf} -test expr-old-26.11 {error conditions} { +test expr-old-26.11 {error conditions} {oldExprParser} { list [catch {expr 2#} msg] $msg } {1 {syntax error in expression "2#": extra tokens at end of expression}} -test expr-old-26.12 {error conditions} -body { +test expr-old-26.12 {error conditions} -constraints {oldExprParser} -body { list [catch {expr a.b} msg] $msg } -match glob -result {1 {syntax error in expression "a.b": * preceding $*}} test expr-old-26.13 {error conditions} { list [catch {expr {"a"/"b"}} msg] $msg } {1 {can't use non-numeric string as operand of "/"}} -test expr-old-26.14 {error conditions} { +test expr-old-26.14 {error conditions} {oldExprParser} { list [catch {expr 2:3} msg] $msg } {1 {syntax error in expression "2:3": extra tokens at end of expression}} -test expr-old-26.15 {error conditions} -body { +test expr-old-26.15 {error conditions} -constraints {oldExprParser} -body { list [catch {expr a@b} msg] $msg } -match glob -result {1 {syntax error in expression "a@b": * preceding $*}} test expr-old-26.16 {error conditions} { list [catch {expr a[b} msg] $msg } {1 {missing close-bracket}} -test expr-old-26.17 {error conditions} -body { +test expr-old-26.17 {error conditions} -constraints {oldExprParser} -body { list [catch {expr a`b} msg] $msg } -match glob -result {1 {syntax error in expression "a`b": * preceding $*}} -test expr-old-26.18 {error conditions} { +test expr-old-26.18 {error conditions} {oldExprParser} { list [catch {expr \"a\"\{b} msg] $msg } {1 syntax\ error\ in\ expression\ \"\"a\"\{b\":\ extra\ tokens\ at\ end\ of\ expression} -test expr-old-26.19 {error conditions} -body { +test expr-old-26.19 {error conditions} -constraints {oldExprParser} -body { list [catch {expr a} msg] $msg } -match glob -result {1 {syntax error in expression "a": * preceding $*}} test expr-old-26.20 {error conditions} { @@ -601,10 +605,10 @@ test expr-old-27.10 {cancelled evaluation} { set x -1.0 list [catch {expr {($x > 0) ? round(log($x)) : 0}} msg] $msg } {0 0} -test expr-old-27.11 {cancelled evaluation} -body { +test expr-old-27.11 {cancelled evaluation} -constraints {oldExprParser} -body { list [catch {expr {0 && foo}} msg] $msg } -match glob -result {1 {syntax error in expression "0 && foo": * preceding $*}} -test expr-old-27.12 {cancelled evaluation} -body { +test expr-old-27.12 {cancelled evaluation} -constraints {oldExprParser} -body { list [catch {expr {0 ? 1 : foo}} msg] $msg } -match glob -result {1 {syntax error in expression "0 ? 1 : foo": * preceding $*}} @@ -681,7 +685,7 @@ test expr-old-29.1 {braces} {expr {{abc}}} abc test expr-old-29.2 {braces} {expr {{00010}}} 8 test expr-old-29.3 {braces} {expr {{3.1200000}}} 3.12 test expr-old-29.4 {braces} {expr {{a{b}{1 {2 3}}c}}} "a{b}{1 {2 3}}c" -test expr-old-29.5 {braces} { +test expr-old-29.5 {braces} {oldExprParser} { list [catch {expr "\{abc"} msg] $msg } {1 {missing close-brace}} @@ -704,13 +708,13 @@ test expr-old-30.2 {long values} { test expr-old-31.1 {multiple arguments to expr command} { expr 4 + ( 6 *12) -3 } 73 -test expr-old-31.2 {multiple arguments to expr command} { +test expr-old-31.2 {multiple arguments to expr command} {oldExprParser} { list [catch {expr 2 + (3 + 4} msg] $msg } {1 {syntax error in expression "2 + (3 + 4": looking for close parenthesis}} -test expr-old-31.3 {multiple arguments to expr command} { +test expr-old-31.3 {multiple arguments to expr command} {oldExprParser} { list [catch {expr 2 + 3 +} msg] $msg } {1 {syntax error in expression "2 + 3 +": premature end of expression}} -test expr-old-31.4 {multiple arguments to expr command} { +test expr-old-31.4 {multiple arguments to expr command} {oldExprParser} { list [catch {expr 2 + 3 )} msg] $msg } {1 {syntax error in expression "2 + 3 )": extra tokens at end of expression}} @@ -902,19 +906,19 @@ test expr-old-33.4 {conversions and fancy args to math functions} { test expr-old-34.1 {errors in math functions} -body { list [catch {expr func_2(1.0)} msg] $msg } -match glob -result {1 {* "*func_2"}} -test expr-old-34.2 {errors in math functions} -body { +test expr-old-34.2 {errors in math functions} -constraints {oldExprParser} -body { list [catch {expr func|(1.0)} msg] $msg } -match glob -result {1 {syntax error in expression "func|(1.0)": * preceding $*}} test expr-old-34.3 {errors in math functions} { list [catch {expr {hypot("a b", 2.0)}} msg] $msg } {1 {expected floating-point number but got "a b"}} -test expr-old-34.4 {errors in math functions} { +test expr-old-34.4 {errors in math functions} {oldExprParser} { list [catch {expr hypot(1.0 2.0)} msg] $msg } {1 {syntax error in expression "hypot(1.0 2.0)": missing close parenthesis at end of function call}} -test expr-old-34.5 {errors in math functions} { +test expr-old-34.5 {errors in math functions} {oldExprParser} { list [catch {expr hypot(1.0, 2.0} msg] $msg } {1 {syntax error in expression "hypot(1.0, 2.0": missing close parenthesis at end of function call}} -test expr-old-34.6 {errors in math functions} { +test expr-old-34.6 {errors in math functions} {oldExprParser} { list [catch {expr hypot(1.0 ,} msg] $msg } {1 {syntax error in expression "hypot(1.0 ,": premature end of expression}} test expr-old-34.7 {errors in math functions} -body { @@ -989,7 +993,7 @@ test expr-old-36.8 {ExprLooksLikeInt procedure} { test expr-old-36.9 {ExprLooksLikeInt procedure} { list [catch {expr 24E1} msg] $msg } {0 240.0} -test expr-old-36.10 {ExprLooksLikeInt procedure} -body { +test expr-old-36.10 {ExprLooksLikeInt procedure} -constraints {oldExprParser} -body { expr 78e } -returnCodes error -match glob -result {syntax error in expression "78e"*} @@ -1118,11 +1122,11 @@ test expr-old-37.24 {Tcl_ExprDouble handles overflows that look like int} \ testexprdouble 17976931348623165[string repeat 0 292] } {This is a result: Inf} test expr-old-37.25 {Tcl_ExprDouble and NaN} \ - {ieeeFloatingPoint testexprdouble} { + {ieeeFloatingPoint testexprdouble oldExprParser} { list [catch {testexprdouble 0.0/0.0} result] $result } {1 {floating point value is Not a Number}} -test expr-old-38.1 {Verify Tcl_ExprString's basic operation} testexprstring { +test expr-old-38.1 {Verify Tcl_ExprString's basic operation} {testexprstring oldExprParser} { list [testexprstring "1+4"] [testexprstring "2*3+4.2"] \ [catch {testexprstring "1+"} msg] $msg } {5 10.2 1 {syntax error in expression "1+": premature end of expression}} |