From 6425a01b7a2896172c65f9883f0b56792a6fd263 Mon Sep 17 00:00:00 2001 From: dkf Date: Thu, 6 Dec 2001 10:59:17 +0000 Subject: More expr syntax error improvements --- ChangeLog | 11 ++ generic/tclParseExpr.c | 58 +++++-- tests/compExpr-old.test | 454 ++++++++++++++++++++++++------------------------ tests/compExpr.test | 14 +- tests/compile.test | 6 +- tests/expr-old.test | 16 +- tests/expr.test | 76 ++++---- tests/for.test | 4 +- tests/parseExpr.test | 62 +++---- 9 files changed, 370 insertions(+), 331 deletions(-) diff --git a/ChangeLog b/ChangeLog index a5ef431..737ecd4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2001-12-06 Donal K. Fellows + + * tests/parseExpr.test, tests/for.test, tests/expr.test: + * tests/expr-old.test, tests/compile.test, tests/compExpr.test + * tests/compExpr-old.test: Kept up to date with syntax errors. + * generic/tclParseExpr.c (ParsePrimaryExpr): Rewrote to give even + better syntax errors in the fairly common case of an identifier + without decorations by guessing based on the currently available + functions. Also made messages consistent between memdebug and + ordinary builds. + 2001-12-05 Miguel Sofer * generic/tclVar.c: diff --git a/generic/tclParseExpr.c b/generic/tclParseExpr.c index fa50209..defdecf 100644 --- a/generic/tclParseExpr.c +++ b/generic/tclParseExpr.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclParseExpr.c,v 1.10 2001/12/04 15:36:29 dkf Exp $ + * RCS: @(#) $Id: tclParseExpr.c,v 1.11 2001/12/06 10:59:17 dkf Exp $ */ #include "tclInt.h" @@ -133,7 +133,6 @@ typedef struct ParseInfo { * entries must match the order and number of the lexeme definitions above. */ -#ifdef TCL_COMPILE_DEBUG static char *lexemeStrings[] = { "LITERAL", "FUNCNAME", "[", "{", "(", ")", "$", "\"", ",", "END", "UNKNOWN", "UNKNOWN_CHAR", @@ -142,7 +141,6 @@ static char *lexemeStrings[] = { "&", "^", "|", "&&", "||", "?", ":", "!", "~", "eq", "ne", }; -#endif /* TCL_COMPILE_DEBUG */ /* * Declarations for local procedures to this file: @@ -1387,8 +1385,39 @@ ParsePrimaryExpr(infoPtr) return code; } if (infoPtr->lexeme != OPEN_PAREN) { - LogSyntaxError(infoPtr, - "expected a parenthesis enclosing function arguments"); + /* + * Guess what kind of error we have by trying to tell + * whether we have a function or variable name here. + * Alas, this makes the parser more tightly bound with the + * rest of the interpreter, but that is the only way to + * give a sensible message here. Still, it is not too + * serious as this is only done when generating an error. + */ + Interp *iPtr = (Interp *) infoPtr->parsePtr->interp; + char savedChar; + Tcl_HashEntry *hPtr; + + /* + * Look up the name as a function name; note that this + * requires the expression to be in writable memory. + */ + savedChar = tokenPtr->start[tokenPtr->size]; + tokenPtr->start[tokenPtr->size] = '\0'; + hPtr = Tcl_FindHashEntry(&iPtr->mathFuncTable, tokenPtr->start); + tokenPtr->start[tokenPtr->size] = savedChar; + + /* + * Assume that we have an attempted variable reference + * unless we've got a function name, as the set of + * potential function names is typically much smaller. + */ + if (hPtr != NULL) { + LogSyntaxError(infoPtr, + "expected parenthesis enclosing function arguments"); + } else { + LogSyntaxError(infoPtr, + "variable references require preceding $"); + } return TCL_ERROR; } code = GetLexeme(infoPtr); /* skip over '(' */ @@ -1438,18 +1467,17 @@ ParsePrimaryExpr(infoPtr) case COLON: LogSyntaxError(infoPtr, "unexpected ternary 'else' separator"); return TCL_ERROR; + case CLOSE_PAREN: + LogSyntaxError(infoPtr, "unexpected close parenthesis"); + return TCL_ERROR; - default: -#ifdef TCL_COMPILE_DEBUG - { - char buf[64]; - sprintf(buf, "unexpected operator %s", lexemeStrings[lexeme]); - LogSyntaxError(infoPtr, buf); - } -#else - LogSyntaxError(infoPtr, "unexpected operator"); -#endif + default: { + char buf[64]; + + sprintf(buf, "unexpected operator %s", lexemeStrings[lexeme]); + LogSyntaxError(infoPtr, buf); return TCL_ERROR; + } } /* diff --git a/tests/compExpr-old.test b/tests/compExpr-old.test index ea54db1..b7df34c 100644 --- a/tests/compExpr-old.test +++ b/tests/compExpr-old.test @@ -2,7 +2,7 @@ # # This file contains the original set of tests for the compilation (and # indirectly execution) of Tcl's expr command. A new set of tests covering -# the new implementation are in the files "parseExpr.test and +# the new implementation are in the files "parseExpr.test" and # "compExpr.test". Sourcing this file into Tcl runs the tests and generates # output for errors. No output means no errors were found. # @@ -12,7 +12,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: compExpr-old.test,v 1.6 2001/12/04 15:36:29 dkf Exp $ +# RCS: @(#) $Id: compExpr-old.test,v 1.7 2001/12/06 10:59:17 dkf Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -76,393 +76,393 @@ proc do_twelve_days {} { catch {unset a b i x} -test expr-1.1 {TclCompileExprCmd: no expression} { +test compExpr-old-1.1 {TclCompileExprCmd: no expression} { list [catch {expr } msg] $msg } {1 {wrong # args: should be "expr arg ?arg ...?"}} -test expr-1.2 {TclCompileExprCmd: one expression word} { +test compExpr-old-1.2 {TclCompileExprCmd: one expression word} { expr -25 } -25 -test expr-1.3 {TclCompileExprCmd: two expression words} { +test compExpr-old-1.3 {TclCompileExprCmd: two expression words} { expr -8.2 -6 } -14.2 -test expr-1.4 {TclCompileExprCmd: five expression words} { +test compExpr-old-1.4 {TclCompileExprCmd: five expression words} { expr 20 - 5 +10 -7 } 18 -test expr-1.5 {TclCompileExprCmd: quoted expression word} { +test compExpr-old-1.5 {TclCompileExprCmd: quoted expression word} { expr "0005" } 5 -test expr-1.6 {TclCompileExprCmd: quoted expression word} { +test compExpr-old-1.6 {TclCompileExprCmd: quoted expression word} { catch {expr "0005"zxy} msg set msg } {extra characters after close-quote} -test expr-1.7 {TclCompileExprCmd: expression word in braces} { +test compExpr-old-1.7 {TclCompileExprCmd: expression word in braces} { expr {-0005} } -5 -test expr-1.8 {TclCompileExprCmd: expression word in braces} { +test compExpr-old-1.8 {TclCompileExprCmd: expression word in braces} { expr {{-0x1234}} } -4660 -test expr-1.9 {TclCompileExprCmd: expression word in braces} { +test compExpr-old-1.9 {TclCompileExprCmd: expression word in braces} { catch {expr {-0005}foo} msg set msg } {extra characters after close-brace} -test expr-1.10 {TclCompileExprCmd: other expression word in braces} { +test compExpr-old-1.10 {TclCompileExprCmd: other expression word in braces} { expr 4*[llength "6 2"] } 8 -test expr-1.11 {TclCompileExprCmd: expression word terminated by ;} { +test compExpr-old-1.11 {TclCompileExprCmd: expression word terminated by ;} { expr 4*[llength "6 2"]; } 8 -test expr-1.12 {TclCompileExprCmd: inlined expr (in "catch") inside other catch} { +test compExpr-old-1.12 {TclCompileExprCmd: inlined expr (in "catch") inside other catch} { set a xxx catch { # Might not be a number set a [expr 10*$a] } } 1 -test expr-1.13 {TclCompileExprCmd: second level of substitutions in expr not in braces with single var reference} { +test compExpr-old-1.13 {TclCompileExprCmd: second level of substitutions in expr not in braces with single var reference} { set a xxx set x 27; set bool {$x}; if $bool {set a foo} set a } foo -test expr-1.14 {TclCompileExprCmd: second level of substitutions in expr with comparison as top-level operator} { +test compExpr-old-1.14 {TclCompileExprCmd: second level of substitutions in expr with comparison as top-level operator} { set a xxx set x 2; set b {$x}; set a [expr $b == 2] set a } 1 -test expr-2.1 {TclCompileExpr: are builtin functions registered?} { +test compExpr-old-2.1 {TclCompileExpr: are builtin functions registered?} { expr double(5*[llength "6 2"]) } 10.0 -test expr-2.2 {TclCompileExpr: error in expr} { +test compExpr-old-2.2 {TclCompileExpr: error in expr} { catch {expr 2**3} msg set msg -} {syntax error in expression "2**3": unexpected operator} -test expr-2.3 {TclCompileExpr: junk after legal expr} { +} {syntax error in expression "2**3": unexpected operator *} +test compExpr-old-2.3 {TclCompileExpr: junk after legal expr} { 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.4 {TclCompileExpr: numeric expr string rep == formatted int rep} { +test compExpr-old-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} { +test compExpr-old-3.1 {CompileCondExpr: just lor expr} {expr 3||0} 1 +test compExpr-old-3.2 {CompileCondExpr: error in lor expr} { catch {expr x||3} msg set msg -} {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} { +} {syntax error in expression "x||3": variable references require preceding $} +test compExpr-old-3.3 {CompileCondExpr: test true arm} {expr 3>2?44:66} 44 +test compExpr-old-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": 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} { +} {syntax error in expression "3>2?2**3:66": unexpected operator *} +test compExpr-old-3.5 {CompileCondExpr: test false arm} {expr 2>3?44:66} 66 +test compExpr-old-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": unexpected operator} -test expr-3.7 {CompileCondExpr: long arms & nested cond exprs} {nonPortable} { - puts "Note: doing test expr-3.7 which can take several minutes to run" +} {syntax error in expression "2>3?44:2**3": unexpected operator *} +test compExpr-old-3.7 {CompileCondExpr: long arms & nested cond exprs} {nonPortable} { + puts "Note: doing test compExpr-old-3.7 which can take several minutes to run" hello_world } {Hello world} catch {unset xxx} -test expr-3.8 {CompileCondExpr: long arms & nested cond exprs} {nonPortable} { - puts "Note: doing test expr-3.8 which can take several minutes to run" +test compExpr-old-3.8 {CompileCondExpr: long arms & nested cond exprs} {nonPortable} { + puts "Note: doing test compExpr-old-3.8 which can take several minutes to run" do_twelve_days } 2358 catch {unset xxx} -test expr-4.1 {CompileLorExpr: just land expr} {expr 1.3&&3.3} 1 -test expr-4.2 {CompileLorExpr: error in land expr} { +test compExpr-old-4.1 {CompileLorExpr: just land expr} {expr 1.3&&3.3} 1 +test compExpr-old-4.2 {CompileLorExpr: error in land expr} { catch {expr x&&3} msg set msg -} {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} { +} {syntax error in expression "x&&3": variable references require preceding $} +test compExpr-old-4.3 {CompileLorExpr: simple lor exprs} {expr 0||1.0} 1 +test compExpr-old-4.4 {CompileLorExpr: simple lor exprs} {expr 3.0||0.0} 1 +test compExpr-old-4.5 {CompileLorExpr: simple lor exprs} {expr 0||0||1} 1 +test compExpr-old-4.6 {CompileLorExpr: error compiling lor arm} { 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} { +} {syntax error in expression "2**3||4.0": unexpected operator *} +test compExpr-old-4.7 {CompileLorExpr: error compiling lor arm} { catch {expr 1.3||2**3} msg set msg -} {syntax error in expression "1.3||2**3": unexpected operator} -test expr-4.8 {CompileLorExpr: error compiling lor arms} { +} {syntax error in expression "1.3||2**3": unexpected operator *} +test compExpr-old-4.8 {CompileLorExpr: error compiling lor arms} { list [catch {expr {"a"||"b"}} msg] $msg } {1 {expected boolean value but got "a"}} -test expr-4.9 {CompileLorExpr: long lor arm} { +test compExpr-old-4.9 {CompileLorExpr: long lor arm} { set a "abcdefghijkl" set i 7 expr {[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]] || [string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]] || [string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]] || [string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]} } 1 -test expr-5.1 {CompileLandExpr: just bitor expr} {expr 7|0x13} 23 -test expr-5.2 {CompileLandExpr: error in bitor expr} { +test compExpr-old-5.1 {CompileLandExpr: just bitor expr} {expr 7|0x13} 23 +test compExpr-old-5.2 {CompileLandExpr: error in bitor expr} { catch {expr x|3} msg set msg -} {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 -test expr-5.6 {CompileLandExpr: simple land exprs} {expr 1&&1&&2} 1 -test expr-5.7 {CompileLandExpr: error compiling land arm} { +} {syntax error in expression "x|3": variable references require preceding $} +test compExpr-old-5.3 {CompileLandExpr: simple land exprs} {expr 0&&1.0} 0 +test compExpr-old-5.4 {CompileLandExpr: simple land exprs} {expr 0&&0} 0 +test compExpr-old-5.5 {CompileLandExpr: simple land exprs} {expr 3.0&&1.2} 1 +test compExpr-old-5.6 {CompileLandExpr: simple land exprs} {expr 1&&1&&2} 1 +test compExpr-old-5.7 {CompileLandExpr: error compiling land arm} { 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} { +} {syntax error in expression "2**3&&4.0": unexpected operator *} +test compExpr-old-5.8 {CompileLandExpr: error compiling land arm} { catch {expr 1.3&&2**3} msg set msg -} {syntax error in expression "1.3&&2**3": unexpected operator} -test expr-5.9 {CompileLandExpr: error compiling land arm} { +} {syntax error in expression "1.3&&2**3": unexpected operator *} +test compExpr-old-5.9 {CompileLandExpr: error compiling land arm} { list [catch {expr {"a"&&"b"}} msg] $msg } {1 {expected boolean value but got "a"}} -test expr-5.10 {CompileLandExpr: long land arms} { +test compExpr-old-5.10 {CompileLandExpr: long land arms} { set a "abcdefghijkl" set i 7 expr {[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]] && [string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]] && [string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]] && [string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]} } 1 -test expr-6.1 {CompileBitXorExpr: just bitand expr} {expr 7&0x13} 3 -test expr-6.2 {CompileBitXorExpr: error in bitand expr} { +test compExpr-old-6.1 {CompileBitXorExpr: just bitand expr} {expr 7&0x13} 3 +test compExpr-old-6.2 {CompileBitXorExpr: error in bitand expr} { catch {expr x|3} msg set msg -} {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 -test expr-6.6 {CompileBitXorExpr: simple bitxor exprs} {expr -1^7} -8 -test expr-6.7 {CompileBitXorExpr: error compiling bitxor arm} { +} {syntax error in expression "x|3": variable references require preceding $} +test compExpr-old-6.3 {CompileBitXorExpr: simple bitxor exprs} {expr 7^0x13} 20 +test compExpr-old-6.4 {CompileBitXorExpr: simple bitxor exprs} {expr 3^0x10} 19 +test compExpr-old-6.5 {CompileBitXorExpr: simple bitxor exprs} {expr 0^7} 7 +test compExpr-old-6.6 {CompileBitXorExpr: simple bitxor exprs} {expr -1^7} -8 +test compExpr-old-6.7 {CompileBitXorExpr: error compiling bitxor arm} { 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} { +} {syntax error in expression "2**3|6": unexpected operator *} +test compExpr-old-6.8 {CompileBitXorExpr: error compiling bitxor arm} { catch {expr 2^x} msg set msg -} {syntax error in expression "2^x": expected a parenthesis enclosing function arguments} -test expr-6.9 {CompileBitXorExpr: runtime error in bitxor arm} { +} {syntax error in expression "2^x": variable references require preceding $} +test compExpr-old-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 "^"}} -test expr-6.10 {CompileBitXorExpr: runtime error in bitxor arm} { +test compExpr-old-6.10 {CompileBitXorExpr: runtime error in bitxor arm} { list [catch {expr {"a"^"b"}} msg] $msg } {1 {can't use non-numeric string as operand of "^"}} -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} { +test compExpr-old-7.1 {CompileBitAndExpr: just equality expr} {expr 3==2} 0 +test compExpr-old-7.2 {CompileBitAndExpr: just equality expr} {expr 2.0==2} 1 +test compExpr-old-7.3 {CompileBitAndExpr: just equality expr} {expr 3.2!=2.2} 1 +test compExpr-old-7.4 {CompileBitAndExpr: just equality expr} {expr {"abc" == "abd"}} 0 +test compExpr-old-7.5 {CompileBitAndExpr: error in equality expr} { catch {expr x==3} msg set msg -} {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 -test expr-7.9 {CompileBitAndExpr: simple bitand exprs} {expr -1&-7} -7 -test expr-7.10 {CompileBitAndExpr: error compiling bitand arm} { +} {syntax error in expression "x==3": variable references require preceding $} +test compExpr-old-7.6 {CompileBitAndExpr: simple bitand exprs} {expr 7&0x13} 3 +test compExpr-old-7.7 {CompileBitAndExpr: simple bitand exprs} {expr 0xf2&0x53} 82 +test compExpr-old-7.8 {CompileBitAndExpr: simple bitand exprs} {expr 3&6} 2 +test compExpr-old-7.9 {CompileBitAndExpr: simple bitand exprs} {expr -1&-7} -7 +test compExpr-old-7.10 {CompileBitAndExpr: error compiling bitand arm} { 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} { +} {syntax error in expression "2**3&6": unexpected operator *} +test compExpr-old-7.11 {CompileBitAndExpr: error compiling bitand arm} { catch {expr 2&x} msg set msg -} {syntax error in expression "2&x": expected a parenthesis enclosing function arguments} -test expr-7.12 {CompileBitAndExpr: runtime error in bitand arm} { +} {syntax error in expression "2&x": variable references require preceding $} +test compExpr-old-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 "&"}} -test expr-7.13 {CompileBitAndExpr: runtime error in bitand arm} { +test compExpr-old-7.13 {CompileBitAndExpr: runtime error in bitand arm} { list [catch {expr {"a"&"b"}} msg] $msg } {1 {can't use non-numeric string as operand of "&"}} -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} { +test compExpr-old-8.1 {CompileEqualityExpr: just relational expr} {expr 3>=2} 1 +test compExpr-old-8.2 {CompileEqualityExpr: just relational expr} {expr 2<=2.1} 1 +test compExpr-old-8.3 {CompileEqualityExpr: just relational expr} {expr 3.2>"2.2"} 1 +test compExpr-old-8.4 {CompileEqualityExpr: just relational expr} {expr {"0y"<"0x12"}} 0 +test compExpr-old-8.5 {CompileEqualityExpr: error in relational expr} { catch {expr x>3} msg set msg -} {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 -test expr-8.9 {CompileEqualityExpr: simple equality exprs} {expr -1!="abc"} 1 -test expr-8.10 {CompileEqualityExpr: error compiling equality arm} { +} {syntax error in expression "x>3": variable references require preceding $} +test compExpr-old-8.6 {CompileEqualityExpr: simple equality exprs} {expr 7==0x13} 0 +test compExpr-old-8.7 {CompileEqualityExpr: simple equality exprs} {expr -0xf2!=0x53} 1 +test compExpr-old-8.8 {CompileEqualityExpr: simple equality exprs} {expr {"12398712938788234-1298379" != ""}} 1 +test compExpr-old-8.9 {CompileEqualityExpr: simple equality exprs} {expr -1!="abc"} 1 +test compExpr-old-8.10 {CompileEqualityExpr: error compiling equality arm} { 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} { +} {syntax error in expression "2**3==6": unexpected operator *} +test compExpr-old-8.11 {CompileEqualityExpr: error compiling equality arm} { catch {expr 2!=x} msg set msg -} {syntax error in expression "2!=x": expected a parenthesis enclosing function arguments} +} {syntax error in expression "2!=x": variable references require preceding $} -test expr-9.1 {CompileRelationalExpr: just shift expr} {expr 3<<2} 12 -test expr-9.2 {CompileRelationalExpr: just shift expr} {expr 0xff>>2} 63 -test expr-9.3 {CompileRelationalExpr: just shift expr} {expr -1>>2} -1 -test expr-9.4 {CompileRelationalExpr: just shift expr} {expr {1<<3}} 8 +test compExpr-old-9.1 {CompileRelationalExpr: just shift expr} {expr 3<<2} 12 +test compExpr-old-9.2 {CompileRelationalExpr: just shift expr} {expr 0xff>>2} 63 +test compExpr-old-9.3 {CompileRelationalExpr: just shift expr} {expr -1>>2} -1 +test compExpr-old-9.4 {CompileRelationalExpr: just shift expr} {expr {1<<3}} 8 # The following test is different for 32-bit versus 64-bit # architectures because LONG_MIN is different if {0x80000000 > 0} { - test expr-9.5 {CompileRelationalExpr: shift expr producing LONG_MIN} {nonPortable} { + test compExpr-old-9.5 {CompileRelationalExpr: shift expr producing LONG_MIN} {nonPortable} { expr {1<<63} } -9223372036854775808 } else { - test expr-9.5 {CompileRelationalExpr: shift expr producing LONG_MIN} {nonPortable} { + test compExpr-old-9.5 {CompileRelationalExpr: shift expr producing LONG_MIN} {nonPortable} { expr {1<<31} } -2147483648 } -test expr-9.6 {CompileRelationalExpr: error in shift expr} { +test compExpr-old-9.6 {CompileRelationalExpr: error in shift expr} { catch {expr x>>3} msg set msg -} {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} { +} {syntax error in expression "x>>3": variable references require preceding $} +test compExpr-old-9.7 {CompileRelationalExpr: simple relational exprs} {expr 0xff>=+0x3} 1 +test compExpr-old-9.8 {CompileRelationalExpr: simple relational exprs} {expr -0xf2<0x3} 1 +test compExpr-old-9.9 {CompileRelationalExpr: error compiling relational arm} { 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} { +} {syntax error in expression "2**3>6": unexpected operator *} +test compExpr-old-9.10 {CompileRelationalExpr: error compiling relational arm} { catch {expr 2>0x3} 31 -test expr-10.7 {CompileShiftExpr: simple shift exprs} {expr -0xf2<<0x3} -1936 -test expr-10.8 {CompileShiftExpr: error compiling shift arm} { +} {syntax error in expression "x+3": variable references require preceding $} +test compExpr-old-10.6 {CompileShiftExpr: simple shift exprs} {expr 0xff>>0x3} 31 +test compExpr-old-10.7 {CompileShiftExpr: simple shift exprs} {expr -0xf2<<0x3} -1936 +test compExpr-old-10.8 {CompileShiftExpr: error compiling shift arm} { 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} { +} {syntax error in expression "2**3>>6": unexpected operator *} +test compExpr-old-10.9 {CompileShiftExpr: error compiling shift arm} { catch {expr 2<>43}} msg] $msg } {1 {can't use floating-point value as operand of ">>"}} -test expr-10.11 {CompileShiftExpr: runtime error} { +test compExpr-old-10.11 {CompileShiftExpr: runtime error} { list [catch {expr {"a"<<"b"}} msg] $msg } {1 {can't use non-numeric string as operand of "<<"}} -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} { +test compExpr-old-11.1 {CompileAddExpr: just multiply expr} {expr 4*-2} -8 +test compExpr-old-11.2 {CompileAddExpr: just multiply expr} {expr 0xff%2} 1 +test compExpr-old-11.3 {CompileAddExpr: just multiply expr} {expr -1/2} -1 +test compExpr-old-11.4 {CompileAddExpr: just multiply expr} {expr 7891%0123} 6 +test compExpr-old-11.5 {CompileAddExpr: error in multiply expr} { catch {expr x*3} msg set msg -} {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} { +} {syntax error in expression "x*3": variable references require preceding $} +test compExpr-old-11.6 {CompileAddExpr: simple add exprs} {expr 0xff++0x3} 258 +test compExpr-old-11.7 {CompileAddExpr: simple add exprs} {expr -0xf2--0x3} -239 +test compExpr-old-11.8 {CompileAddExpr: error compiling add arm} { 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} { +} {syntax error in expression "2**3+6": unexpected operator *} +test compExpr-old-11.9 {CompileAddExpr: error compiling add arm} { catch {expr 2-x} msg set msg -} {syntax error in expression "2-x": expected a parenthesis enclosing function arguments} -test expr-11.10 {CompileAddExpr: runtime error} { +} {syntax error in expression "2-x": variable references require preceding $} +test compExpr-old-11.10 {CompileAddExpr: runtime error} { list [catch {expr {24.0+"xx"}} msg] $msg } {1 {can't use non-numeric string as operand of "+"}} -test expr-11.11 {CompileAddExpr: runtime error} { +test compExpr-old-11.11 {CompileAddExpr: runtime error} { list [catch {expr {"a"-"b"}} msg] $msg } {1 {can't use non-numeric string as operand of "-"}} -test expr-11.12 {CompileAddExpr: runtime error} { +test compExpr-old-11.12 {CompileAddExpr: runtime error} { list [catch {expr {3/0}} msg] $msg } {1 {divide by zero}} -test expr-11.13 {CompileAddExpr: runtime error} { +test compExpr-old-11.13 {CompileAddExpr: runtime error} { list [catch {expr {2.3/0.0}} msg] $msg } {1 {divide by zero}} -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} { +test compExpr-old-12.1 {CompileMultiplyExpr: just unary expr} {expr ~4} -5 +test compExpr-old-12.2 {CompileMultiplyExpr: just unary expr} {expr --5} 5 +test compExpr-old-12.3 {CompileMultiplyExpr: just unary expr} {expr !27} 0 +test compExpr-old-12.4 {CompileMultiplyExpr: just unary expr} {expr ~0xff00ff} -16711936 +test compExpr-old-12.5 {CompileMultiplyExpr: error in unary expr} { catch {expr ~x} msg set msg -} {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} { +} {syntax error in expression "~x": variable references require preceding $} +test compExpr-old-12.6 {CompileMultiplyExpr: simple multiply exprs} {expr 0xff*0x3} 765 +test compExpr-old-12.7 {CompileMultiplyExpr: simple multiply exprs} {expr -0xf2%-0x3} -2 +test compExpr-old-12.8 {CompileMultiplyExpr: error compiling multiply arm} { 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} { +} {syntax error in expression "2*3%%6": unexpected operator %} +test compExpr-old-12.9 {CompileMultiplyExpr: error compiling multiply arm} { catch {expr 2*x} msg set msg -} {syntax error in expression "2*x": expected a parenthesis enclosing function arguments} -test expr-12.10 {CompileMultiplyExpr: runtime error} { +} {syntax error in expression "2*x": variable references require preceding $} +test compExpr-old-12.10 {CompileMultiplyExpr: runtime error} { list [catch {expr {24.0*"xx"}} msg] $msg } {1 {can't use non-numeric string as operand of "*"}} -test expr-12.11 {CompileMultiplyExpr: runtime error} { +test compExpr-old-12.11 {CompileMultiplyExpr: runtime error} { list [catch {expr {"a"/"b"}} msg] $msg } {1 {can't use non-numeric string as operand of "/"}} -test expr-13.1 {CompileUnaryExpr: unary exprs} {expr -0xff} -255 -test expr-13.2 {CompileUnaryExpr: unary exprs} {expr +000123} 83 -test expr-13.3 {CompileUnaryExpr: unary exprs} {expr +--++36} 36 -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} { +test compExpr-old-13.1 {CompileUnaryExpr: unary exprs} {expr -0xff} -255 +test compExpr-old-13.2 {CompileUnaryExpr: unary exprs} {expr +000123} 83 +test compExpr-old-13.3 {CompileUnaryExpr: unary exprs} {expr +--++36} 36 +test compExpr-old-13.4 {CompileUnaryExpr: unary exprs} {expr !2} 0 +test compExpr-old-13.5 {CompileUnaryExpr: unary exprs} {expr +--+-62.0} -62.0 +test compExpr-old-13.6 {CompileUnaryExpr: unary exprs} {expr !0.0} 1 +test compExpr-old-13.7 {CompileUnaryExpr: unary exprs} {expr !0xef} 0 +test compExpr-old-13.8 {CompileUnaryExpr: error compiling unary expr} { catch {expr ~x} msg set msg -} {syntax error in expression "~x": expected a parenthesis enclosing function arguments} -test expr-13.9 {CompileUnaryExpr: error compiling unary expr} { +} {syntax error in expression "~x": variable references require preceding $} +test compExpr-old-13.9 {CompileUnaryExpr: error compiling unary expr} { catch {expr !1.x} msg set msg } {syntax error in expression "!1.x": extra tokens at end of expression} -test expr-13.10 {CompileUnaryExpr: runtime error} { +test compExpr-old-13.10 {CompileUnaryExpr: runtime error} { list [catch {expr {~"xx"}} msg] $msg } {1 {can't use non-numeric string as operand of "~"}} -test expr-13.11 {CompileUnaryExpr: runtime error} { +test compExpr-old-13.11 {CompileUnaryExpr: runtime error} { list [catch {expr ~4.0} msg] $msg } {1 {can't use floating-point value as operand of "~"}} -test expr-13.12 {CompileUnaryExpr: just primary expr} {expr 0x123} 291 -test expr-13.13 {CompileUnaryExpr: just primary expr} { +test compExpr-old-13.12 {CompileUnaryExpr: just primary expr} {expr 0x123} 291 +test compExpr-old-13.13 {CompileUnaryExpr: just primary expr} { set a 27 expr $a } 27 -test expr-13.14 {CompileUnaryExpr: just primary expr} { +test compExpr-old-13.14 {CompileUnaryExpr: just primary expr} { expr double(27) } 27.0 -test expr-13.15 {CompileUnaryExpr: just primary expr} {expr "123"} 123 -test expr-13.16 {CompileUnaryExpr: error in primary expr} { +test compExpr-old-13.15 {CompileUnaryExpr: just primary expr} {expr "123"} 123 +test compExpr-old-13.16 {CompileUnaryExpr: error in primary expr} { catch {expr [set]} msg set msg } {wrong # args: should be "set varName ?newValue?"} -test expr-14.1 {CompilePrimaryExpr: literal primary} {expr 1} 1 -test expr-14.2 {CompilePrimaryExpr: literal primary} {expr 123} 123 -test expr-14.3 {CompilePrimaryExpr: literal primary} {expr 0xff} 255 -test expr-14.4 {CompilePrimaryExpr: literal primary} {expr 00010} 8 -test expr-14.5 {CompilePrimaryExpr: literal primary} {expr 62.0} 62.0 -test expr-14.6 {CompilePrimaryExpr: literal primary} { +test compExpr-old-14.1 {CompilePrimaryExpr: literal primary} {expr 1} 1 +test compExpr-old-14.2 {CompilePrimaryExpr: literal primary} {expr 123} 123 +test compExpr-old-14.3 {CompilePrimaryExpr: literal primary} {expr 0xff} 255 +test compExpr-old-14.4 {CompilePrimaryExpr: literal primary} {expr 00010} 8 +test compExpr-old-14.5 {CompilePrimaryExpr: literal primary} {expr 62.0} 62.0 +test compExpr-old-14.6 {CompilePrimaryExpr: literal primary} { expr 3.1400000 } 3.14 -test expr-14.7 {CompilePrimaryExpr: literal primary} {expr {{abcde}<{abcdef}}} 1 -test expr-14.8 {CompilePrimaryExpr: literal primary} {expr {{abc\ +test compExpr-old-14.7 {CompilePrimaryExpr: literal primary} {expr {{abcde}<{abcdef}}} 1 +test compExpr-old-14.8 {CompilePrimaryExpr: literal primary} {expr {{abc\ def} < {abcdef}}} 1 -test expr-14.9 {CompilePrimaryExpr: literal primary} {expr {{abc\tde} > {abc\tdef}}} 0 -test expr-14.10 {CompilePrimaryExpr: literal primary} {expr {{123}}} 123 -test expr-14.11 {CompilePrimaryExpr: var reference primary} { +test compExpr-old-14.9 {CompilePrimaryExpr: literal primary} {expr {{abc\tde} > {abc\tdef}}} 0 +test compExpr-old-14.10 {CompilePrimaryExpr: literal primary} {expr {{123}}} 123 +test compExpr-old-14.11 {CompilePrimaryExpr: var reference primary} { set i 789 list [expr {$i}] [expr $i] } {789 789} -test expr-14.12 {CompilePrimaryExpr: var reference primary} { +test compExpr-old-14.12 {CompilePrimaryExpr: var reference primary} { set i {789} ;# test expr's aggressive conversion to numeric semantics list [expr {$i}] [expr $i] } {789 789} -test expr-14.13 {CompilePrimaryExpr: var reference primary} { +test compExpr-old-14.13 {CompilePrimaryExpr: var reference primary} { catch {unset a} set a(foo) foo set a(bar) bar @@ -472,45 +472,45 @@ test expr-14.13 {CompilePrimaryExpr: var reference primary} { catch {unset a} set result } {123 1} -test expr-14.14 {CompilePrimaryExpr: var reference primary} { +test compExpr-old-14.14 {CompilePrimaryExpr: var reference primary} { set i 123 ;# test "$var.0" floating point conversion hack list [expr $i] [expr $i.0] [expr $i.0/12.0] } {123 123.0 10.25} -test expr-14.15 {CompilePrimaryExpr: var reference primary} { +test compExpr-old-14.15 {CompilePrimaryExpr: var reference primary} { set i 123 catch {expr $i.2} msg set msg } 123.2 -test expr-14.16 {CompilePrimaryExpr: error compiling var reference primary} { +test compExpr-old-14.16 {CompilePrimaryExpr: error compiling var reference primary} { catch {expr {$a(foo}} msg set errorInfo } {missing ) while compiling "expr {$a(foo}"} -test expr-14.17 {CompilePrimaryExpr: string primary that looks like var ref} { +test compExpr-old-14.17 {CompilePrimaryExpr: string primary that looks like var ref} { expr $ } $ -test expr-14.18 {CompilePrimaryExpr: quoted string primary} { +test compExpr-old-14.18 {CompilePrimaryExpr: quoted string primary} { expr "21" } 21 -test expr-14.19 {CompilePrimaryExpr: quoted string primary} { +test compExpr-old-14.19 {CompilePrimaryExpr: quoted string primary} { set i 123 set x 456 expr "$i+$x" } 579 -test expr-14.20 {CompilePrimaryExpr: quoted string primary} { +test compExpr-old-14.20 {CompilePrimaryExpr: quoted string primary} { set i 3 set x 6 expr 2+"$i.$x" } 5.6 -test expr-14.21 {CompilePrimaryExpr: error in quoted string primary} { +test compExpr-old-14.21 {CompilePrimaryExpr: error in quoted string primary} { catch {expr "[set]"} msg set msg } {wrong # args: should be "set varName ?newValue?"} -test expr-14.22 {CompilePrimaryExpr: subcommand primary} { +test compExpr-old-14.22 {CompilePrimaryExpr: subcommand primary} { expr {[set i 123; set i]} } 123 -test expr-14.23 {CompilePrimaryExpr: error in subcommand primary} { +test compExpr-old-14.23 {CompilePrimaryExpr: error in subcommand primary} { catch {expr {[set]}} msg set errorInfo } {wrong # args: should be "set varName ?newValue?" @@ -518,28 +518,28 @@ test expr-14.23 {CompilePrimaryExpr: error in subcommand primary} { "set" while compiling "expr {[set]}"} -test expr-14.24 {CompilePrimaryExpr: error in subcommand primary} { +test compExpr-old-14.24 {CompilePrimaryExpr: error in subcommand primary} { catch {expr {[set i}} msg set errorInfo } {missing close-bracket while compiling "expr {[set i}"} -test expr-14.25 {CompilePrimaryExpr: math function primary} { +test compExpr-old-14.25 {CompilePrimaryExpr: math function primary} { format %.6g [expr exp(1.0)] } 2.71828 -test expr-14.26 {CompilePrimaryExpr: math function primary} { +test compExpr-old-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} { +test compExpr-old-14.27 {CompilePrimaryExpr: error in math function primary} { catch {expr sinh::(2.0)} msg set errorInfo -} {syntax error in expression "sinh::(2.0)": expected a parenthesis enclosing function arguments +} {syntax error in expression "sinh::(2.0)": expected parenthesis enclosing function arguments while compiling "expr sinh::(2.0)"} -test expr-14.28 {CompilePrimaryExpr: subexpression primary} { +test compExpr-old-14.28 {CompilePrimaryExpr: subexpression primary} { expr 2+(3*4) } 14 -test expr-14.29 {CompilePrimaryExpr: error in subexpression primary} { +test compExpr-old-14.29 {CompilePrimaryExpr: error in subexpression primary} { catch {expr 2+(3*[set])} msg set errorInfo } {wrong # args: should be "set varName ?newValue?" @@ -547,79 +547,79 @@ test expr-14.29 {CompilePrimaryExpr: error in subexpression primary} { "set" while compiling "expr 2+(3*[set])"} -test expr-14.30 {CompilePrimaryExpr: missing paren in subexpression primary} { +test compExpr-old-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)": looking for close parenthesis while compiling "expr 2+(3*(4+5)"} -test expr-14.31 {CompilePrimaryExpr: just var ref in subexpression primary} { +test compExpr-old-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} { +test compExpr-old-14.32 {CompilePrimaryExpr: unexpected token} { catch {expr @} msg set errorInfo } {syntax error in expression "@": character not legal in expressions while compiling "expr @"} -test expr-15.1 {CompileMathFuncCall: missing parenthesis} { +test compExpr-old-15.1 {CompileMathFuncCall: missing parenthesis} { catch {expr sinh2.0)} msg set errorInfo -} {syntax error in expression "sinh2.0)": expected a parenthesis enclosing function arguments +} {syntax error in expression "sinh2.0)": variable references require preceding $ while compiling "expr sinh2.0)"} -test expr-15.2 {CompileMathFuncCall: unknown math function} { +test compExpr-old-15.2 {CompileMathFuncCall: unknown math function} { catch {expr whazzathuh(1)} msg set errorInfo } {unknown math function "whazzathuh" while compiling "expr whazzathuh(1)"} -test expr-15.3 {CompileMathFuncCall: too many arguments} { +test compExpr-old-15.3 {CompileMathFuncCall: too many arguments} { catch {expr sin(1,2,3)} msg set errorInfo } {too many arguments for math function while compiling "expr sin(1,2,3)"} -test expr-15.4 {CompileMathFuncCall: ')' found before last required arg} { +test compExpr-old-15.4 {CompileMathFuncCall: ')' found before last required arg} { catch {expr sin()} msg set errorInfo } {too few arguments for math function while compiling "expr sin()"} -test expr-15.5 {CompileMathFuncCall: too few arguments} { +test compExpr-old-15.5 {CompileMathFuncCall: too few arguments} { catch {expr pow(1)} msg set errorInfo } {too few arguments for math function while compiling "expr pow(1)"} -test expr-15.6 {CompileMathFuncCall: missing ')'} { +test compExpr-old-15.6 {CompileMathFuncCall: missing ')'} { catch {expr sin(1} msg set errorInfo } {syntax error in expression "sin(1": missing close parenthesis at end of function call while compiling "expr sin(1"} if $gotT1 { - test expr-15.7 {CompileMathFuncCall: call registered math function} { + test compExpr-old-15.7 {CompileMathFuncCall: call registered math function} { expr 2*T1() } 246 - test expr-15.8 {CompileMathFuncCall: call registered math function} { + test compExpr-old-15.8 {CompileMathFuncCall: call registered math function} { expr T2()*3 } 1035 - test expr-15.9 {CompileMathFuncCall: call registered math function} { + test compExpr-old-15.9 {CompileMathFuncCall: call registered math function} { expr T3(21, 37) } 37 - test expr-15.10 {CompileMathFuncCall: call registered math function} { + test compExpr-old-15.10 {CompileMathFuncCall: call registered math function} { expr T3(21.2, 37) } 37.0 - test expr-15.11 {CompileMathFuncCall: call registered math function} { + test compExpr-old-15.11 {CompileMathFuncCall: call registered math function} { expr T3(-21.2, -17.5) } -17.5 } -test expr-16.1 {GetToken: checks whether integer token starting with "0x" (e.g., "0x$") is invalid} { +test compExpr-old-16.1 {GetToken: checks whether integer token starting with "0x" (e.g., "0x$") is invalid} { catch {unset a} set a(VALUE) ff15 set i 123 @@ -628,13 +628,13 @@ test expr-16.1 {GetToken: checks whether integer token starting with "0x" (e.g., } set i } {} -test expr-16.2 {GetToken: check for string literal in braces} { +test compExpr-old-16.2 {GetToken: check for string literal in braces} { expr {{1}} } {1} # Check "expr" and computed command names. -test expr-17.1 {expr and computed command names} { +test compExpr-old-17.1 {expr and computed command names} { set i 0 set z expr $z 1+2 @@ -644,7 +644,7 @@ test expr-17.1 {expr and computed command names} { # an integer, convert to integer. Otherwise, if the string looks like a # double, convert to double. -test expr-18.1 {expr and conversion of operands to numbers} { +test compExpr-old-18.1 {expr and conversion of operands to numbers} { set x [lindex 11 0] catch {expr int($x)} expr {$x} @@ -653,7 +653,7 @@ test expr-18.1 {expr and conversion of operands to numbers} { # Check "expr" and interpreter result object resetting before appending # an error msg during evaluation of exprs not in {}s -test expr-19.1 {expr and interpreter result object resetting} { +test compExpr-old-19.1 {expr and interpreter result object resetting} { proc p {} { set t 10.0 set x 2.0 diff --git a/tests/compExpr.test b/tests/compExpr.test index 54e5de0..cd407d3 100644 --- a/tests/compExpr.test +++ b/tests/compExpr.test @@ -8,7 +8,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: compExpr.test,v 1.5 2001/12/04 15:36:29 dkf Exp $ +# RCS: @(#) $Id: compExpr.test,v 1.6 2001/12/06 10:59:17 dkf Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -211,7 +211,7 @@ test compExpr-3.2 {CompileLandOrLorExpr procedure, nonnumeric 1st operand} { } 0 test compExpr-3.3 {CompileSubExpr procedure, error in 1st operand} { list [catch {expr {[expr *2]||0}} msg] $msg -} {1 {syntax error in expression "*2": unexpected operator}} +} {1 {syntax error in expression "*2": unexpected operator *}} test compExpr-3.4 {CompileLandOrLorExpr procedure, result is 1 or 0} { catch {unset a} catch {unset b} @@ -241,7 +241,7 @@ test compExpr-3.8 {CompileLandOrLorExpr procedure, nonnumeric 2nd operand} { } 0 test compExpr-3.9 {CompileLandOrLorExpr procedure, error in 2nd operand} { list [catch {expr {0||[expr %2]}} msg] $msg -} {1 {syntax error in expression "%2": unexpected operator}} +} {1 {syntax error in expression "%2": unexpected operator %}} test compExpr-3.10 {CompileLandOrLorExpr procedure, long lor/land arm} { set a "abcdefghijkl" set i 7 @@ -260,7 +260,7 @@ test compExpr-4.2 {CompileCondExpr procedure, complex test, convert to numeric} } -54 test compExpr-4.3 {CompileCondExpr procedure, error in test} { list [catch {expr {[expr *2]? +1 : -1}} msg] $msg -} {1 {syntax error in expression "*2": unexpected operator}} +} {1 {syntax error in expression "*2": unexpected operator *}} test compExpr-4.4 {CompileCondExpr procedure, simple "true" clause} { catch {unset a} set a no @@ -273,7 +273,7 @@ test compExpr-4.5 {CompileCondExpr procedure, convert "true" clause to numeric} } no test compExpr-4.6 {CompileCondExpr procedure, error in "true" clause} { list [catch {expr {1? [expr *2] : -127}} msg] $msg -} {1 {syntax error in expression "*2": unexpected operator}} +} {1 {syntax error in expression "*2": unexpected operator *}} test compExpr-4.7 {CompileCondExpr procedure, simple "false" clause} { catch {unset a} set a no @@ -286,7 +286,7 @@ test compExpr-4.8 {CompileCondExpr procedure, convert "false" clause to numeric} } 83 test compExpr-4.9 {CompileCondExpr procedure, error in "false" clause} { list [catch {expr {1? 15 : [expr *2]}} msg] $msg -} {1 {syntax error in expression "*2": unexpected operator}} +} {1 {syntax error in expression "*2": unexpected operator *}} test compExpr-5.1 {CompileMathFuncCall procedure, math function found} { format %.6g [expr atan2(1.0, 2.0)] @@ -310,7 +310,7 @@ test compExpr-5.6 {CompileMathFuncCall procedure, complex argument} { } 9.97424 test compExpr-5.7 {CompileMathFuncCall procedure, error in argument} { list [catch {expr {sinh(2.*)}} msg] $msg -} {1 {syntax error in expression "sinh(2.*)": unexpected operator}} +} {1 {syntax error in expression "sinh(2.*)": unexpected close parenthesis}} test compExpr-5.8 {CompileMathFuncCall procedure, too many arguments} { list [catch {expr {sinh(2.0, 3.0)}} msg] $msg } {1 {too many arguments for math function}} diff --git a/tests/compile.test b/tests/compile.test index 72024b8..03f8295 100644 --- a/tests/compile.test +++ b/tests/compile.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: compile.test,v 1.16 2001/12/04 15:36:29 dkf Exp $ +# RCS: @(#) $Id: compile.test,v 1.17 2001/12/06 10:59:17 dkf Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -230,11 +230,11 @@ test compile-11.6 {Tcl_Append*: ensure Tcl_ResetResult is used properly} { test compile-11.7 {Tcl_Append*: ensure Tcl_ResetResult is used properly} { proc p {} { set r [list foobar] ; expr !a } list [catch {p} msg] $msg -} {1 {syntax error in expression "!a": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "!a": variable references require preceding $}} test compile-11.8 {Tcl_Append*: ensure Tcl_ResetResult is used properly} { proc p {} { set r [list foobar] ; expr {!a} } list [catch {p} msg] $msg -} {1 {syntax error in expression "!a": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "!a": variable references require preceding $}} test compile-11.9 {Tcl_Append*: ensure Tcl_ResetResult is used properly} { proc p {} { set r [list foobar] ; llength "\{" } list [catch {p} msg] $msg diff --git a/tests/expr-old.test b/tests/expr-old.test index 368ec44..6ed4446 100644 --- a/tests/expr-old.test +++ b/tests/expr-old.test @@ -13,7 +13,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-old.test,v 1.12 2001/12/04 15:36:29 dkf Exp $ +# RCS: @(#) $Id: expr-old.test,v 1.13 2001/12/06 10:59:17 dkf Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -472,7 +472,7 @@ test expr-old-26.11 {error conditions} { } {1 {syntax error in expression "2#": extra tokens at end of expression}} test expr-old-26.12 {error conditions} { list [catch {expr a.b} msg] $msg -} {1 {syntax error in expression "a.b": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "a.b": variable references require 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 "/"}} @@ -481,19 +481,19 @@ test expr-old-26.14 {error conditions} { } {1 {syntax error in expression "2:3": extra tokens at end of expression}} test expr-old-26.15 {error conditions} { list [catch {expr a@b} msg] $msg -} {1 {syntax error in expression "a@b": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "a@b": variable references require 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} { list [catch {expr a`b} msg] $msg -} {1 {syntax error in expression "a`b": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "a`b": variable references require preceding $}} test expr-old-26.18 {error conditions} { 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} { list [catch {expr a} msg] $msg -} {1 {syntax error in expression "a": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "a": variable references require preceding $}} test expr-old-26.20 {error conditions} { list [catch expr msg] $msg } {1 {wrong # args: should be "expr arg ?arg ...?"}} @@ -543,10 +543,10 @@ test expr-old-27.10 {cancelled evaluation} { } {0 0} test expr-old-27.11 {cancelled evaluation} { list [catch {expr {0 && foo}} msg] $msg -} {1 {syntax error in expression "0 && foo": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "0 && foo": variable references require preceding $}} test expr-old-27.12 {cancelled evaluation} { list [catch {expr {0 ? 1 : foo}} msg] $msg -} {1 {syntax error in expression "0 ? 1 : foo": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "0 ? 1 : foo": variable references require preceding $}} # Tcl_ExprBool as used in "if" statements @@ -850,7 +850,7 @@ test expr-old-34.1 {errors in math functions} { } {1 {unknown math function "func_2"}} test expr-old-34.2 {errors in math functions} { list [catch {expr func|(1.0)} msg] $msg -} {1 {syntax error in expression "func|(1.0)": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "func|(1.0)": variable references require preceding $}} test expr-old-34.3 {errors in math functions} { list [catch {expr {hypot("a b", 2.0)}} msg] $msg } {1 {argument to math function didn't have numeric value}} diff --git a/tests/expr.test b/tests/expr.test index 2233e53..c5b794a 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.13 2001/12/04 15:36:29 dkf Exp $ +# RCS: @(#) $Id: expr.test,v 1.14 2001/12/06 10:59:18 dkf Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -138,7 +138,7 @@ 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": unexpected operator} +} {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 @@ -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": expected a parenthesis enclosing function arguments} +} {syntax error in expression "x||3": variable references require preceding $} 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": unexpected operator} +} {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": unexpected operator} +} {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": expected a parenthesis enclosing function arguments} +} {syntax error in expression "x&&3": variable references require preceding $} 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": unexpected operator} +} {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": unexpected operator} +} {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": expected a parenthesis enclosing function arguments} +} {syntax error in expression "x|3": variable references require preceding $} 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": unexpected operator} +} {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": unexpected operator} +} {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": expected a parenthesis enclosing function arguments} +} {syntax error in expression "x|3": variable references require preceding $} 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": unexpected operator} +} {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": expected a parenthesis enclosing function arguments} +} {syntax error in expression "2^x": variable references require preceding $} 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": expected a parenthesis enclosing function arguments} +} {syntax error in expression "x==3": variable references require preceding $} 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": unexpected operator} +} {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": expected a parenthesis enclosing function arguments} +} {syntax error in expression "2&x": variable references require preceding $} 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": expected a parenthesis enclosing function arguments} +} {syntax error in expression "xne3": variable references require preceding $} 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": expected a parenthesis enclosing function arguments} +} {syntax error in expression "x>3": variable references require preceding $} 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": unexpected operator} +} {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": expected a parenthesis enclosing function arguments} +} {syntax error in expression "2!=x": variable references require preceding $} 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 @@ -312,12 +312,12 @@ test expr-8.19 {CompileBitAndExpr: equality expr} {expr {"abc" ne "abd"}} 1 test expr-8.20 {CompileBitAndExpr: error in equality expr} { catch {expr x ne3} msg set msg -} {syntax error in expression "x ne3": expected a parenthesis enclosing function arguments} +} {syntax error in expression "x ne3": variable references require preceding $} 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": expected a parenthesis enclosing function arguments} +} {syntax error in expression "a eq b": variable references require preceding $} 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": expected a parenthesis enclosing function arguments} +} {syntax error in expression "x>>3": variable references require preceding $} 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": unexpected operator} +} {syntax error in expression "2**3>6": unexpected operator *} test expr-9.10 {CompileRelationalExpr: error compiling relational arm} { catch {expr 2>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": unexpected operator} +} {syntax error in expression "2**3>>6": unexpected operator *} test expr-10.9 {CompileShiftExpr: error compiling shift arm} { catch {expr 2<>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": expected a parenthesis enclosing function arguments} +} {syntax error in expression "x*3": variable references require preceding $} 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": unexpected operator} +} {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": expected a parenthesis enclosing function arguments} +} {syntax error in expression "2-x": variable references require preceding $} 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": expected a parenthesis enclosing function arguments} +} {syntax error in expression "~x": variable references require preceding $} 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": unexpected operator} +} {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": expected a parenthesis enclosing function arguments} +} {syntax error in expression "2*x": variable references require preceding $} 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,7 +442,7 @@ 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": expected a parenthesis enclosing function arguments} +} {syntax error in expression "~x": variable references require preceding $} test expr-13.9 {CompileUnaryExpr: error compiling unary expr} { catch {expr !1.x} msg set msg @@ -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)": expected a parenthesis enclosing function arguments +} {syntax error in expression "sinh::(2.0)": expected parenthesis enclosing function arguments while compiling "expr sinh::(2.0)"} test expr-14.28 {CompilePrimaryExpr: subexpression primary} { @@ -597,7 +597,7 @@ test expr-14.32 {CompilePrimaryExpr: unexpected token} { test expr-15.1 {CompileMathFuncCall: missing parenthesis} { catch {expr sinh2.0)} msg set errorInfo -} {syntax error in expression "sinh2.0)": expected a parenthesis enclosing function arguments +} {syntax error in expression "sinh2.0)": variable references require preceding $ while compiling "expr sinh2.0)"} test expr-15.2 {CompileMathFuncCall: unknown math function} { diff --git a/tests/for.test b/tests/for.test index 95ba8d0..4fbeef7 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.8 2001/12/04 15:36:29 dkf Exp $ +# RCS: @(#) $Id: for.test,v 1.9 2001/12/06 10:59:18 dkf Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -668,7 +668,7 @@ test for-6.6 {Tcl_ForObjCmd: error in initial command} { test for-6.7 {Tcl_ForObjCmd: error in test expression} { set z for list [catch {$z {set i 0} {i < 5} {incr i} {body}} msg] $msg $errorInfo -} {1 {syntax error in expression "i < 5": expected a parenthesis enclosing function arguments} {syntax error in expression "i < 5": expected a parenthesis enclosing function arguments +} {1 {syntax error in expression "i < 5": variable references require preceding $} {syntax error in expression "i < 5": variable references require preceding $ while executing "$z {set i 0} {i < 5} {incr i} {body}"}} test for-6.8 {Tcl_ForObjCmd: test expression is enclosed in quotes} { diff --git a/tests/parseExpr.test b/tests/parseExpr.test index 0f9fb7e..958c515 100644 --- a/tests/parseExpr.test +++ b/tests/parseExpr.test @@ -8,7 +8,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: parseExpr.test,v 1.6 2001/12/04 15:36:29 dkf Exp $ +# RCS: @(#) $Id: parseExpr.test,v 1.7 2001/12/06 10:59:18 dkf Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -43,7 +43,7 @@ test parseExpr-1.3 {Tcl_ParseExpr procedure, error getting initial lexeme} {wide } {1 {integer value too large to represent}} test parseExpr-1.4 {Tcl_ParseExpr procedure, error in conditional expression} { list [catch {testexprparser {foo+} -1} msg] $msg -} {1 {syntax error in expression "foo+": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "foo+": variable references require preceding $}} test parseExpr-1.5 {Tcl_ParseExpr procedure, lexemes after the expression} { list [catch {testexprparser {1+2 345} -1} msg] $msg } {1 {syntax error in expression "1+2 345": extra tokens at end of expression}} @@ -53,7 +53,7 @@ test parseExpr-2.1 {ParseCondExpr procedure, valid test subexpr} { } {- {} 0 subexpr {2>3? 1 : 0} 11 operator ? 0 subexpr 2>3 5 operator > 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}} test parseExpr-2.2 {ParseCondExpr procedure, error in test subexpr} { list [catch {testexprparser {0 || foo} -1} msg] $msg -} {1 {syntax error in expression "0 || foo": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "0 || foo": variable references require preceding $}} test parseExpr-2.3 {ParseCondExpr procedure, next lexeme isn't "?"} { testexprparser {1+2} -1 } {- {} 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 {}} @@ -68,7 +68,7 @@ test parseExpr-2.6 {ParseCondExpr procedure, valid "then" subexpression} { } {- {} 0 subexpr {1? 3 : 4} 7 operator ? 0 subexpr 1 1 text 1 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}} test parseExpr-2.7 {ParseCondExpr procedure, error in "then" subexpression} { list [catch {testexprparser {1? fred : martha} -1} msg] $msg -} {1 {syntax error in expression "1? fred : martha": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1? fred : martha": variable references require preceding $}} test parseExpr-2.8 {ParseCondExpr procedure, lexeme after "then" subexpr isn't ":"} { list [catch {testexprparser {1? 2 martha 3} -1} msg] $msg } {1 {syntax error in expression "1? 2 martha 3": missing colon from ternary conditional}} @@ -77,14 +77,14 @@ test parseExpr-2.9 {ParseCondExpr procedure, valid "else" subexpression} { } {- {} 0 subexpr {27||3? 3 : 4&&9} 15 operator ? 0 subexpr 27||3 5 operator || 0 subexpr 27 1 text 27 0 subexpr 3 1 text 3 0 subexpr 3 1 text 3 0 subexpr 4&&9 5 operator && 0 subexpr 4 1 text 4 0 subexpr 9 1 text 9 0 {}} test parseExpr-2.10 {ParseCondExpr procedure, error in "else" subexpression} { list [catch {testexprparser {1? 2 : martha} -1} msg] $msg -} {1 {syntax error in expression "1? 2 : martha": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1? 2 : martha": variable references require preceding $}} test parseExpr-3.1 {ParseLorExpr procedure, valid logical and subexpr} { testexprparser {1&&2 || 3} -1 } {- {} 0 subexpr {1&&2 || 3} 9 operator || 0 subexpr 1&&2 5 operator && 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}} test parseExpr-3.2 {ParseLorExpr procedure, error in logical and subexpr} { list [catch {testexprparser {1&&foo || 3} -1} msg] $msg -} {1 {syntax error in expression "1&&foo || 3": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1&&foo || 3": variable references require preceding $}} test parseExpr-3.3 {ParseLorExpr procedure, next lexeme isn't "||"} { testexprparser {1&&2? 1 : 0} -1 } {- {} 0 subexpr {1&&2? 1 : 0} 11 operator ? 0 subexpr 1&&2 5 operator && 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}} @@ -99,14 +99,14 @@ test parseExpr-3.6 {ParseLorExpr procedure, valid RHS subexpression} { } {- {} 0 subexpr {1&&2 || 3 || 4} 13 operator || 0 subexpr {1&&2 || 3} 9 operator || 0 subexpr 1&&2 5 operator && 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}} test parseExpr-3.7 {ParseLorExpr procedure, error in RHS subexpression} { list [catch {testexprparser {1&&2 || 3 || martha} -1} msg] $msg -} {1 {syntax error in expression "1&&2 || 3 || martha": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1&&2 || 3 || martha": variable references require preceding $}} test parseExpr-4.1 {ParseLandExpr procedure, valid LHS "|" subexpr} { testexprparser {1|2 && 3} -1 } {- {} 0 subexpr {1|2 && 3} 9 operator && 0 subexpr 1|2 5 operator | 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}} test parseExpr-4.2 {ParseLandExpr procedure, error in LHS "|" subexpr} { list [catch {testexprparser {1&&foo && 3} -1} msg] $msg -} {1 {syntax error in expression "1&&foo && 3": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1&&foo && 3": variable references require preceding $}} test parseExpr-4.3 {ParseLandExpr procedure, next lexeme isn't "&&"} { testexprparser {1|2? 1 : 0} -1 } {- {} 0 subexpr {1|2? 1 : 0} 11 operator ? 0 subexpr 1|2 5 operator | 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}} @@ -121,14 +121,14 @@ test parseExpr-4.6 {ParseLandExpr procedure, valid RHS subexpression} { } {- {} 0 subexpr {1|2 && 3 && 4} 13 operator && 0 subexpr {1|2 && 3} 9 operator && 0 subexpr 1|2 5 operator | 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}} test parseExpr-4.7 {ParseLandExpr procedure, error in RHS subexpression} { list [catch {testexprparser {1|2 && 3 && martha} -1} msg] $msg -} {1 {syntax error in expression "1|2 && 3 && martha": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1|2 && 3 && martha": variable references require preceding $}} test parseExpr-5.1 {ParseBitOrExpr procedure, valid LHS "^" subexpr} { testexprparser {1^2 | 3} -1 } {- {} 0 subexpr {1^2 | 3} 9 operator | 0 subexpr 1^2 5 operator ^ 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}} test parseExpr-5.2 {ParseBitOrExpr procedure, error in LHS "^" subexpr} { list [catch {testexprparser {1|foo | 3} -1} msg] $msg -} {1 {syntax error in expression "1|foo | 3": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1|foo | 3": variable references require preceding $}} test parseExpr-5.3 {ParseBitOrExpr procedure, next lexeme isn't "|"} { testexprparser {1^2? 1 : 0} -1 } {- {} 0 subexpr {1^2? 1 : 0} 11 operator ? 0 subexpr 1^2 5 operator ^ 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}} @@ -143,14 +143,14 @@ test parseExpr-5.6 {ParseBitOrExpr procedure, valid RHS subexpression} { } {- {} 0 subexpr {1^2 | 3 | 4} 13 operator | 0 subexpr {1^2 | 3} 9 operator | 0 subexpr 1^2 5 operator ^ 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}} test parseExpr-5.7 {ParseBitOrExpr procedure, error in RHS subexpression} { list [catch {testexprparser {1^2 | 3 | martha} -1} msg] $msg -} {1 {syntax error in expression "1^2 | 3 | martha": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1^2 | 3 | martha": variable references require preceding $}} test parseExpr-6.1 {ParseBitXorExpr procedure, valid LHS "&" subexpr} { testexprparser {1&2 ^ 3} -1 } {- {} 0 subexpr {1&2 ^ 3} 9 operator ^ 0 subexpr 1&2 5 operator & 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}} test parseExpr-6.2 {ParseBitXorExpr procedure, error in LHS "&" subexpr} { list [catch {testexprparser {1^foo ^ 3} -1} msg] $msg -} {1 {syntax error in expression "1^foo ^ 3": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1^foo ^ 3": variable references require preceding $}} test parseExpr-6.3 {ParseBitXorExpr procedure, next lexeme isn't "^"} { testexprparser {1&2? 1 : 0} -1 } {- {} 0 subexpr {1&2? 1 : 0} 11 operator ? 0 subexpr 1&2 5 operator & 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}} @@ -165,14 +165,14 @@ test parseExpr-6.6 {ParseBitXorExpr procedure, valid RHS subexpression} { } {- {} 0 subexpr {1&2 ^ 3 ^ 4} 13 operator ^ 0 subexpr {1&2 ^ 3} 9 operator ^ 0 subexpr 1&2 5 operator & 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}} test parseExpr-6.7 {ParseBitXorExpr procedure, error in RHS subexpression} { list [catch {testexprparser {1&2 ^ 3 ^ martha} -1} msg] $msg -} {1 {syntax error in expression "1&2 ^ 3 ^ martha": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1&2 ^ 3 ^ martha": variable references require preceding $}} test parseExpr-7.1 {ParseBitAndExpr procedure, valid LHS equality subexpr} { testexprparser {1==2 & 3} -1 } {- {} 0 subexpr {1==2 & 3} 9 operator & 0 subexpr 1==2 5 operator == 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}} test parseExpr-7.2 {ParseBitAndExpr procedure, error in LHS equality subexpr} { list [catch {testexprparser {1!=foo & 3} -1} msg] $msg -} {1 {syntax error in expression "1!=foo & 3": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1!=foo & 3": variable references require preceding $}} test parseExpr-7.3 {ParseBitAndExpr procedure, next lexeme isn't "&"} { testexprparser {1==2? 1 : 0} -1 } {- {} 0 subexpr {1==2? 1 : 0} 11 operator ? 0 subexpr 1==2 5 operator == 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}} @@ -187,14 +187,14 @@ test parseExpr-7.6 {ParseBitAndExpr procedure, valid RHS subexpression} { } {- {} 0 subexpr {1<2 & 3 & 4} 13 operator & 0 subexpr {1<2 & 3} 9 operator & 0 subexpr 1<2 5 operator < 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}} test parseExpr-7.7 {ParseBitAndExpr procedure, error in RHS subexpression} { list [catch {testexprparser {1==2 & 3>2 & martha} -1} msg] $msg -} {1 {syntax error in expression "1==2 & 3>2 & martha": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1==2 & 3>2 & martha": variable references require preceding $}} test parseExpr-8.1 {ParseEqualityExpr procedure, valid LHS relational subexpr} { testexprparser {1<2 == 3} -1 } {- {} 0 subexpr {1<2 == 3} 9 operator == 0 subexpr 1<2 5 operator < 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}} test parseExpr-8.2 {ParseEqualityExpr procedure, error in LHS relational subexpr} { list [catch {testexprparser {1>=foo == 3} -1} msg] $msg -} {1 {syntax error in expression "1>=foo == 3": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1>=foo == 3": variable references require preceding $}} test parseExpr-8.3 {ParseEqualityExpr procedure, next lexeme isn't "==" or "!="} { testexprparser {1<2? 1 : 0} -1 } {- {} 0 subexpr {1<2? 1 : 0} 11 operator ? 0 subexpr 1<2 5 operator < 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}} @@ -212,14 +212,14 @@ test parseExpr-8.7 {ParseEqualityExpr procedure, valid RHS subexpression} { } {- {} 0 subexpr {1<2 == 3 == 4} 13 operator == 0 subexpr {1<2 == 3} 9 operator == 0 subexpr 1<2 5 operator < 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}} test parseExpr-8.8 {ParseEqualityExpr procedure, error in RHS subexpression} { list [catch {testexprparser {1<2 == 3 != martha} -1} msg] $msg -} {1 {syntax error in expression "1<2 == 3 != martha": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1<2 == 3 != martha": variable references require preceding $}} test parseExpr-9.1 {ParseRelationalExpr procedure, valid LHS shift subexpr} { testexprparser {1<<2 < 3} -1 } {- {} 0 subexpr {1<<2 < 3} 9 operator < 0 subexpr 1<<2 5 operator << 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}} test parseExpr-9.2 {ParseRelationalExpr procedure, error in LHS shift subexpr} { list [catch {testexprparser {1>=foo < 3} -1} msg] $msg -} {1 {syntax error in expression "1>=foo < 3": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1>=foo < 3": variable references require preceding $}} test parseExpr-9.3 {ParseRelationalExpr procedure, next lexeme isn't relational op} { testexprparser {1<<2? 1 : 0} -1 } {- {} 0 subexpr {1<<2? 1 : 0} 11 operator ? 0 subexpr 1<<2 5 operator << 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}} @@ -243,14 +243,14 @@ test parseExpr-9.9 {ParseRelationalExpr procedure, valid RHS subexpression} { } {- {} 0 subexpr {1<<2 < 3 < 4} 13 operator < 0 subexpr {1<<2 < 3} 9 operator < 0 subexpr 1<<2 5 operator << 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}} test parseExpr-9.10 {ParseRelationalExpr procedure, error in RHS subexpression} { list [catch {testexprparser {1<<2 < 3 > martha} -1} msg] $msg -} {1 {syntax error in expression "1<<2 < 3 > martha": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1<<2 < 3 > martha": variable references require preceding $}} test parseExpr-10.1 {ParseShiftExpr procedure, valid LHS add subexpr} { testexprparser {1+2 << 3} -1 } {- {} 0 subexpr {1+2 << 3} 9 operator << 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}} test parseExpr-10.2 {ParseShiftExpr procedure, error in LHS add subexpr} { list [catch {testexprparser {1-foo << 3} -1} msg] $msg -} {1 {syntax error in expression "1-foo << 3": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1-foo << 3": variable references require preceding $}} test parseExpr-10.3 {ParseShiftExpr procedure, next lexeme isn't "<<" or ">>"} { testexprparser {1+2? 1 : 0} -1 } {- {} 0 subexpr {1+2? 1 : 0} 11 operator ? 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}} @@ -268,14 +268,14 @@ test parseExpr-10.7 {ParseShiftExpr procedure, valid RHS subexpression} { } {- {} 0 subexpr {1+2 << 3 << 4} 13 operator << 0 subexpr {1+2 << 3} 9 operator << 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}} test parseExpr-10.8 {ParseShiftExpr procedure, error in RHS subexpression} { list [catch {testexprparser {1+2 << 3 >> martha} -1} msg] $msg -} {1 {syntax error in expression "1+2 << 3 >> martha": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1+2 << 3 >> martha": variable references require preceding $}} test parseExpr-11.1 {ParseAddExpr procedure, valid LHS multiply subexpr} { testexprparser {1*2 + 3} -1 } {- {} 0 subexpr {1*2 + 3} 9 operator + 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}} test parseExpr-11.2 {ParseAddExpr procedure, error in LHS multiply subexpr} { list [catch {testexprparser {1/foo + 3} -1} msg] $msg -} {1 {syntax error in expression "1/foo + 3": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1/foo + 3": variable references require preceding $}} test parseExpr-11.3 {ParseAddExpr procedure, next lexeme isn't "+" or "-"} { testexprparser {1*2? 1 : 0} -1 } {- {} 0 subexpr {1*2? 1 : 0} 11 operator ? 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}} @@ -293,14 +293,14 @@ test parseExpr-11.7 {ParseAddExpr procedure, valid RHS subexpression} { } {- {} 0 subexpr {1*2 + 3 + 4} 13 operator + 0 subexpr {1*2 + 3} 9 operator + 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}} test parseExpr-11.8 {ParseAddExpr procedure, error in RHS subexpression} { list [catch {testexprparser {1*2 + 3 - martha} -1} msg] $msg -} {1 {syntax error in expression "1*2 + 3 - martha": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1*2 + 3 - martha": variable references require preceding $}} test parseExpr-12.1 {ParseAddExpr procedure, valid LHS multiply subexpr} { testexprparser {1*2 + 3} -1 } {- {} 0 subexpr {1*2 + 3} 9 operator + 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}} test parseExpr-12.2 {ParseAddExpr procedure, error in LHS multiply subexpr} { list [catch {testexprparser {1/foo + 3} -1} msg] $msg -} {1 {syntax error in expression "1/foo + 3": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1/foo + 3": variable references require preceding $}} test parseExpr-12.3 {ParseAddExpr procedure, next lexeme isn't "+" or "-"} { testexprparser {1*2? 1 : 0} -1 } {- {} 0 subexpr {1*2? 1 : 0} 11 operator ? 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}} @@ -318,7 +318,7 @@ test parseExpr-12.7 {ParseAddExpr procedure, valid RHS subexpression} { } {- {} 0 subexpr {1*2 + 3 + 4} 13 operator + 0 subexpr {1*2 + 3} 9 operator + 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}} test parseExpr-12.8 {ParseAddExpr procedure, error in RHS subexpression} { list [catch {testexprparser {1*2 + 3 - martha} -1} msg] $msg -} {1 {syntax error in expression "1*2 + 3 - martha": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "1*2 + 3 - martha": variable references require preceding $}} test parseExpr-13.1 {ParseMultiplyExpr procedure, valid LHS unary subexpr} { testexprparser {+2 * 3} -1 @@ -346,7 +346,7 @@ test parseExpr-13.8 {ParseMultiplyExpr procedure, valid RHS subexpression} { } {- {} 0 subexpr {-2 / 3 % 4} 11 operator % 0 subexpr {-2 / 3} 7 operator / 0 subexpr -2 3 operator - 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}} test parseExpr-13.9 {ParseMultiplyExpr procedure, error in RHS subexpression} { list [catch {testexprparser {++2 / 3 * martha} -1} msg] $msg -} {1 {syntax error in expression "++2 / 3 * martha": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "++2 / 3 * martha": variable references require preceding $}} test parseExpr-14.1 {ParseUnaryExpr procedure, first token is unary operator} { testexprparser {+2} -1 @@ -371,10 +371,10 @@ test parseExpr-14.7 {ParseUnaryExpr procedure, another unary expr after unary op } {- {} 0 subexpr ~!{fred} 5 operator ~ 0 subexpr !{fred} 3 operator ! 0 subexpr {{fred}} 1 text fred 0 {}} test parseExpr-14.8 {ParseUnaryExpr procedure, error in unary expr after unary op} { list [catch {testexprparser {+-||27} -1} msg] $msg -} {1 {syntax error in expression "+-||27": unexpected operator}} +} {1 {syntax error in expression "+-||27": unexpected operator ||}} test parseExpr-14.9 {ParseUnaryExpr procedure, error in unary expr after unary op} { list [catch {testexprparser {+-||27} -1} msg] $msg -} {1 {syntax error in expression "+-||27": unexpected operator}} +} {1 {syntax error in expression "+-||27": unexpected operator ||}} test parseExpr-14.10 {ParseUnaryExpr procedure, first token is not unary op} { testexprparser {123} -1 } {- {} 0 subexpr 123 1 text 123 0 {}} @@ -457,7 +457,7 @@ test parseExpr-15.23 {ParsePrimaryExpr procedure, bad lexeme after function name } {1 {integer value too large to represent}} test parseExpr-15.24 {ParsePrimaryExpr procedure, lexeme after function name isn't "("} { list [catch {testexprparser {foo 27.4 123)} -1} msg] $msg -} {1 {syntax error in expression "foo 27.4 123)": expected a parenthesis enclosing function arguments}} +} {1 {syntax error in expression "foo 27.4 123)": variable references require preceding $}} test parseExpr-15.25 {ParsePrimaryExpr procedure, bad lexeme after "("} {wideIntegerUnparsed} { list [catch {testexprparser {foo(12345678901234567890)} -1} msg] $msg } {1 {integer value too large to represent}} @@ -466,10 +466,10 @@ test parseExpr-15.26 {ParsePrimaryExpr procedure, function call, one arg} { } {- {} 0 subexpr foo(27*4) 7 operator foo 0 subexpr 27*4 5 operator * 0 subexpr 27 1 text 27 0 subexpr 4 1 text 4 0 {}} test parseExpr-15.27 {ParsePrimaryExpr procedure, error in function arg} { list [catch {testexprparser {foo(*1-2)} -1} msg] $msg -} {1 {syntax error in expression "foo(*1-2)": unexpected operator}} +} {1 {syntax error in expression "foo(*1-2)": unexpected operator *}} test parseExpr-15.28 {ParsePrimaryExpr procedure, error in function arg} { list [catch {testexprparser {foo(*1-2)} -1} msg] $msg -} {1 {syntax error in expression "foo(*1-2)": unexpected operator}} +} {1 {syntax error in expression "foo(*1-2)": unexpected operator *}} test parseExpr-15.29 {ParsePrimaryExpr procedure, function call, comma after arg} { testexprparser {foo(27-2, (-2*[foo]))} -1 } {- {} 0 subexpr {foo(27-2, (-2*[foo]))} 15 operator foo 0 subexpr 27-2 5 operator - 0 subexpr 27 1 text 27 0 subexpr 2 1 text 2 0 subexpr {-2*[foo]} 7 operator * 0 subexpr -2 3 operator - 0 subexpr 2 1 text 2 0 subexpr {[foo]} 1 command {[foo]} 0 {}} -- cgit v0.12