summaryrefslogtreecommitdiffstats
path: root/tests/expr-old.test
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2006-08-22 04:03:23 (GMT)
committerdgp <dgp@users.sourceforge.net>2006-08-22 04:03:23 (GMT)
commita9e01d92cd36a6bd0e284252cb645ebe343c7c36 (patch)
tree3c2ba6753261f2925bdb82db20c562b7454c6adf /tests/expr-old.test
parent3154c0f487e39f1d7ad82415bcb33fcfc614593b (diff)
downloadtcl-a9e01d92cd36a6bd0e284252cb645ebe343c7c36.zip
tcl-a9e01d92cd36a6bd0e284252cb645ebe343c7c36.tar.gz
tcl-a9e01d92cd36a6bd0e284252cb645ebe343c7c36.tar.bz2
* tests/compExpr-old.test: Update existing tests to not fail
* tests/compExpr.test: with the new expr parser. * tests/compile.test: * tests/expr-old.test: * tests/expr.test: * tests/for.test: * tests/if.test: * tests/parseExpr.test: * tests/while.test:
Diffstat (limited to 'tests/expr-old.test')
-rw-r--r--tests/expr-old.test136
1 files changed, 66 insertions, 70 deletions
diff --git a/tests/expr-old.test b/tests/expr-old.test
index be7d3c2..e842f22 100644
--- a/tests/expr-old.test
+++ b/tests/expr-old.test
@@ -13,17 +13,13 @@
# 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.36 2006/08/02 20:03:37 das Exp $
+# RCS: @(#) $Id: expr-old.test,v 1.37 2006/08/22 04:03:23 dgp 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]]
@@ -499,12 +495,12 @@ 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} {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} {oldExprParser} {
- list [catch {expr 2+4*(} msg] $msg
-} {1 {syntax error in expression "2+4*(": premature end of expression}}
+test expr-old-26.2 {error conditions} -body {
+ expr 2+4*
+} -returnCodes error -match glob -result *
+test expr-old-26.3 {error conditions} -body {
+ expr 2+4*(
+} -returnCodes error -match glob -result *
catch {unset _non_existent_}
test expr-old-26.4 {error conditions} {
list [catch {expr 2+$_non_existent_} msg] $msg
@@ -516,9 +512,9 @@ 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} {oldExprParser} {
- list [catch {expr {2+(4}} msg] $msg
-} {1 {syntax error in expression "2+(4": looking for close parenthesis}}
+test expr-old-26.7 {error conditions} -body {
+ expr {2+(4}
+} -returnCodes error -match glob -result *
test expr-old-26.8 {error conditions} {
list [catch {expr 2/0} msg] $msg $errorCode
} {1 {divide by zero} {ARITH DIVZERO {divide by zero}}}
@@ -531,33 +527,33 @@ 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} {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} -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.11 {error conditions} -body {
+ expr 2#
+} -returnCodes error -match glob -result *
+test expr-old-26.12 {error conditions} -body {
+ expr a.b
+} -returnCodes error -match glob -result *
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} {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} -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.14 {error conditions} -body {
+ expr 2:3
+} -returnCodes error -match glob -result *
+test expr-old-26.15 {error conditions} -body {
+ expr a@b
+} -returnCodes error -match glob -result *
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} -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} {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} -constraints {oldExprParser} -body {
- list [catch {expr a} msg] $msg
-} -match glob -result {1 {syntax error in expression "a": * preceding $*}}
+test expr-old-26.17 {error conditions} -body {
+ expr a`b
+} -returnCodes error -match glob -result *
+test expr-old-26.18 {error conditions} -body {
+ expr \"a\"\{b
+} -returnCodes error -match glob -result *
+test expr-old-26.19 {error conditions} -body {
+ expr a
+} -returnCodes error -match glob -result *
test expr-old-26.20 {error conditions} {
list [catch expr msg] $msg
} {1 {wrong # args: should be "expr arg ?arg ...?"}}
@@ -605,12 +601,12 @@ 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} -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} -constraints {oldExprParser} -body {
- list [catch {expr {0 ? 1 : foo}} msg] $msg
-} -match glob -result {1 {syntax error in expression "0 ? 1 : foo": * preceding $*}}
+test expr-old-27.11 {cancelled evaluation} -body {
+ expr {0 && foo}
+} -returnCodes error -match glob -result *
+test expr-old-27.12 {cancelled evaluation} -body {
+ expr {0 ? 1 : foo}
+} -returnCodes error -match glob -result *
# Tcl_ExprBool as used in "if" statements
@@ -685,9 +681,9 @@ 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} {oldExprParser} {
- list [catch {expr "\{abc"} msg] $msg
-} {1 {missing close-brace}}
+test expr-old-29.5 {braces} -body {
+ expr "\{abc"
+} -returnCodes error -match glob -result *
# Very long values
@@ -708,15 +704,15 @@ 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} {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} {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} {oldExprParser} {
- list [catch {expr 2 + 3 )} msg] $msg
-} {1 {syntax error in expression "2 + 3 )": extra tokens at end of expression}}
+test expr-old-31.2 {multiple arguments to expr command} -body {
+ expr 2 + (3 + 4
+} -returnCodes error -match glob -result *
+test expr-old-31.3 {multiple arguments to expr command} -body {
+ expr 2 + 3 +
+} -returnCodes error -match glob -result *
+test expr-old-31.4 {multiple arguments to expr command} -body {
+ expr 2 + 3 )
+} -returnCodes error -match glob -result *
# Math functions
@@ -906,21 +902,21 @@ 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} -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.2 {errors in math functions} -body {
+ expr func|(1.0)
+} -returnCodes error -match glob -result *
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} {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} {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} {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.4 {errors in math functions} -body {
+ expr hypot(1.0 2.0)
+} -returnCodes error -match glob -result *
+test expr-old-34.5 {errors in math functions} -body {
+ expr hypot(1.0, 2.0
+} -returnCodes error -match glob -result *
+test expr-old-34.6 {errors in math functions} -body {
+ expr hypot(1.0 ,
+} -returnCodes error -match glob -result *
test expr-old-34.7 {errors in math functions} -body {
list [catch {expr hypot(1.0)} msg] $msg
} -match glob -result {1 {too few arguments for math function*}}
@@ -993,9 +989,9 @@ 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} -constraints {oldExprParser} -body {
+test expr-old-36.10 {ExprLooksLikeInt procedure} -body {
expr 78e
-} -returnCodes error -match glob -result {syntax error in expression "78e"*}
+} -returnCodes error -match glob -result *
# test for [Bug #542588]
test expr-old-36.11 {ExprLooksLikeInt procedure} {
@@ -1122,14 +1118,14 @@ 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 oldExprParser} {
+ {ieeeFloatingPoint testexprdouble} {
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 oldExprParser} {
+test expr-old-38.1 {Verify Tcl_ExprString's basic operation} -constraints {testexprstring} -body {
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}}
+} -match glob -result {5 10.2 1 *}
test expr-old-38.2 {Tcl_ExprString} testexprstring {
# This one is "magical"
testexprstring {}