diff options
author | Nikita Borodikhin <eliterr@gmail.com> | 2016-07-09 03:23:10 -0700 |
---|---|---|
committer | Nikita Borodikhin <eliterr@gmail.com> | 2016-07-10 01:36:22 -0700 |
commit | 245b2009c66f3b3698773d8c49a834913db7d656 (patch) | |
tree | af9ca48f8de63021131713aa9e8874db30592eeb /tests | |
parent | 3d2168352d3d2125ef0a70bd34c6af025687a5e7 (diff) | |
download | jimtcl-245b2009c66f3b3698773d8c49a834913db7d656.zip jimtcl-245b2009c66f3b3698773d8c49a834913db7d656.tar.gz jimtcl-245b2009c66f3b3698773d8c49a834913db7d656.tar.bz2 |
Boolean contstants in expr, `string is boolean` classification
* named boolean values in `expr` are internally converted to int
* named constants are lower-case only
Diffstat (limited to 'tests')
-rw-r--r-- | tests/expr-new.test | 36 | ||||
-rw-r--r-- | tests/string.test | 38 | ||||
-rw-r--r-- | tests/while.test | 4 |
3 files changed, 75 insertions, 3 deletions
diff --git a/tests/expr-new.test b/tests/expr-new.test index e3c4378..86e776b 100644 --- a/tests/expr-new.test +++ b/tests/expr-new.test @@ -574,6 +574,42 @@ test expr-20.7 {handling of compile error in runtime case} { list [catch {expr + {[error foo]}} msg] } {1} +test expr-21.1 {checking boolean 0} { + expr 0 +} 0 +test expr-21.2 {checking boolean 0} { + expr {0 || 0} +} 0 +test expr-21.3 {checking boolean false} { + expr {0 || false} +} 0 +test expr-21.4 {checking boolean no} { + expr {0 || no} +} 0 +test expr-21.5 {checking boolean off} { + expr {0 || off} +} 0 +test expr-21.6 {checking boolean 1} { + expr {0 || 1} +} 1 +test expr-21.7 {checking boolean true} { + expr {0 || true} +} 1 +test expr-21.8 {checking boolean yes} { + expr {0 || yes} +} 1 +test expr-21.9 {checking boolean on} { + expr {0 || on} +} 1 +test expr-21.7 {checking boolean mixed case} { + set res 0 + try { + expr {0 || True} + } on error {msg} { + set res 1 + } +} 1 + # cleanup if {[info exists a]} { unset a diff --git a/tests/string.test b/tests/string.test index 33723b7..b095f60 100644 --- a/tests/string.test +++ b/tests/string.test @@ -232,10 +232,10 @@ test string-6.4 {string is, too many args} jim { } {1 {wrong # args: should be "string is class ?-strict? str"}} test string-6.5 {string is, class check} jim { list [catch {string is bogus str} msg] $msg -} {1 {bad class "bogus": must be alnum, alpha, ascii, control, digit, double, graph, integer, lower, print, punct, space, upper, or xdigit}} +} {1 {bad class "bogus": must be alnum, alpha, ascii, boolean, control, digit, double, graph, integer, lower, print, punct, space, upper, or xdigit}} test string-6.6 {string is, ambiguous class} jim { list [catch {string is al str} msg] $msg -} {1 {ambiguous class "al": must be alnum, alpha, ascii, control, digit, double, graph, integer, lower, print, punct, space, upper, or xdigit}} +} {1 {ambiguous class "al": must be alnum, alpha, ascii, boolean, control, digit, double, graph, integer, lower, print, punct, space, upper, or xdigit}} test string-6.10 {string is, ok on empty} { string is alpha {} } 1 @@ -389,7 +389,39 @@ test string-6.88 {string is punct} { test string-6.89 {string is xdigit} { list [string is xdigit 0123456789\u0061bcdefABCDEFg] } 0 - +test string-6.90 {string is boolean, true} { + list [string is boolean 0] +} 1 +test string-6.91 {string is boolean, true} { + list [string is boolean false] +} 1 +test string-6.92 {string is boolean, true} { + list [string is boolean no] +} 1 +test string-6.93 {string is boolean, true} { + list [string is boolean off] +} 1 +test string-6.94 {string is boolean, true} { + list [string is boolean 1] +} 1 +test string-6.95 {string is boolean, true} { + list [string is boolean true] +} 1 +test string-6.96 {string is boolean, true} { + list [string is boolean yes] +} 1 +test string-6.97 {string is boolean, true} { + list [string is boolean on] +} 1 +test string-6.98 {string is boolean, not boolean string, false} { + list [string is boolean a] +} 0 +test string-6.99 {string is boolean, special character, false} { + list [string is boolean -] +} 0 +test string-6.10 {string is boolean, mixed case, false} { + list [string is boolean True] +} 0 test string-7.1 {string last, too few args} { list [catch {string last a} msg] } {1} diff --git a/tests/while.test b/tests/while.test index de6d9b5..165791d 100644 --- a/tests/while.test +++ b/tests/while.test @@ -110,6 +110,10 @@ test while-old-5.2 {while return result} { set x 1 while {$x} {set x 0} } {} +test while-old-5.3 {while return result} { + set x true + while {$x} {set x 0} +} {} # cleanup testreport |