diff options
author | hobbs <hobbs> | 2000-05-09 00:00:34 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2000-05-09 00:00:34 (GMT) |
commit | 427c904742d9d5aec8068fce38a28be9ae65af08 (patch) | |
tree | 1e3bab60e826e937b67fa7d70d97f4f352fe315a /tests | |
parent | 9f7b9b72befea46deb71233146973eea88223af0 (diff) | |
download | tcl-427c904742d9d5aec8068fce38a28be9ae65af08.zip tcl-427c904742d9d5aec8068fce38a28be9ae65af08.tar.gz tcl-427c904742d9d5aec8068fce38a28be9ae65af08.tar.bz2 |
* doc/expr.n:
* tests/expr.test:
* tests/expr-old.test: added tests for 'eq' and 'ne'
* generic/tclExecute.c:
* generic/tclCompile.h: added INST_STREQ and INST_STRNEQ opcodes
that do strict string comparisons.
* generic/tclCompExpr.c: added 'eq' and 'ne' string comparison
operators.
* generic/tclParseExpr.c (GetLexeme): added 'eq' and 'ne' expr
parse terms (string (in)equality check).
Diffstat (limited to 'tests')
-rw-r--r-- | tests/expr-old.test | 34 | ||||
-rw-r--r-- | tests/expr.test | 33 |
2 files changed, 59 insertions, 8 deletions
diff --git a/tests/expr-old.test b/tests/expr-old.test index 4d44b55..b810d6f 100644 --- a/tests/expr-old.test +++ b/tests/expr-old.test @@ -8,12 +8,12 @@ # # Copyright (c) 1991-1994 The Regents of the University of California. # Copyright (c) 1994-1997 Sun Microsystems, Inc. -# Copyright (c) 1998-1999 by Scriptics Corporation. +# Copyright (c) 1998-2000 by Scriptics Corporation. # # 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.8 2000/04/10 17:18:58 ericm Exp $ +# RCS: @(#) $Id: expr-old.test,v 1.9 2000/05/09 00:00:36 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -186,6 +186,16 @@ test expr-old-4.15 {string operators} {expr {"abc" != "abd"}} 1 test expr-old-4.16 {string operators} {expr {"abd" != "abd"}} 0 test expr-old-4.17 {string operators} {expr {"0y" < "0x12"}} 0 test expr-old-4.18 {string operators} {expr {"." < " "}} 0 +test expr-old-4.19 {string operators} {expr {"abc" eq "abd"}} 0 +test expr-old-4.20 {string operators} {expr {"abd" eq "abd"}} 1 +test expr-old-4.21 {string operators} {expr {"abc" ne "abd"}} 1 +test expr-old-4.22 {string operators} {expr {"abd" ne "abd"}} 0 +test expr-old-4.23 {string operators} {expr {"" eq "abd"}} 0 +test expr-old-4.24 {string operators} {expr {"" eq ""}} 1 +test expr-old-4.25 {string operators} {expr {"abd" ne ""}} 1 +test expr-old-4.26 {string operators} {expr {"" ne ""}} 0 +test expr-old-4.26 {string operators} {expr {"longerstring" eq "shorter"}} 0 +test expr-old-4.26 {string operators} {expr {"longerstring" ne "shorter"}} 1 # The following tests are non-portable because on some systems "+" # and "-" can be parsed as numbers. @@ -305,14 +315,28 @@ test expr-old-14.5 {precedence checks} {expr 1==4>=3} 1 test expr-old-14.6 {precedence checks} {expr 0!=4>=3} 1 test expr-old-14.7 {precedence checks} {expr 1==3<=4} 1 test expr-old-14.8 {precedence checks} {expr 0!=3<=4} 1 +test expr-old-14.9 {precedence checks} {expr 1eq4>3} 1 +test expr-old-14.10 {precedence checks} {expr 0ne4>3} 1 +test expr-old-14.11 {precedence checks} {expr 1eq3<4} 1 +test expr-old-14.12 {precedence checks} {expr 0ne3<4} 1 +test expr-old-14.13 {precedence checks} {expr 1eq4>=3} 1 +test expr-old-14.14 {precedence checks} {expr 0ne4>=3} 1 +test expr-old-14.15 {precedence checks} {expr 1eq3<=4} 1 +test expr-old-14.16 {precedence checks} {expr 0ne3<=4} 1 test expr-old-15.1 {precedence checks} {expr 1==3==3} 0 test expr-old-15.2 {precedence checks} {expr 3==3!=2} 1 test expr-old-15.3 {precedence checks} {expr 2!=3==3} 0 test expr-old-15.4 {precedence checks} {expr 2!=1!=1} 0 - -test expr-old-16.1 {precedence checks} {expr 2&3==2} 0 -test expr-old-16.2 {precedence checks} {expr 1&3!=3} 0 +test expr-old-15.5 {precedence checks} {expr 1eq3eq3} 0 +test expr-old-15.6 {precedence checks} {expr 3eq3ne2} 1 +test expr-old-15.7 {precedence checks} {expr 2ne3eq3} 0 +test expr-old-15.8 {precedence checks} {expr 2ne1ne1} 0 + +test expr-old-16.1 {precedence checks} {expr 2&3eq2} 0 +test expr-old-16.2 {precedence checks} {expr 1&3ne3} 0 +test expr-old-16.3 {precedence checks} {expr 2&3eq2} 0 +test expr-old-16.4 {precedence checks} {expr 1&3ne3} 0 test expr-old-17.1 {precedence checks} {expr 7&3^0x10} 19 test expr-old-17.2 {precedence checks} {expr 7^0x10&3} 7 diff --git a/tests/expr.test b/tests/expr.test index 13d5583..9ea5026 100644 --- a/tests/expr.test +++ b/tests/expr.test @@ -5,12 +5,12 @@ # generates output for errors. No output means no errors were found. # # Copyright (c) 1996-1997 Sun Microsystems, Inc. -# Copyright (c) 1998-1999 by Scriptics Corporation. +# Copyright (c) 1998-2000 by Scriptics Corporation. # # 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.9 2000/04/10 17:18:59 ericm Exp $ +# RCS: @(#) $Id: expr.test,v 1.10 2000/05/09 00:00:37 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -126,6 +126,11 @@ test expr-1.14 {TclCompileExprCmd: second level of substitutions in expr with co set x 2; set b {$x}; set a [expr $b == 2] set a } 1 +test expr-1.15 {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 eq 2] + set a +} 1 test expr-2.1 {TclCompileExpr: are builtin functions registered?} { expr double(5*[llength "6 2"]) @@ -269,6 +274,12 @@ test expr-7.12 {CompileBitAndExpr: runtime error in bitand arm} { test expr-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-7.14 {CompileBitAndExpr: equality expr} {expr 3eq2} 0 +test expr-7.18 {CompileBitAndExpr: equality expr} {expr {"abc" eq "abd"}} 0 +test expr-7.20 {CompileBitAndExpr: error in equality expr} { + catch {expr xne3} msg + set msg +} {syntax error in expression "xne3"} 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 @@ -290,7 +301,23 @@ test expr-8.11 {CompileEqualityExpr: error compiling equality arm} { catch {expr 2!=x} msg set msg } {syntax error in expression "2!=x"} - +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 +test expr-8.15 {CompileBitAndExpr: equality expr} {expr 2.0eq2} 0 +test expr-8.16 {CompileBitAndExpr: equality expr} {expr 3.2ne2.2} 1 +test expr-8.17 {CompileBitAndExpr: equality expr} {expr 01eq1} 0 +test expr-8.18 {CompileBitAndExpr: equality expr} {expr {"abc" eq "abd"}} 0 +test expr-8.19 {CompileBitAndExpr: equality expr} {expr {"abc" ne "abd"}} 1 +test expr-8.20 {CompileBitAndExpr: error in equality expr} { + catch {expr xne3} msg + set msg +} {syntax error in expression "xne3"} +test expr-8.20 {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"} test expr-9.1 {CompileRelationalExpr: just shift expr} {expr 3<<2} 12 test expr-9.2 {CompileRelationalExpr: just shift expr} {expr 0xff>>2} 63 |