diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2001-12-04 15:36:29 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2001-12-04 15:36:29 (GMT) |
commit | 5135eae0433e9c4fb96153356cce8f29f72c09a8 (patch) | |
tree | 274a2df1f90321771b312de400142f588d5eb264 /tests/expr.test | |
parent | 1b5d4aa57d4fd6ffb21d7f5a0c08567eb0959714 (diff) | |
download | tcl-5135eae0433e9c4fb96153356cce8f29f72c09a8.zip tcl-5135eae0433e9c4fb96153356cce8f29f72c09a8.tar.gz tcl-5135eae0433e9c4fb96153356cce8f29f72c09a8.tar.bz2 |
Improved messages produced on getting a syntax error in an expression
Diffstat (limited to 'tests/expr.test')
-rw-r--r-- | tests/expr.test | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/tests/expr.test b/tests/expr.test index b4487e3..2233e53 100644 --- a/tests/expr.test +++ b/tests/expr.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: expr.test,v 1.12 2001/04/09 09:48:41 dkf Exp $ +# RCS: @(#) $Id: expr.test,v 1.13 2001/12/04 15:36:29 dkf Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -138,11 +138,11 @@ test expr-2.1 {TclCompileExpr: are builtin functions registered?} { test expr-2.2 {TclCompileExpr: error in expr} { catch {expr 2**3} msg set msg -} {syntax error in expression "2**3"} +} {syntax error in expression "2**3": unexpected operator} test expr-2.3 {TclCompileExpr: junk after legal expr} { catch {expr 7*[llength "a b"]foo} msg set msg -} {syntax error in expression "7*2foo"} +} {syntax error in expression "7*2foo": extra tokens at end of expression} test expr-2.4 {TclCompileExpr: numeric expr string rep == formatted int rep} { expr {0001} } 1 @@ -151,17 +151,17 @@ test expr-3.1 {CompileCondExpr: just lor expr} {expr 3||0} 1 test expr-3.2 {CompileCondExpr: error in lor expr} { catch {expr x||3} msg set msg -} {syntax error in expression "x||3"} +} {syntax error in expression "x||3": expected a parenthesis enclosing function arguments} test expr-3.3 {CompileCondExpr: test true arm} {expr 3>2?44:66} 44 test expr-3.4 {CompileCondExpr: error compiling true arm} { catch {expr 3>2?2**3:66} msg set msg -} {syntax error in expression "3>2?2**3:66"} +} {syntax error in expression "3>2?2**3:66": unexpected operator} test expr-3.5 {CompileCondExpr: test false arm} {expr 2>3?44:66} 66 test expr-3.6 {CompileCondExpr: error compiling false arm} { catch {expr 2>3?44:2**3} msg set msg -} {syntax error in expression "2>3?44:2**3"} +} {syntax error in expression "2>3?44:2**3": unexpected operator} test expr-3.7 {CompileCondExpr: long arms & nested cond exprs} {unixOnly nonPortable} { puts "Note: doing test expr-3.7 which can take several minutes to run" hello_world @@ -177,18 +177,18 @@ test expr-4.1 {CompileLorExpr: just land expr} {expr 1.3&&3.3} 1 test expr-4.2 {CompileLorExpr: error in land expr} { catch {expr x&&3} msg set msg -} {syntax error in expression "x&&3"} +} {syntax error in expression "x&&3": expected a parenthesis enclosing function arguments} 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} { catch {expr 2**3||4.0} msg set msg -} {syntax error in expression "2**3||4.0"} +} {syntax error in expression "2**3||4.0": unexpected operator} test expr-4.7 {CompileLorExpr: error compiling lor arm} { catch {expr 1.3||2**3} msg set msg -} {syntax error in expression "1.3||2**3"} +} {syntax error in expression "1.3||2**3": unexpected operator} test expr-4.8 {CompileLorExpr: error compiling lor arms} { list [catch {expr {"a"||"b"}} msg] $msg } {1 {expected boolean value but got "a"}} @@ -202,7 +202,7 @@ test expr-5.1 {CompileLandExpr: just bitor expr} {expr 7|0x13} 23 test expr-5.2 {CompileLandExpr: error in bitor expr} { catch {expr x|3} msg set msg -} {syntax error in expression "x|3"} +} {syntax error in expression "x|3": expected a parenthesis enclosing function arguments} 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 @@ -210,11 +210,11 @@ test expr-5.6 {CompileLandExpr: simple land exprs} {expr 1&&1&&2} 1 test expr-5.7 {CompileLandExpr: error compiling land arm} { catch {expr 2**3&&4.0} msg set msg -} {syntax error in expression "2**3&&4.0"} +} {syntax error in expression "2**3&&4.0": unexpected operator} test expr-5.8 {CompileLandExpr: error compiling land arm} { catch {expr 1.3&&2**3} msg set msg -} {syntax error in expression "1.3&&2**3"} +} {syntax error in expression "1.3&&2**3": unexpected operator} test expr-5.9 {CompileLandExpr: error compiling land arm} { list [catch {expr {"a"&&"b"}} msg] $msg } {1 {expected boolean value but got "a"}} @@ -228,7 +228,7 @@ test expr-6.1 {CompileBitXorExpr: just bitand expr} {expr 7&0x13} 3 test expr-6.2 {CompileBitXorExpr: error in bitand expr} { catch {expr x|3} msg set msg -} {syntax error in expression "x|3"} +} {syntax error in expression "x|3": expected a parenthesis enclosing function arguments} 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 @@ -236,11 +236,11 @@ test expr-6.6 {CompileBitXorExpr: simple bitxor exprs} {expr -1^7} -8 test expr-6.7 {CompileBitXorExpr: error compiling bitxor arm} { catch {expr 2**3|6} msg set msg -} {syntax error in expression "2**3|6"} +} {syntax error in expression "2**3|6": unexpected operator} test expr-6.8 {CompileBitXorExpr: error compiling bitxor arm} { catch {expr 2^x} msg set msg -} {syntax error in expression "2^x"} +} {syntax error in expression "2^x": expected a parenthesis enclosing function arguments} 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 "^"}} @@ -255,7 +255,7 @@ test expr-7.4 {CompileBitAndExpr: just equality expr} {expr {"abc" == "abd"}} 0 test expr-7.5 {CompileBitAndExpr: error in equality expr} { catch {expr x==3} msg set msg -} {syntax error in expression "x==3"} +} {syntax error in expression "x==3": expected a parenthesis enclosing function arguments} 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 @@ -263,11 +263,11 @@ test expr-7.9 {CompileBitAndExpr: simple bitand exprs} {expr -1&-7} -7 test expr-7.10 {CompileBitAndExpr: error compiling bitand arm} { catch {expr 2**3&6} msg set msg -} {syntax error in expression "2**3&6"} +} {syntax error in expression "2**3&6": unexpected operator} test expr-7.11 {CompileBitAndExpr: error compiling bitand arm} { catch {expr 2&x} msg set msg -} {syntax error in expression "2&x"} +} {syntax error in expression "2&x": expected a parenthesis enclosing function arguments} 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 "&"}} @@ -279,7 +279,7 @@ test expr-7.18 {CompileBitAndExpr: equality expr} {expr {"abc" eq "abd"}} 0 test expr-7.20 {CompileBitAndExpr: error in equality expr} { catch {expr xne3} msg set msg -} {syntax error in expression "xne3"} +} {syntax error in expression "xne3": expected a parenthesis enclosing function arguments} 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 @@ -288,7 +288,7 @@ test expr-8.4 {CompileEqualityExpr: just relational expr} {expr {"0y"<"0x12"}} 0 test expr-8.5 {CompileEqualityExpr: error in relational expr} { catch {expr x>3} msg set msg -} {syntax error in expression "x>3"} +} {syntax error in expression "x>3": expected a parenthesis enclosing function arguments} 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 @@ -296,11 +296,11 @@ test expr-8.9 {CompileEqualityExpr: simple equality exprs} {expr -1!="abc"} 1 test expr-8.10 {CompileEqualityExpr: error compiling equality arm} { catch {expr 2**3==6} msg set msg -} {syntax error in expression "2**3==6"} +} {syntax error in expression "2**3==6": unexpected operator} test expr-8.11 {CompileEqualityExpr: error compiling equality arm} { catch {expr 2!=x} msg set msg -} {syntax error in expression "2!=x"} +} {syntax error in expression "2!=x": expected a parenthesis enclosing function arguments} test expr-8.14 {CompileBitAndExpr: equality expr} {expr {"a"eq"a"}} 1 test expr-8.14 {CompileBitAndExpr: equality expr} {expr {"\374" eq "ü"}} 1 test expr-8.14 {CompileBitAndExpr: equality expr} {expr 3eq2} 0 @@ -310,14 +310,14 @@ 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} { - catch {expr xne3} msg + catch {expr x ne3} msg set msg -} {syntax error in expression "xne3"} -test expr-8.20 {CompileBitAndExpr: error in equality expr} { +} {syntax error in expression "x ne3": expected a parenthesis enclosing function arguments} +test expr-8.21 {CompileBitAndExpr: error in equality expr} { # These should be ""ed to avoid the error catch {expr a eq b} msg set msg -} {syntax error in expression "a eq b"} +} {syntax error in expression "a eq b": expected a parenthesis enclosing function arguments} test expr-9.1 {CompileRelationalExpr: just shift expr} {expr 3<<2} 12 test expr-9.2 {CompileRelationalExpr: just shift expr} {expr 0xff>>2} 63 @@ -339,17 +339,17 @@ if {0x80000000 > 0} { test expr-9.6 {CompileRelationalExpr: error in shift expr} { catch {expr x>>3} msg set msg -} {syntax error in expression "x>>3"} +} {syntax error in expression "x>>3": expected a parenthesis enclosing function arguments} 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} { catch {expr 2**3>6} msg set msg -} {syntax error in expression "2**3>6"} +} {syntax error in expression "2**3>6": unexpected operator} test expr-9.10 {CompileRelationalExpr: error compiling relational arm} { catch {expr 2<x} msg set msg -} {syntax error in expression "2<x"} +} {syntax error in expression "2<x": expected a parenthesis enclosing function arguments} test expr-10.1 {CompileShiftExpr: just add expr} {expr 4+-2} 2 test expr-10.2 {CompileShiftExpr: just add expr} {expr 0xff-2} 253 @@ -358,17 +358,17 @@ test expr-10.4 {CompileShiftExpr: just add expr} {expr 1-0123} -82 test expr-10.5 {CompileShiftExpr: error in add expr} { catch {expr x+3} msg set msg -} {syntax error in expression "x+3"} +} {syntax error in expression "x+3": expected a parenthesis enclosing function arguments} 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} { catch {expr 2**3>>6} msg set msg -} {syntax error in expression "2**3>>6"} +} {syntax error in expression "2**3>>6": unexpected operator} test expr-10.9 {CompileShiftExpr: error compiling shift arm} { catch {expr 2<<x} msg set msg -} {syntax error in expression "2<<x"} +} {syntax error in expression "2<<x": expected a parenthesis enclosing function arguments} 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 ">>"}} @@ -383,17 +383,17 @@ test expr-11.4 {CompileAddExpr: just multiply expr} {expr 7891%0123} 6 test expr-11.5 {CompileAddExpr: error in multiply expr} { catch {expr x*3} msg set msg -} {syntax error in expression "x*3"} +} {syntax error in expression "x*3": expected a parenthesis enclosing function arguments} 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} { catch {expr 2**3+6} msg set msg -} {syntax error in expression "2**3+6"} +} {syntax error in expression "2**3+6": unexpected operator} test expr-11.9 {CompileAddExpr: error compiling add arm} { catch {expr 2-x} msg set msg -} {syntax error in expression "2-x"} +} {syntax error in expression "2-x": expected a parenthesis enclosing function arguments} 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 "+"}} @@ -414,17 +414,17 @@ test expr-12.4 {CompileMultiplyExpr: just unary expr} {expr ~0xff00ff} -16711936 test expr-12.5 {CompileMultiplyExpr: error in unary expr} { catch {expr ~x} msg set msg -} {syntax error in expression "~x"} +} {syntax error in expression "~x": expected a parenthesis enclosing function arguments} 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} { catch {expr 2*3%%6} msg set msg -} {syntax error in expression "2*3%%6"} +} {syntax error in expression "2*3%%6": unexpected operator} test expr-12.9 {CompileMultiplyExpr: error compiling multiply arm} { catch {expr 2*x} msg set msg -} {syntax error in expression "2*x"} +} {syntax error in expression "2*x": expected a parenthesis enclosing function arguments} 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 "*"}} @@ -442,11 +442,11 @@ test expr-13.7 {CompileUnaryExpr: unary exprs} {expr !0xef} 0 test expr-13.8 {CompileUnaryExpr: error compiling unary expr} { catch {expr ~x} msg set msg -} {syntax error in expression "~x"} +} {syntax error in expression "~x": expected a parenthesis enclosing function arguments} test expr-13.9 {CompileUnaryExpr: error compiling unary expr} { catch {expr !1.x} msg set msg -} {syntax error in expression "!1.x"} +} {syntax error in expression "!1.x": extra tokens at end of expression} test expr-13.10 {CompileUnaryExpr: runtime error} { list [catch {expr {~"xx"}} msg] $msg } {1 {can't use non-numeric string as operand of "~"}} @@ -563,7 +563,7 @@ test expr-14.26 {CompilePrimaryExpr: math function primary} { test expr-14.27 {CompilePrimaryExpr: error in math function primary} { catch {expr sinh::(2.0)} msg set errorInfo -} {syntax error in expression "sinh::(2.0)" +} {syntax error in expression "sinh::(2.0)": expected a parenthesis enclosing function arguments while compiling "expr sinh::(2.0)"} test expr-14.28 {CompilePrimaryExpr: subexpression primary} { @@ -580,7 +580,7 @@ test expr-14.29 {CompilePrimaryExpr: error in subexpression primary} { test expr-14.30 {CompilePrimaryExpr: missing paren in subexpression primary} { catch {expr 2+(3*(4+5)} msg set errorInfo -} {syntax error in expression "2+(3*(4+5)" +} {syntax error in expression "2+(3*(4+5)": looking for close parenthesis while compiling "expr 2+(3*(4+5)"} test expr-14.31 {CompilePrimaryExpr: just var ref in subexpression primary} { @@ -590,14 +590,14 @@ test expr-14.31 {CompilePrimaryExpr: just var ref in subexpression primary} { test expr-14.32 {CompilePrimaryExpr: unexpected token} { catch {expr @} msg set errorInfo -} {syntax error in expression "@" +} {syntax error in expression "@": character not legal in expressions while compiling "expr @"} test expr-15.1 {CompileMathFuncCall: missing parenthesis} { catch {expr sinh2.0)} msg set errorInfo -} {syntax error in expression "sinh2.0)" +} {syntax error in expression "sinh2.0)": expected a parenthesis enclosing function arguments while compiling "expr sinh2.0)"} test expr-15.2 {CompileMathFuncCall: unknown math function} { @@ -627,7 +627,7 @@ test expr-15.5 {CompileMathFuncCall: too few arguments} { test expr-15.6 {CompileMathFuncCall: missing ')'} { catch {expr sin(1} msg set errorInfo -} {syntax error in expression "sin(1" +} {syntax error in expression "sin(1": missing close parenthesis at end of function call while compiling "expr sin(1"} if $gotT1 { @@ -733,7 +733,7 @@ test expr-20.2 {double invocation of variable traces} { 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"} 0 32 {}} +} {1 {syntax error in expression "1 oops 10 + 20": extra tokens at end of expression} 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] |