aboutsummaryrefslogtreecommitdiff
path: root/tests/expr.test
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2010-01-24 12:03:40 +1000
committerSteve Bennett <steveb@workware.net.au>2010-10-15 11:02:44 +1000
commita17425e476861fde1e1ad824181f97e081740659 (patch)
treefce3d80fb5c271dddf1ab005ecdfd039ec52ebb4 /tests/expr.test
parentb9835f11e31b7e021da6b0831eac659425735ba2 (diff)
downloadjimtcl-a17425e476861fde1e1ad824181f97e081740659.zip
jimtcl-a17425e476861fde1e1ad824181f97e081740659.tar.gz
jimtcl-a17425e476861fde1e1ad824181f97e081740659.tar.bz2
New features, docs
Implement lsearch in C with options *: lsearch -exact, -glob, -regexp, -not, -bool, -all, -inline Add tests for lsearch and expand expr operators: in and ni (Tcl 8.6)
Diffstat (limited to 'tests/expr.test')
-rw-r--r--tests/expr.test45
1 files changed, 37 insertions, 8 deletions
diff --git a/tests/expr.test b/tests/expr.test
index b15ee36..d7c7b5e 100644
--- a/tests/expr.test
+++ b/tests/expr.test
@@ -86,19 +86,48 @@ test expr-1.17 "Rotate left" {
# This crashes older jim
test expr-2.1 "bogus unarymin" {
- expr {unarymin 1}
-} {-1}
+ catch {expr {unarymin 1}}
+ return 1
+} {1}
test expr-2.2 "Ternary operator - missing colon" {
- list [catch {expr {1 ? 2 3}} msg] $msg
-} {1 {Invalid expression: 1 ? 2 3}}
+ list [catch {expr {1 ? 2 3}} msg]
+} {1}
test expr-2.3 "Ternary operator - missing third term" {
- list [catch {expr {1 ? 2}} msg] $msg
-} {1 {Invalid expression: 1 ? 2}}
+ list [catch {expr {1 ? 2}} msg]
+} {1}
test expr-2.4 "Ternary operator - missing question" {
- list [catch {expr {1 : 2}} msg] $msg
-} {1 {Invalid expression: 1 : 2}}
+ list [catch {expr {1 : 2}} msg]
+} {1}
+
+test expr-3.1 "in, ni operators" {
+ set l {a b c d}
+ set c C
+ list [expr {"a" in $l}] [expr {$c in $l}] [expr {"b" ni $l}] [expr {$c ni $l}]
+} {1 0 0 1}
+
+test expr-3.2 "if: in, ni operators" {
+ set l {a b c d}
+ set a a
+ set c C
+ set result {}
+ if {$a in $l} {
+ lappend result 1
+ }
+ if {$c in $l} {
+ lappend result 2
+ }
+ if {$a ni $l} {
+ lappend result 3
+ }
+ if {$c ni $l} {
+ lappend result 4
+ }
+ if {"d" in $l} {
+ lappend result 5
+ }
+} {1 4 5}
testreport