summaryrefslogtreecommitdiffstats
path: root/tests/expr.test
diff options
context:
space:
mode:
authorhobbs <hobbs@noemail.net>2000-05-09 00:00:34 (GMT)
committerhobbs <hobbs@noemail.net>2000-05-09 00:00:34 (GMT)
commit040618a8dabf810f5a28a56e494fdf9802b6f87b (patch)
tree1e3bab60e826e937b67fa7d70d97f4f352fe315a /tests/expr.test
parent2c10a8f6eeecb313b0bef7da8e611ec9f20200b6 (diff)
downloadtcl-040618a8dabf810f5a28a56e494fdf9802b6f87b.zip
tcl-040618a8dabf810f5a28a56e494fdf9802b6f87b.tar.gz
tcl-040618a8dabf810f5a28a56e494fdf9802b6f87b.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). FossilOrigin-Name: 0d91727189902e0a4d26a1475c4ecdd1bfda037e
Diffstat (limited to 'tests/expr.test')
-rw-r--r--tests/expr.test33
1 files changed, 30 insertions, 3 deletions
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