diff options
author | dgp <dgp@users.sourceforge.net> | 2006-08-22 04:03:23 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2006-08-22 04:03:23 (GMT) |
commit | a9e01d92cd36a6bd0e284252cb645ebe343c7c36 (patch) | |
tree | 3c2ba6753261f2925bdb82db20c562b7454c6adf /tests/compExpr.test | |
parent | 3154c0f487e39f1d7ad82415bcb33fcfc614593b (diff) | |
download | tcl-a9e01d92cd36a6bd0e284252cb645ebe343c7c36.zip tcl-a9e01d92cd36a6bd0e284252cb645ebe343c7c36.tar.gz tcl-a9e01d92cd36a6bd0e284252cb645ebe343c7c36.tar.bz2 |
* tests/compExpr-old.test: Update existing tests to not fail
* tests/compExpr.test: with the new expr parser.
* tests/compile.test:
* tests/expr-old.test:
* tests/expr.test:
* tests/for.test:
* tests/if.test:
* tests/parseExpr.test:
* tests/while.test:
Diffstat (limited to 'tests/compExpr.test')
-rw-r--r-- | tests/compExpr.test | 78 |
1 files changed, 37 insertions, 41 deletions
diff --git a/tests/compExpr.test b/tests/compExpr.test index f2c7ffc..991033f 100644 --- a/tests/compExpr.test +++ b/tests/compExpr.test @@ -8,17 +8,13 @@ # 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.12 2006/08/02 20:03:37 das Exp $ +# RCS: @(#) $Id: compExpr.test,v 1.13 2006/08/22 04:03:23 dgp Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest namespace import -force ::tcltest::* } -# Constraint set on tests that depend on the exact format of the error messages -# of the pre-2006/07/05 expression parser (-DOLD_EXPR_PARSER=1) -testConstraint oldExprParser [expr {![testConstraint newExprParser]}] - if {[catch {expr T1()} msg] && $msg eq {invalid command name "tcl::mathfunc::T1"}} { testConstraint testmathfunctions 0 } else { @@ -30,9 +26,9 @@ catch {unset a} test compExpr-1.1 {TclCompileExpr procedure, successful expr parse and compile} { expr 1+2 } 3 -test compExpr-1.2 {TclCompileExpr procedure, error parsing expr} {oldExprParser} { - list [catch {expr 1+2+} msg] $msg -} {1 {syntax error in expression "1+2+": premature end of expression}} +test compExpr-1.2 {TclCompileExpr procedure, error parsing expr} -body { + expr 1+2+ +} -returnCodes error -match glob -result * test compExpr-1.3 {TclCompileExpr procedure, error compiling expr} -body { list [catch {expr "foo(123)"} msg] $msg } -match glob -result {1 {* "*foo"}} @@ -47,9 +43,9 @@ test compExpr-2.1 {CompileSubExpr procedure, TCL_TOKEN_WORD parse token} { set a 27 expr {"foo$a" < "bar"} } 0 -test compExpr-2.2 {CompileSubExpr procedure, error compiling TCL_TOKEN_WORD parse token} {oldExprParser} { - list [catch {expr {"00[expr 1+]" + 17}} msg] $msg -} {1 {syntax error in expression "1+": premature end of expression}} +test compExpr-2.2 {CompileSubExpr procedure, error compiling TCL_TOKEN_WORD parse token} -body { + expr {"00[expr 1+]" + 17} +} -returnCodes error -match glob -result * test compExpr-2.3 {CompileSubExpr procedure, TCL_TOKEN_TEXT parse token} { expr {{12345}} } 12345 @@ -66,9 +62,9 @@ test compExpr-2.6 {CompileSubExpr procedure, TCL_TOKEN_COMMAND parse token} { test compExpr-2.7 {CompileSubExpr procedure, TCL_TOKEN_COMMAND parse token} { expr {[]} } {} -test compExpr-2.8 {CompileSubExpr procedure, error in TCL_TOKEN_COMMAND parse token} {oldExprParser} { - list [catch {expr {[foo "bar"xxx] + 17}} msg] $msg -} {1 {extra characters after close-quote}} +test compExpr-2.8 {CompileSubExpr procedure, error in TCL_TOKEN_COMMAND parse token} -body { + expr {[foo "bar"xxx] + 17} +} -returnCodes error -match glob -result * test compExpr-2.9 {CompileSubExpr procedure, TCL_TOKEN_VARIABLE parse token} { catch {unset a} set a 123 @@ -158,18 +154,18 @@ test compExpr-2.33 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, normal o test compExpr-2.34 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, special operator} { expr {+2} } 2 -test compExpr-2.35 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, error in special operator} {oldExprParser} { - list [catch {expr {+[expr 1+]}} msg] $msg -} {1 {syntax error in expression "1+": premature end of expression}} +test compExpr-2.35 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, error in special operator} -body { + expr {+[expr 1+]} +} -returnCodes error -match glob -result * test compExpr-2.36 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, special operator} { expr {4+2} } 6 -test compExpr-2.37 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, error in special operator} {oldExprParser} { - list [catch {expr {[expr 1+]+5}} msg] $msg -} {1 {syntax error in expression "1+": premature end of expression}} -test compExpr-2.38 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, error in special operator} {oldExprParser} { - list [catch {expr {5+[expr 1+]}} msg] $msg -} {1 {syntax error in expression "1+": premature end of expression}} +test compExpr-2.37 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, error in special operator} -body { + expr {[expr 1+]+5} +} -returnCodes error -match glob -result * +test compExpr-2.38 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, error in special operator} -body { + expr {5+[expr 1+]} +} -returnCodes error -match glob -result * test compExpr-2.39 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, special operator} { expr {-2} } -2 @@ -212,9 +208,9 @@ test compExpr-3.2 {CompileLandOrLorExpr procedure, nonnumeric 1st operand} { set a no expr {$a&&1} } 0 -test compExpr-3.3 {CompileSubExpr procedure, error in 1st operand} {oldExprParser} { - list [catch {expr {[expr *2]||0}} msg] $msg -} {1 {syntax error in expression "*2": unexpected operator *}} +test compExpr-3.3 {CompileSubExpr procedure, error in 1st operand} -body { + expr {[expr *2]||0} +} -returnCodes error -match glob -result * test compExpr-3.4 {CompileLandOrLorExpr procedure, result is 1 or 0} { catch {unset a} catch {unset b} @@ -242,9 +238,9 @@ test compExpr-3.8 {CompileLandOrLorExpr procedure, nonnumeric 2nd operand} { set a no expr {1&&$a} } 0 -test compExpr-3.9 {CompileLandOrLorExpr procedure, error in 2nd operand} {oldExprParser} { - list [catch {expr {0||[expr %2]}} msg] $msg -} {1 {syntax error in expression "%2": unexpected operator %}} +test compExpr-3.9 {CompileLandOrLorExpr procedure, error in 2nd operand} -body { + expr {0||[expr %2]} +} -returnCodes error -match glob -result * test compExpr-3.10 {CompileLandOrLorExpr procedure, long lor/land arm} { set a "abcdefghijkl" set i 7 @@ -261,9 +257,9 @@ test compExpr-4.2 {CompileCondExpr procedure, complex test, convert to numeric} set a no expr {[set a]? 27 : -54} } -54 -test compExpr-4.3 {CompileCondExpr procedure, error in test} {oldExprParser} { - list [catch {expr {[expr *2]? +1 : -1}} msg] $msg -} {1 {syntax error in expression "*2": unexpected operator *}} +test compExpr-4.3 {CompileCondExpr procedure, error in test} -body { + expr {[expr *2]? +1 : -1} +} -returnCodes error -match glob -result * test compExpr-4.4 {CompileCondExpr procedure, simple "true" clause} { catch {unset a} set a no @@ -274,9 +270,9 @@ test compExpr-4.5 {CompileCondExpr procedure, convert "true" clause to numeric} set a no expr {1? $a : -54} } no -test compExpr-4.6 {CompileCondExpr procedure, error in "true" clause} {oldExprParser} { - list [catch {expr {1? [expr *2] : -127}} msg] $msg -} {1 {syntax error in expression "*2": unexpected operator *}} +test compExpr-4.6 {CompileCondExpr procedure, error in "true" clause} -body { + expr {1? [expr *2] : -127} +} -returnCodes error -match glob -result * test compExpr-4.7 {CompileCondExpr procedure, simple "false" clause} { catch {unset a} set a no @@ -309,9 +305,9 @@ test compExpr-5.5 {CompileMathFuncCall procedure, too few arguments} -body { test compExpr-5.6 {CompileMathFuncCall procedure, complex argument} { format %.6g [expr pow(2.1, 27.5-(24.4*(5%2)))] } 9.97424 -test compExpr-5.7 {CompileMathFuncCall procedure, error in argument} {oldExprParser} { - list [catch {expr {sinh(2.*)}} msg] $msg -} {1 {syntax error in expression "sinh(2.*)": unexpected close parenthesis}} +test compExpr-5.7 {CompileMathFuncCall procedure, error in argument} -body { + expr {sinh(2.*)} +} -returnCodes error -match glob -result * test compExpr-5.8 {CompileMathFuncCall procedure, too many arguments} -body { list [catch {expr {sinh(2.0, 3.0)}} msg] $msg } -match glob -result {1 {too many arguments for math function*}} @@ -319,9 +315,9 @@ test compExpr-5.9 {CompileMathFuncCall procedure, too many arguments} -body { list [catch {expr {0 <= rand(5.2)}} msg] $msg } -match glob -result {1 {too many arguments for math function*}} -test compExpr-6.1 {LogSyntaxError procedure, error in expr longer than 60 chars} {oldExprParser} { - list [catch {expr {(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)/} -1 foo 3} msg] $msg -} {1 {syntax error in expression "(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+012...": extra tokens at end of expression}} +test compExpr-6.1 {LogSyntaxError procedure, error in expr longer than 60 chars} -body { + expr {(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)/} -1 foo 3 +} -returnCodes error -match glob -result * # cleanup catch {unset a} |