summaryrefslogtreecommitdiffstats
path: root/tests/expr.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/expr.test')
-rw-r--r--tests/expr.test425
1 files changed, 177 insertions, 248 deletions
diff --git a/tests/expr.test b/tests/expr.test
index ef84607..93efbde 100644
--- a/tests/expr.test
+++ b/tests/expr.test
@@ -10,17 +10,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.test,v 1.57 2006/08/02 20:03:37 das Exp $
+# RCS: @(#) $Id: expr.test,v 1.58 2006/08/22 04:03:24 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 testmathfunctions [expr {
([catch {expr T1()} msg] != 1) || ($msg ne {invalid command name "tcl::mathfunc::T1"})
}]
@@ -207,33 +203,28 @@ test expr-1.15 {TclCompileExprCmd: second level of substitutions in expr with co
test expr-2.1 {TclCompileExpr: are builtin functions registered?} {
expr double(5*[llength "6 2"])
} 10.0
-test expr-2.2 {TclCompileExpr: error in expr} {oldExprParser} {
- catch {expr 2***3} msg
- set msg
-} {syntax error in expression "2***3": unexpected operator *}
-test expr-2.3 {TclCompileExpr: junk after legal expr} {oldExprParser} {
- catch {expr 7*[llength "a b"]foo} msg
- set msg
-} {syntax error in expression "7*2foo": extra tokens at end of expression}
+test expr-2.2 {TclCompileExpr: error in expr} -body {
+ expr 2***3
+} -returnCodes error -match glob -result *
+test expr-2.3 {TclCompileExpr: junk after legal expr} -body {
+ expr 7*[llength "a b"]foo
+} -returnCodes error -match glob -result *
test expr-2.4 {TclCompileExpr: numeric expr string rep == formatted int rep} {
expr {0001}
} 1
test expr-3.1 {CompileCondExpr: just lor expr} {expr 3||0} 1
-test expr-3.2 {CompileCondExpr: error in lor expr} -constraints {oldExprParser} -body {
- catch {expr x||3} msg
- set msg
-} -match glob -result {syntax error in expression "x||3": * preceding $*}
+test expr-3.2 {CompileCondExpr: error in lor expr} -body {
+ expr x||3
+} -returnCodes error -match glob -result *
test expr-3.3 {CompileCondExpr: test true arm} {expr 3>2?44:66} 44
-test expr-3.4 {CompileCondExpr: error compiling true arm} {oldExprParser} {
- catch {expr 3>2?2***3:66} msg
- set msg
-} {syntax error in expression "3>2?2***3:66": unexpected operator *}
+test expr-3.4 {CompileCondExpr: error compiling true arm} -body {
+ expr 3>2?2***3:66
+} -returnCodes error -match glob -result *
test expr-3.5 {CompileCondExpr: test false arm} {expr 2>3?44:66} 66
-test expr-3.6 {CompileCondExpr: error compiling false arm} {oldExprParser} {
- catch {expr 2>3?44:2***3} msg
- set msg
-} {syntax error in expression "2>3?44:2***3": unexpected operator *}
+test expr-3.6 {CompileCondExpr: error compiling false arm} -body {
+ expr 2>3?44:2***3
+} -returnCodes error -match glob -result *
test expr-3.7 {CompileCondExpr: long arms & nested cond exprs} {
hello_world
} {Hello world}
@@ -243,21 +234,18 @@ test expr-3.8 {CompileCondExpr: long arms & nested cond exprs} unix {
} 2358
test expr-4.1 {CompileLorExpr: just land expr} {expr 1.3&&3.3} 1
-test expr-4.2 {CompileLorExpr: error in land expr} -constraints {oldExprParser} -body {
- catch {expr x&&3} msg
- set msg
-} -match glob -result {syntax error in expression "x&&3": *preceding $*}
+test expr-4.2 {CompileLorExpr: error in land expr} -body {
+ expr x&&3
+} -returnCodes error -match glob -result *
test expr-4.3 {CompileLorExpr: simple lor exprs} {expr 0||1.0} 1
test expr-4.4 {CompileLorExpr: simple lor exprs} {expr 3.0||0.0} 1
test expr-4.5 {CompileLorExpr: simple lor exprs} {expr 0||0||1} 1
-test expr-4.6 {CompileLorExpr: error compiling lor arm} {oldExprParser} {
- catch {expr 2***3||4.0} msg
- set msg
-} {syntax error in expression "2***3||4.0": unexpected operator *}
-test expr-4.7 {CompileLorExpr: error compiling lor arm} {oldExprParser} {
- catch {expr 1.3||2***3} msg
- set msg
-} {syntax error in expression "1.3||2***3": unexpected operator *}
+test expr-4.6 {CompileLorExpr: error compiling lor arm} -body {
+ expr 2***3||4.0
+} -returnCodes error -match glob -result *
+test expr-4.7 {CompileLorExpr: error compiling lor arm} -body {
+ expr 1.3||2***3
+} -returnCodes error -match glob -result *
test expr-4.8 {CompileLorExpr: error compiling lor arms} {
list [catch {expr {"a"||"b"}} msg] $msg
} {1 {expected boolean value but got "a"}}
@@ -277,22 +265,19 @@ test expr-4.12 {CompileLorExpr: error compiling land arms} {
} {1 {expected boolean value but got "a"}}
test expr-5.1 {CompileLandExpr: just bitor expr} {expr 7|0x13} 23
-test expr-5.2 {CompileLandExpr: error in bitor expr} -constraints {oldExprParser} -body {
- catch {expr x|3} msg
- set msg
-} -match glob -result {syntax error in expression "x|3": * preceding $*}
+test expr-5.2 {CompileLandExpr: error in bitor expr} -body {
+ expr x|3
+} -returnCodes error -match glob -result *
test expr-5.3 {CompileLandExpr: simple land exprs} {expr 0&&1.0} 0
test expr-5.4 {CompileLandExpr: simple land exprs} {expr 0&&0} 0
test expr-5.5 {CompileLandExpr: simple land exprs} {expr 3.0&&1.2} 1
test expr-5.6 {CompileLandExpr: simple land exprs} {expr 1&&1&&2} 1
-test expr-5.7 {CompileLandExpr: error compiling land arm} {oldExprParser} {
- catch {expr 2***3&&4.0} msg
- set msg
-} {syntax error in expression "2***3&&4.0": unexpected operator *}
-test expr-5.8 {CompileLandExpr: error compiling land arm} {oldExprParser} {
- catch {expr 1.3&&2***3} msg
- set msg
-} {syntax error in expression "1.3&&2***3": unexpected operator *}
+test expr-5.7 {CompileLandExpr: error compiling land arm} -body {
+ expr 2***3&&4.0
+} -returnCodes error -match glob -result *
+test expr-5.8 {CompileLandExpr: error compiling land arm} -body {
+ expr 1.3&&2***3
+} -returnCodes error -match glob -result *
test expr-5.9 {CompileLandExpr: error compiling land arm} {
list [catch {expr {"a"&&"b"}} msg] $msg
} {1 {expected boolean value but got "a"}}
@@ -303,22 +288,19 @@ test expr-5.10 {CompileLandExpr: long land arms} {
} 1
test expr-6.1 {CompileBitXorExpr: just bitand expr} {expr 7&0x13} 3
-test expr-6.2 {CompileBitXorExpr: error in bitand expr} -constraints {oldExprParser} -body {
- catch {expr x|3} msg
- set msg
-} -match glob -result {syntax error in expression "x|3": * preceding $*}
+test expr-6.2 {CompileBitXorExpr: error in bitand expr} -body {
+ expr x|3
+} -returnCodes error -match glob -result *
test expr-6.3 {CompileBitXorExpr: simple bitxor exprs} {expr 7^0x13} 20
test expr-6.4 {CompileBitXorExpr: simple bitxor exprs} {expr 3^0x10} 19
test expr-6.5 {CompileBitXorExpr: simple bitxor exprs} {expr 0^7} 7
test expr-6.6 {CompileBitXorExpr: simple bitxor exprs} {expr -1^7} -8
-test expr-6.7 {CompileBitXorExpr: error compiling bitxor arm} {oldExprParser} {
- catch {expr 2***3|6} msg
- set msg
-} {syntax error in expression "2***3|6": unexpected operator *}
-test expr-6.8 {CompileBitXorExpr: error compiling bitxor arm} -constraints {oldExprParser} -body {
- catch {expr 2^x} msg
- set msg
-} -match glob -result {syntax error in expression "2^x": * preceding $**}
+test expr-6.7 {CompileBitXorExpr: error compiling bitxor arm} -body {
+ expr 2***3|6
+} -returnCodes error -match glob -result *
+test expr-6.8 {CompileBitXorExpr: error compiling bitxor arm} -body {
+ expr 2^x
+} -returnCodes error -match glob -result *
test expr-6.9 {CompileBitXorExpr: runtime error in bitxor arm} {
list [catch {expr {24.0^3}} msg] $msg
} {1 {can't use floating-point value as operand of "^"}}
@@ -330,22 +312,19 @@ test expr-7.1 {CompileBitAndExpr: just equality expr} {expr 3==2} 0
test expr-7.2 {CompileBitAndExpr: just equality expr} {expr 2.0==2} 1
test expr-7.3 {CompileBitAndExpr: just equality expr} {expr 3.2!=2.2} 1
test expr-7.4 {CompileBitAndExpr: just equality expr} {expr {"abc" == "abd"}} 0
-test expr-7.5 {CompileBitAndExpr: error in equality expr} -constraints {oldExprParser} -body {
- catch {expr x==3} msg
- set msg
-} -match glob -result {syntax error in expression "x==3": * preceding $*}
+test expr-7.5 {CompileBitAndExpr: error in equality expr} -body {
+ expr x==3
+} -returnCodes error -match glob -result *
test expr-7.6 {CompileBitAndExpr: simple bitand exprs} {expr 7&0x13} 3
test expr-7.7 {CompileBitAndExpr: simple bitand exprs} {expr 0xf2&0x53} 82
test expr-7.8 {CompileBitAndExpr: simple bitand exprs} {expr 3&6} 2
test expr-7.9 {CompileBitAndExpr: simple bitand exprs} {expr -1&-7} -7
-test expr-7.10 {CompileBitAndExpr: error compiling bitand arm} {oldExprParser} {
- catch {expr 2***3&6} msg
- set msg
-} {syntax error in expression "2***3&6": unexpected operator *}
-test expr-7.11 {CompileBitAndExpr: error compiling bitand arm} -constraints {oldExprParser} -body {
- catch {expr 2&x} msg
- set msg
-} -match glob -result {syntax error in expression "2&x": * preceding $*}
+test expr-7.10 {CompileBitAndExpr: error compiling bitand arm} -body {
+ expr 2***3&6
+} -returnCodes error -match glob -result *
+test expr-7.11 {CompileBitAndExpr: error compiling bitand arm} -body {
+ expr 2&x
+} -returnCodes error -match glob -result *
test expr-7.12 {CompileBitAndExpr: runtime error in bitand arm} {
list [catch {expr {24.0&3}} msg] $msg
} {1 {can't use floating-point value as operand of "&"}}
@@ -354,31 +333,27 @@ test expr-7.13 {CompileBitAndExpr: runtime error in bitand arm} {
} {1 {can't use non-numeric string as operand of "&"}}
test expr-7.14 {CompileBitAndExpr: equality expr} {expr 3eq2} 0
test expr-7.18 {CompileBitAndExpr: equality expr} {expr {"abc" eq "abd"}} 0
-test expr-7.20 {CompileBitAndExpr: error in equality expr} -constraints {oldExprParser} -body {
- catch {expr xne3} msg
- set msg
-} -match glob -result {syntax error in expression "xne3": * preceding $*}
+test expr-7.20 {CompileBitAndExpr: error in equality expr} -body {
+ expr xne3
+} -returnCodes error -match glob -result *
test expr-8.1 {CompileEqualityExpr: just relational expr} {expr 3>=2} 1
test expr-8.2 {CompileEqualityExpr: just relational expr} {expr 2<=2.1} 1
test expr-8.3 {CompileEqualityExpr: just relational expr} {expr 3.2>"2.2"} 1
test expr-8.4 {CompileEqualityExpr: just relational expr} {expr {"0y"<"0x12"}} 0
-test expr-8.5 {CompileEqualityExpr: error in relational expr} -constraints {oldExprParser} -body {
- catch {expr x>3} msg
- set msg
-} -match glob -result {syntax error in expression "x>3": * preceding $*}
+test expr-8.5 {CompileEqualityExpr: error in relational expr} -body {
+ expr x>3
+} -returnCodes error -match glob -result *
test expr-8.6 {CompileEqualityExpr: simple equality exprs} {expr 7==0x13} 0
test expr-8.7 {CompileEqualityExpr: simple equality exprs} {expr -0xf2!=0x53} 1
test expr-8.8 {CompileEqualityExpr: simple equality exprs} {expr {"12398712938788234-1298379" != ""}} 1
test expr-8.9 {CompileEqualityExpr: simple equality exprs} {expr -1!="abc"} 1
-test expr-8.10 {CompileEqualityExpr: error compiling equality arm} {oldExprParser} {
- catch {expr 2***3==6} msg
- set msg
-} {syntax error in expression "2***3==6": unexpected operator *}
-test expr-8.11 {CompileEqualityExpr: error compiling equality arm} -constraints {oldExprParser} -body {
- catch {expr 2!=x} msg
- set msg
-} -match glob -result {syntax error in expression "2!=x": * preceding $*}
+test expr-8.10 {CompileEqualityExpr: error compiling equality arm} -body {
+ expr 2***3==6
+} -returnCodes error -match glob -result *
+test expr-8.11 {CompileEqualityExpr: error compiling equality arm} -body {
+ expr 2!=x
+} -returnCodes error -match glob -result *
test expr-8.12 {CompileBitAndExpr: equality expr} {expr {"a"eq"a"}} 1
test expr-8.13 {CompileBitAndExpr: equality expr} {expr {"\374" eq "ü"}} 1
test expr-8.14 {CompileBitAndExpr: equality expr} {expr 3eq2} 0
@@ -387,23 +362,19 @@ test expr-8.16 {CompileBitAndExpr: equality expr} {expr 3.2ne2.2} 1
test expr-8.17 {CompileBitAndExpr: equality expr} {expr 01eq1} 0
test expr-8.18 {CompileBitAndExpr: equality expr} {expr {"abc" eq "abd"}} 0
test expr-8.19 {CompileBitAndExpr: equality expr} {expr {"abc" ne "abd"}} 1
-test expr-8.20 {CompileBitAndExpr: error in equality expr} -constraints {oldExprParser} -body {
- catch {expr x ne3} msg
- set msg
-} -match glob -result {syntax error in expression "x ne3": * preceding $*}
-test expr-8.21 {CompileBitAndExpr: error in equality expr} -constraints {oldExprParser} -body {
+test expr-8.20 {CompileBitAndExpr: error in equality expr} -body {
+ expr x ne3
+} -returnCodes error -match glob -result *
+test expr-8.21 {CompileBitAndExpr: error in equality expr} -body {
# These should be ""ed to avoid the error
- catch {expr a eq b} msg
- set msg
-} -match glob -result {syntax error in expression "a eq b": * preceding $*}
-test expr-8.22 {CompileBitAndExpr: error in equality expr} {oldExprParser} {
- catch {expr {false eqfalse}} msg
- set msg
-} {syntax error in expression "false eqfalse": extra tokens at end of expression}
-test expr-8.23 {CompileBitAndExpr: error in equality expr} {oldExprParser} {
- catch {expr {false nefalse}} msg
- set msg
-} {syntax error in expression "false nefalse": extra tokens at end of expression}
+ expr a eq b
+} -returnCodes error -match glob -result *
+test expr-8.22 {CompileBitAndExpr: error in equality expr} -body {
+ expr {false eqfalse}
+} -returnCodes error -match glob -result *
+test expr-8.23 {CompileBitAndExpr: error in equality expr} -body {
+ expr {false nefalse}
+} -returnCodes error -match glob -result *
test expr-8.24 {CompileEqualityExpr: simple equality exprs} {
set x 12398712938788234
expr {$x == 100}
@@ -429,21 +400,21 @@ test expr-8.29 {CompileEqualityExpr: just relational expr} {
test expr-8.30 {CompileEqualityExpr: simple equality exprs} {
expr {"fake" != "bob"}
} 1
-test expr-8.31 {expr edge cases} {oldExprParser} {
- list [catch {expr {1e}} err] $err
-} {1 {syntax error in expression "1e": extra tokens at end of expression}}
-test expr-8.32 {expr edge cases} {oldExprParser} {
- list [catch {expr {1E}} err] $err
-} {1 {syntax error in expression "1E": extra tokens at end of expression}}
-test expr-8.33 {expr edge cases} {oldExprParser} {
- list [catch {expr {1e+}} err] $err
-} {1 {syntax error in expression "1e+": extra tokens at end of expression}}
-test expr-8.34 {expr edge cases} {oldExprParser} {
- list [catch {expr {1E+}} err] $err
-} {1 {syntax error in expression "1E+": extra tokens at end of expression}}
-test expr-8.35 {expr edge cases} {oldExprParser} {
- list [catch {expr {1ea}} err] $err
-} {1 {syntax error in expression "1ea": extra tokens at end of expression}}
+test expr-8.31 {expr edge cases} -body {
+ expr {1e}
+} -returnCodes error -match glob -result *
+test expr-8.32 {expr edge cases} -body {
+ expr {1E}
+} -returnCodes error -match glob -result *
+test expr-8.33 {expr edge cases} -body {
+ expr {1e+}
+} -returnCodes error -match glob -result *
+test expr-8.34 {expr edge cases} -body {
+ expr {1E+}
+} -returnCodes error -match glob -result *
+test expr-8.35 {expr edge cases} -body {
+ expr {1ea}
+} -returnCodes error -match glob -result *
test expr-9.1 {CompileRelationalExpr: just shift expr} {expr 3<<2} 12
test expr-9.2 {CompileRelationalExpr: just shift expr} {expr 0xff>>2} 63
@@ -455,39 +426,33 @@ test expr-9.5a {CompileRelationalExpr: shift expr producing LONG_MIN} longIs64bi
test expr-9.5b {CompileRelationalExpr: shift expr producing LONG_MIN} longIs32bit {
expr {int(1<<31)}
} -2147483648
-test expr-9.6 {CompileRelationalExpr: error in shift expr} -constraints {oldExprParser} -body {
- catch {expr x>>3} msg
- set msg
-} -match glob -result {syntax error in expression "x>>3": * preceding $*}
+test expr-9.6 {CompileRelationalExpr: error in shift expr} -body {
+ expr x>>3
+} -returnCodes error -match glob -result *
test expr-9.7 {CompileRelationalExpr: simple relational exprs} {expr 0xff>=+0x3} 1
test expr-9.8 {CompileRelationalExpr: simple relational exprs} {expr -0xf2<0x3} 1
-test expr-9.9 {CompileRelationalExpr: error compiling relational arm} {oldExprParser} {
- catch {expr 2***3>6} msg
- set msg
-} {syntax error in expression "2***3>6": unexpected operator *}
-test expr-9.10 {CompileRelationalExpr: error compiling relational arm} -constraints {oldExprParser} -body {
- catch {expr 2<x} msg
- set msg
-} -match glob -result {syntax error in expression "2<x": * preceding $*}
+test expr-9.9 {CompileRelationalExpr: error compiling relational arm} -body {
+ expr 2***3>6
+} -returnCodes error -match glob -result *
+test expr-9.10 {CompileRelationalExpr: error compiling relational arm} -body {
+ expr 2<x
+} -returnCodes error -match glob -result *
test expr-10.1 {CompileShiftExpr: just add expr} {expr 4+-2} 2
test expr-10.2 {CompileShiftExpr: just add expr} {expr 0xff-2} 253
test expr-10.3 {CompileShiftExpr: just add expr} {expr -1--2} 1
test expr-10.4 {CompileShiftExpr: just add expr} {expr 1-0123} -82
-test expr-10.5 {CompileShiftExpr: error in add expr} -constraints {oldExprParser} -body {
- catch {expr x+3} msg
- set msg
-} -match glob -result {syntax error in expression "x+3": * preceding $*}
+test expr-10.5 {CompileShiftExpr: error in add expr} -body {
+ expr x+3
+} -returnCodes error -match glob -result *
test expr-10.6 {CompileShiftExpr: simple shift exprs} {expr 0xff>>0x3} 31
test expr-10.7 {CompileShiftExpr: simple shift exprs} {expr -0xf2<<0x3} -1936
-test expr-10.8 {CompileShiftExpr: error compiling shift arm} {oldExprParser} {
- catch {expr 2***3>>6} msg
- set msg
-} {syntax error in expression "2***3>>6": unexpected operator *}
-test expr-10.9 {CompileShiftExpr: error compiling shift arm} -constraints {oldExprParser} -body {
- catch {expr 2<<x} msg
- set msg
-} -match glob -result {syntax error in expression "2<<x": * preceding $*}
+test expr-10.8 {CompileShiftExpr: error compiling shift arm} -body {
+ expr 2***3>>6
+} -returnCodes error -match glob -result *
+test expr-10.9 {CompileShiftExpr: error compiling shift arm} -body {
+ expr 2<<x
+} -returnCodes error -match glob -result *
test expr-10.10 {CompileShiftExpr: runtime error} {
list [catch {expr {24.0>>43}} msg] $msg
} {1 {can't use floating-point value as operand of ">>"}}
@@ -499,20 +464,17 @@ test expr-11.1 {CompileAddExpr: just multiply expr} {expr 4*-2} -8
test expr-11.2 {CompileAddExpr: just multiply expr} {expr 0xff%2} 1
test expr-11.3 {CompileAddExpr: just multiply expr} {expr -1/2} -1
test expr-11.4 {CompileAddExpr: just multiply expr} {expr 7891%0123} 6
-test expr-11.5 {CompileAddExpr: error in multiply expr} -constraints {oldExprParser} -body {
- catch {expr x*3} msg
- set msg
-} -match glob -result {syntax error in expression "x*3": * preceding $*}
+test expr-11.5 {CompileAddExpr: error in multiply expr} -body {
+ expr x*3
+} -returnCodes error -match glob -result *
test expr-11.6 {CompileAddExpr: simple add exprs} {expr 0xff++0x3} 258
test expr-11.7 {CompileAddExpr: simple add exprs} {expr -0xf2--0x3} -239
-test expr-11.8 {CompileAddExpr: error compiling add arm} {oldExprParser} {
- catch {expr 2***3+6} msg
- set msg
-} {syntax error in expression "2***3+6": unexpected operator *}
-test expr-11.9 {CompileAddExpr: error compiling add arm} -constraints {oldExprParser} -body {
- catch {expr 2-x} msg
- set msg
-} -match glob -result {syntax error in expression "2-x": * preceding $*}
+test expr-11.8 {CompileAddExpr: error compiling add arm} -body {
+ expr 2***3+6
+} -returnCodes error -match glob -result *
+test expr-11.9 {CompileAddExpr: error compiling add arm} -body {
+ expr 2-x
+} -returnCodes error -match glob -result *
test expr-11.10 {CompileAddExpr: runtime error} {
list [catch {expr {24.0+"xx"}} msg] $msg
} {1 {can't use non-numeric string as operand of "+"}}
@@ -533,20 +495,17 @@ test expr-12.1 {CompileMultiplyExpr: just unary expr} {expr ~4} -5
test expr-12.2 {CompileMultiplyExpr: just unary expr} {expr --5} 5
test expr-12.3 {CompileMultiplyExpr: just unary expr} {expr !27} 0
test expr-12.4 {CompileMultiplyExpr: just unary expr} {expr ~0xff00ff} -16711936
-test expr-12.5 {CompileMultiplyExpr: error in unary expr} -constraints {oldExprParser} -body {
- catch {expr ~x} msg
- set msg
-} -match glob -result {syntax error in expression "~x": * preceding $*}
+test expr-12.5 {CompileMultiplyExpr: error in unary expr} -body {
+ expr ~x
+} -returnCodes error -match glob -result *
test expr-12.6 {CompileMultiplyExpr: simple multiply exprs} {expr 0xff*0x3} 765
test expr-12.7 {CompileMultiplyExpr: simple multiply exprs} {expr -0xf2%-0x3} -2
-test expr-12.8 {CompileMultiplyExpr: error compiling multiply arm} {oldExprParser} {
- catch {expr 2*3%%6} msg
- set msg
-} {syntax error in expression "2*3%%6": unexpected operator %}
-test expr-12.9 {CompileMultiplyExpr: error compiling multiply arm} -constraints {oldExprParser} -body {
- catch {expr 2*x} msg
- set msg
-} -match glob -result {syntax error in expression "2*x": * preceding $*}
+test expr-12.8 {CompileMultiplyExpr: error compiling multiply arm} -body {
+ expr 2*3%%6
+} -returnCodes error -match glob -result *
+test expr-12.9 {CompileMultiplyExpr: error compiling multiply arm} -body {
+ expr 2*x
+} -returnCodes error -match glob -result *
test expr-12.10 {CompileMultiplyExpr: runtime error} {
list [catch {expr {24.0*"xx"}} msg] $msg
} {1 {can't use non-numeric string as operand of "*"}}
@@ -561,14 +520,12 @@ test expr-13.4 {CompileUnaryExpr: unary exprs} {expr !2} 0
test expr-13.5 {CompileUnaryExpr: unary exprs} {expr +--+-62.0} -62.0
test expr-13.6 {CompileUnaryExpr: unary exprs} {expr !0.0} 1
test expr-13.7 {CompileUnaryExpr: unary exprs} {expr !0xef} 0
-test expr-13.8 {CompileUnaryExpr: error compiling unary expr} -constraints {oldExprParser} -body {
- catch {expr ~x} msg
- set msg
-} -match glob -result {syntax error in expression "~x": * preceding $*}
-test expr-13.9 {CompileUnaryExpr: error compiling unary expr} {oldExprParser} {
- catch {expr !1.x} msg
- set msg
-} {syntax error in expression "!1.x": extra tokens at end of expression}
+test expr-13.8 {CompileUnaryExpr: error compiling unary expr} -body {
+ expr ~x
+} -returnCodes error -match glob -result *
+test expr-13.9 {CompileUnaryExpr: error compiling unary expr} -body {
+ expr !1.x
+} -returnCodes error -match glob -result *
test expr-13.10 {CompileUnaryExpr: runtime error} {
list [catch {expr {~"xx"}} msg] $msg
} {1 {can't use non-numeric string as operand of "~"}}
@@ -633,15 +590,12 @@ test expr-14.15 {CompilePrimaryExpr: var reference primary} {
catch {expr $i.2} msg
set msg
} 123.2
-test expr-14.16 {CompilePrimaryExpr: error compiling var reference primary} -constraints {oldExprParser} -body {
- catch {expr {$a(foo}} msg
- set errorInfo
-} -match glob -result {missing )
- while *ing
-"expr {$a(foo}"}
-test expr-14.17 {CompilePrimaryExpr: string primary that looks like var ref} {oldExprParser} {
+test expr-14.16 {CompilePrimaryExpr: error compiling var reference primary} -body {
+ expr {$a(foo}
+} -returnCodes error -match glob -result *
+test expr-14.17 {CompilePrimaryExpr: string primary that looks like var ref} -body {
expr $
-} $
+} -returnCodes error -match glob -result *
test expr-14.18 {CompilePrimaryExpr: quoted string primary} {
expr "21"
} 21
@@ -668,24 +622,18 @@ test expr-14.23 {CompilePrimaryExpr: error in subcommand primary} -body {
} -match glob -result {wrong # args: should be "set varName ?newValue?"
while *ing
"set"*}
-test expr-14.24 {CompilePrimaryExpr: error in subcommand primary} -constraints {oldExprParser} -body {
- catch {expr {[set i}} msg
- set errorInfo
-} -match glob -result {missing close-bracket
- while *ing
-"expr {\[set i}"}
+test expr-14.24 {CompilePrimaryExpr: error in subcommand primary} -body {
+ expr {[set i}
+} -returnCodes error -match glob -result *
test expr-14.25 {CompilePrimaryExpr: math function primary} {
format %.6g [expr exp(1.0)]
} 2.71828
test expr-14.26 {CompilePrimaryExpr: math function primary} {
format %.6g [expr pow(2.0+0.1,3.0+0.1)]
} 9.97424
-test expr-14.27 {CompilePrimaryExpr: error in math function primary} -constraints {oldExprParser} -body {
- catch {expr sinh::(2.0)} msg
- set errorInfo
-} -match glob -result {syntax error in expression "sinh::(2.0)": * function arguments*
- while *ing
-"expr sinh::(2.0)"}
+test expr-14.27 {CompilePrimaryExpr: error in math function primary} -body {
+ expr sinh::(2.0)
+} -returnCodes error -match glob -result *
test expr-14.28 {CompilePrimaryExpr: subexpression primary} {
expr 2+(3*4)
} 14
@@ -695,29 +643,20 @@ test expr-14.29 {CompilePrimaryExpr: error in subexpression primary} -body {
} -match glob -result {wrong # args: should be "set varName ?newValue?"
while *ing
"set"*}
-test expr-14.30 {CompilePrimaryExpr: missing paren in subexpression primary} -constraints {oldExprParser} -body {
- catch {expr 2+(3*(4+5)} msg
- set errorInfo
-} -match glob -result {syntax error in expression "2+(3*(4+5)": looking for close parenthesis
- while *ing
-"expr 2+(3*(4+5)"}
+test expr-14.30 {CompilePrimaryExpr: missing paren in subexpression primary} -body {
+ expr 2+(3*(4+5)
+} -returnCodes error -match glob -result *
test expr-14.31 {CompilePrimaryExpr: just var ref in subexpression primary} {
set i "5+10"
list "[expr $i] == 15" "[expr ($i)] == 15" "[eval expr ($i)] == 15"
} {{15 == 15} {15 == 15} {15 == 15}}
-test expr-14.32 {CompilePrimaryExpr: unexpected token} -constraints {oldExprParser} -body {
- catch {expr @} msg
- set errorInfo
-} -match glob -result {syntax error in expression "@": character not legal in expressions
- while *ing
-"expr @"}
+test expr-14.32 {CompilePrimaryExpr: unexpected token} -body {
+ expr @
+} -returnCodes error -match glob -result *
-test expr-15.1 {CompileMathFuncCall: missing parenthesis} -constraints {oldExprParser} -body {
- catch {expr sinh2.0)} msg
- set errorInfo
-} -match glob -result {syntax error in expression "sinh2.0)": * preceding $*
- while *ing
-"expr sinh2.0)"}
+test expr-15.1 {CompileMathFuncCall: missing parenthesis} -body {
+ expr sinh2.0)
+} -returnCodes error -match glob -result *
test expr-15.2 {CompileMathFuncCall: unknown math function} -body {
catch {expr whazzathuh(1)} msg
set errorInfo
@@ -742,12 +681,9 @@ test expr-15.5 {CompileMathFuncCall: too few arguments} -body {
} -match glob -result {too few arguments for math function*
while *ing
"expr pow(1)"}
-test expr-15.6 {CompileMathFuncCall: missing ')'} -constraints {oldExprParser} -body {
- catch {expr sin(1} msg
- set errorInfo
-} -match glob -result {syntax error in expression "sin(1": missing close parenthesis at end of function call
- while *ing
-"expr sin(1"}
+test expr-15.6 {CompileMathFuncCall: missing ')'} -body {
+ expr sin(1
+} -returnCodes error -match glob -result *
test expr-15.7 {CompileMathFuncCall: call registered math function} {testmathfunctions} {
expr 2*T1()
} 246
@@ -851,7 +787,7 @@ test expr-20.1 {wrong brace matching} {
set cmd "expr $l$q|$q == $q$r$q$r"
list [catch $cmd a] $a
} {1 {extra characters after close-brace}}
-test expr-20.2 {double invocation of variable traces} {oldExprParser} {
+test expr-20.2 {double invocation of variable traces} -body {
set exprtracecounter 0
proc exprtraceproc {args} {
upvar #0 exprtracecounter counter
@@ -869,7 +805,7 @@ test expr-20.2 {double invocation of variable traces} {oldExprParser} {
list [catch {expr "$exprtracevar + 20"} a] $a \
[catch {expr "$exprtracevar + 20"} b] $b \
[unset exprtracevar exprtracecounter]
-} {1 {syntax error in expression "1 oops 10 + 20": extra tokens at end of expression} 0 32 {}}
+} -match glob -result {1 * 0 32 {}}
test expr-20.3 {broken substitution of integer digits} {
# fails with 8.0.x, but not 8.1b2
list [set a 000; expr 0x1$a] [set a 1; expr ${a}000]
@@ -902,9 +838,9 @@ test expr-21.9 {non-numeric boolean literals} {expr !off } 1
test expr-21.10 {non-numeric boolean literals} {expr !on } 0
test expr-21.11 {non-numeric boolean literals} {expr !no } 1
test expr-21.12 {non-numeric boolean literals} {expr !yes } 0
-test expr-21.13 {non-numeric boolean literals} {oldExprParser} {
- list [catch {expr !truef} err] $err
-} {1 {syntax error in expression "!truef": the word "truef" requires a preceding $ if it's a variable or function arguments if it's a function}}
+test expr-21.13 {non-numeric boolean literals} -body {
+ expr !truef
+} -returnCodes error -match glob -result *
test expr-21.14 {non-numeric boolean literals} {
list [catch {expr !"truef"} err] $err
} {1 {can't use non-numeric string as operand of "!"}}
@@ -979,19 +915,16 @@ test expr-23.1 {CompileExponentialExpr: just exponential expr} {expr 4**2} 16
test expr-23.2 {CompileExponentialExpr: just exponential expr} {expr 0xff**2} 65025
test expr-23.3 {CompileExponentialExpr: just exponential expr} {expr -1**2} 1
test expr-23.4 {CompileExponentialExpr: just exponential expr} {expr 18**07} 612220032
-test expr-23.5 {CompileExponentialExpr: error in exponential expr} -constraints {oldExprParser} -body {
- catch {expr x**3} msg
- set msg
-} -match glob -result {syntax error in expression "x**3": * preceding $*}
+test expr-23.5 {CompileExponentialExpr: error in exponential expr} -body {
+ expr x**3
+} -returnCodes error -match glob -result *
test expr-23.6 {CompileExponentialExpr: simple expo exprs} {expr 0xff**0x3} 16581375
-test expr-23.7 {CompileExponentialExpr: error compiling expo arm} {oldExprParser} {
- catch {expr (-3-)**6} msg
- set msg
-} {syntax error in expression "(-3-)**6": unexpected close parenthesis}
-test expr-23.8 {CompileExponentialExpr: error compiling expo arm} -constraints {oldExprParser} -body {
- catch {expr 2**x} msg
- set msg
-} -match glob -result {syntax error in expression "2**x": * preceding $*}
+test expr-23.7 {CompileExponentialExpr: error compiling expo arm} -body {
+ expr (-3-)**6
+} -returnCodes error -match glob -result *
+test expr-23.8 {CompileExponentialExpr: error compiling expo arm} -body {
+ expr 2**x
+} -returnCodes error -match glob -result *
test expr-23.9 {CompileExponentialExpr: runtime error} {
list [catch {expr {24.0**"xx"}} msg] $msg
} {1 {can't use non-numeric string as operand of "**"}}
@@ -6277,12 +6210,10 @@ test expr-39.2 {Tcl_ExprLongObj handles wide ints gracefully} testexprlongobj {
} {This is a result: 3}
test expr-39.3 {Tcl_ExprLongObj on the empty string} \
- -constraints {testexprlongobj oldExprParser}\
- -body {
- list [catch {testexprlongobj ""} result] $result
- } \
+ -constraints {testexprlongobj}\
+ -body {testexprlongobj ""} \
-match glob \
- -result {1 {syntax error*}}
+ -returnCodes error -result *
test expr-39.4 {Tcl_ExprLongObj coerces doubles} testexprlongobj {
testexprlongobj 3+.14159
} {This is a result: 3}
@@ -6344,12 +6275,10 @@ test expr-39.17 {Check that Tcl_ExprDoubleObj doesn't modify interpreter result
} {This is a result: 5.0}
#Check for [Bug 1109484]
test expr-39.18 {Tcl_ExprDoubleObj on the empty string} \
- -constraints {testexprdoubleobj oldExprParser} \
+ -constraints {testexprdoubleobj} \
-match glob \
- -body {
- list [catch {testexprdoubleobj ""} result] $result
- } \
- -result {1 {syntax error*}}
+ -body {testexprdoubleobj ""} \
+ -returnCodes error -result *
test expr-39.19 {Tcl_ExprDoubleObj coerces wides} testexprdoubleobj {
testexprdoubleobj 1[string repeat 0 17]
} {This is a result: 1e+17}
@@ -6373,7 +6302,7 @@ test expr-39.24 {Tcl_ExprDoubleObj handles overflows that look like int} \
testexprdoubleobj 17976931348623165[string repeat 0 292]
} {This is a result: Inf}
test expr-39.25 {Tcl_ExprDoubleObj and NaN} \
- {testexprdoubleobj ieeeFloatingPoint oldExprParser} {
+ {testexprdoubleobj ieeeFloatingPoint} {
list [catch {testexprdoubleobj 0.0/0.0} result] $result
} {1 {floating point value is Not a Number}}