diff options
Diffstat (limited to 'tests/string.test')
-rw-r--r-- | tests/string.test | 393 |
1 files changed, 334 insertions, 59 deletions
diff --git a/tests/string.test b/tests/string.test index 555e5ce..c3cfc3c 100644 --- a/tests/string.test +++ b/tests/string.test @@ -19,17 +19,15 @@ if {[lsearch [namespace children] ::tcltest] == -1} { # Some tests require the testobj command -set ::tcltest::testConstraints(testobj) \ - [expr {[info commands testobj] != {}}] -set ::tcltest::testConstraints(testindexobj) \ - [expr {[info commands testindexobj] != {}}] +testConstraint testobj [expr {[info commands testobj] != {}}] +testConstraint testindexobj [expr {[info commands testindexobj] != {}}] test string-1.1 {error conditions} { list [catch {string gorp a b} msg] $msg -} {1 {bad option "gorp": must be bytelength, compare, equal, first, index, is, last, length, map, match, range, repeat, replace, tolower, toupper, totitle, trim, trimleft, trimright, wordend, or wordstart}} +} {1 {unknown or ambiguous subcommand "gorp": must be bytelength, compare, equal, first, index, is, last, length, map, match, range, repeat, replace, reverse, tolower, totitle, toupper, trim, trimleft, trimright, wordend, or wordstart}} test string-1.2 {error conditions} { list [catch {string} msg] $msg -} {1 {wrong # args: should be "string option arg ?arg ...?"}} +} {1 {wrong # args: should be "string subcommand ?argument ...?"}} test string-2.1 {string compare, too few args} { list [catch {string compare a} msg] $msg @@ -173,13 +171,13 @@ test string-3.8 {string equal with length, unequal strings} { test string-4.1 {string first, too few args} { list [catch {string first a} msg] $msg -} {1 {wrong # args: should be "string first subString string ?startIndex?"}} +} {1 {wrong # args: should be "string first needleString haystackString ?startIndex?"}} test string-4.2 {string first, bad args} { list [catch {string first a b c} msg] $msg -} {1 {bad index "c": must be integer or end?-integer?}} +} {1 {bad index "c": must be integer?[+-]integer? or end?[+-]integer?}} test string-4.3 {string first, too many args} { list [catch {string first a b 5 d} msg] $msg -} {1 {wrong # args: should be "string first subString string ?startIndex?"}} +} {1 {wrong # args: should be "string first needleString haystackString ?startIndex?"}} test string-4.4 {string first} { string first bq abcdefgbcefgbqrs } 12 @@ -241,7 +239,7 @@ test string-5.6 {string index} { } {0 {}} test string-5.7 {string index} { list [catch {string index a xyz} msg] $msg -} {1 {bad index "xyz": must be integer or end?-integer?}} +} {1 {bad index "xyz": must be integer?[+-]integer? or end?[+-]integer?}} test string-5.8 {string index} { string index abc end } c @@ -274,12 +272,12 @@ test string-5.16 {string index, bytearray object with string obj shimmering} { binary scan $str H* dump string compare [string index $str 10] \x00 } 0 -test string-5.17 {string index, bad integer} { - list [catch {string index "abc" 08} msg] $msg -} {1 {bad index "08": must be integer or end?-integer? (looks like invalid octal number)}} -test string-5.18 {string index, bad integer} { - list [catch {string index "abc" end-00289} msg] $msg -} {1 {bad index "end-00289": must be integer or end?-integer? (looks like invalid octal number)}} +test string-5.17 {string index, bad integer} -body { + list [catch {string index "abc" 0o8} msg] $msg +} -match glob -result {1 {*invalid octal number*}} +test string-5.18 {string index, bad integer} -body { + list [catch {string index "abc" end-0o0289} msg] $msg +} -match glob -result {1 {*invalid octal number*}} test string-5.19 {string index, bytearray object out of bounds} { string index [binary format I* {0x50515253 0x52}] -1 } {} @@ -293,7 +291,7 @@ proc largest_int {} { # so we can test for overflow properly below on >32 bit systems set int 1 set exp 7; # assume we get at least 8 bits - while {$int > 0} { set int [expr {wide(1) << [incr exp]}] } + while {wide($int) > 0} { set int [expr {wide(1) << [incr exp]}] } return [expr {$int-1}] } @@ -311,10 +309,10 @@ test string-6.4 {string is, too many args} { } {1 {wrong # args: should be "string is class ?-strict? ?-failindex var? str"}} test string-6.5 {string is, class check} { list [catch {string is bogus str} msg] $msg -} {1 {bad class "bogus": must be alnum, alpha, ascii, control, boolean, digit, double, false, graph, integer, lower, print, punct, space, true, upper, wordchar, or xdigit}} +} {1 {bad class "bogus": must be alnum, alpha, ascii, control, boolean, digit, double, false, graph, integer, list, lower, print, punct, space, true, upper, wideinteger, wordchar, or xdigit}} test string-6.6 {string is, ambiguous class} { list [catch {string is al str} msg] $msg -} {1 {ambiguous class "al": must be alnum, alpha, ascii, control, boolean, digit, double, false, graph, integer, lower, print, punct, space, true, upper, wordchar, or xdigit}} +} {1 {ambiguous class "al": must be alnum, alpha, ascii, control, boolean, digit, double, false, graph, integer, list, lower, print, punct, space, true, upper, wideinteger, wordchar, or xdigit}} test string-6.7 {string is alpha, all ok} { string is alpha -strict -failindex var abc } 1 @@ -338,7 +336,7 @@ test string-6.13 {string is alnum, false} { list [string is alnum -failindex var abc1.23] $var } {0 4} test string-6.14 {string is alnum, unicode} { - string is alnum abcü + string is alnum abc\u00fc } 1 test string-6.15 {string is alpha, true} { string is alpha abc @@ -350,11 +348,11 @@ test string-6.17 {string is alpha, unicode} { string is alpha abc\374 } 1 test string-6.18 {string is ascii, true} { - string is ascii abc\u007Fend + string is ascii abc\u007Fend\u0000 } 1 test string-6.19 {string is ascii, false} { - list [string is ascii -fail var abcdef\u0080more] $var -} {0 6} + list [string is ascii -fail var abc\u0000def\u0080more] $var +} {0 7} test string-6.20 {string is boolean, true} { string is boolean true } 1 @@ -371,7 +369,7 @@ test string-6.24 {string is digit, true} { string is digit 0123456789 } 1 test string-6.25 {string is digit, false} { - list [string is digit -fail var 0123Ü567] $var + list [string is digit -fail var 0123\u00dc567] $var } {0 4} test string-6.26 {string is digit, false} { list [string is digit -fail var +123567] $var @@ -408,16 +406,18 @@ test string-6.36 {string is double, false} { } {0 0} test string-6.37 {string is double, false on int overflow} { # Make it the largest int recognizable, with one more digit for overflow + # Since bignums arrived in Tcl 8.5, the sense of this test changed. + # Now integer values that exceed native limits become bignums, and + # bignums can convert to doubles without error. list [string is double -fail var [largest_int]0] $var -} {0 -1} -test string-6.38 {string is double, false on underflow} { - catch {unset var} - list [string is double -fail var 123e-9999] $var -} {0 -1} -test string-6.39 {string is double, false} {nonPortable} { +} {1 0} +# string-6.38 removed, underflow on input is no longer an error. +test string-6.39 {string is double, false} { # This test is non-portable because IRIX thinks # that .e1 is a valid double - this is really a bug # on IRIX as .e1 should NOT be a valid double + # + # Portable now. Tcl 8.5 does its own double parsing. list [string is double -fail var .e1] $var } {0 0} @@ -478,8 +478,11 @@ test string-6.57 {string is integer, false} { list [string is integer -fail var " "] $var } {0 0} test string-6.58 {string is integer, false on bad octal} { - list [string is integer -fail var 036963] $var -} {0 3} + list [string is integer -fail var 0o36963] $var +} {0 4} +test string-6.58.1 {string is integer, false on bad octal} { + list [string is integer -fail var 0o36963] $var +} {0 4} test string-6.59 {string is integer, false on bad hex} { list [string is integer -fail var 0X345XYZ] $var } {0 5} @@ -487,7 +490,7 @@ test string-6.60 {string is lower, true} { string is lower abc } 1 test string-6.61 {string is lower, unicode true} { - string is lower abcüue + string is lower abc\u00fcue } 1 test string-6.62 {string is lower, false} { list [string is lower -fail var aBc] $var @@ -496,7 +499,7 @@ test string-6.63 {string is lower, false} { list [string is lower -fail var abc1] $var } {0 3} test string-6.64 {string is lower, unicode false} { - list [string is lower -fail var abÜUE] $var + list [string is lower -fail var ab\u00dcUE] $var } {0 2} test string-6.65 {string is space, true} { string is space " \t\n\v\f" @@ -534,7 +537,7 @@ test string-6.75 {string is upper, true} { string is upper ABC } 1 test string-6.76 {string is upper, unicode true} { - string is upper ABCÜUE + string is upper ABC\u00dcUE } 1 test string-6.77 {string is upper, false} { list [string is upper -fail var AbC] $var @@ -543,13 +546,13 @@ test string-6.78 {string is upper, false} { list [string is upper -fail var AB2C] $var } {0 2} test string-6.79 {string is upper, unicode false} { - list [string is upper -fail var ABCüue] $var + list [string is upper -fail var ABC\u00fcue] $var } {0 3} test string-6.80 {string is wordchar, true} { string is wordchar abc_123 } 1 test string-6.81 {string is wordchar, unicode true} { - string is wordchar abcüabÜAB\u5001 + string is wordchar abc\u00fcab\u00dcAB\u5001 } 1 test string-6.82 {string is wordchar, false} { list [string is wordchar -fail var abcd.ef] $var @@ -614,18 +617,74 @@ test string-6.94 {string is integer, 32-bit overflow} { set x 0x100000000 list [string is integer -failindex var [expr {$x}]] $var } {0 -1} +test string-6.95 {string is wideinteger, true} { + string is wideinteger +1234567890 +} 1 +test string-6.96 {string is wideinteger, true on type} { + string is wideinteger [expr wide(50.0)] +} 1 +test string-6.97 {string is wideinteger, true} { + string is wideinteger [list -10] +} 1 +test string-6.98 {string is wideinteger, true as hex} { + string is wideinteger 0xabcdef +} 1 +test string-6.99 {string is wideinteger, true as octal} { + string is wideinteger 0123456 +} 1 +test string-6.100 {string is wideinteger, true with whitespace} { + string is wideinteger " \n1234\v" +} 1 +test string-6.101 {string is wideinteger, false} { + list [string is wideinteger -fail var 123abc] $var +} {0 3} +test string-6.102 {string is wideinteger, false on overflow} { + list [string is wideinteger -fail var +[largest_int]0] $var +} {0 -1} +test string-6.103 {string is wideinteger, false} { + list [string is wideinteger -fail var [expr double(1)]] $var +} {0 1} +test string-6.104 {string is wideinteger, false} { + list [string is wideinteger -fail var " "] $var +} {0 0} +test string-6.105 {string is wideinteger, false on bad octal} { + list [string is wideinteger -fail var 0o36963] $var +} {0 4} +test string-6.105.1 {string is wideinteger, false on bad octal} { + list [string is wideinteger -fail var 0o36963] $var +} {0 4} +test string-6.106 {string is wideinteger, false on bad hex} { + list [string is wideinteger -fail var 0X345XYZ] $var +} {0 5} +test string-6.107 {string is integer, bad integers} { + # SF bug #634856 + set result "" + set numbers [list 1 +1 ++1 +-1 -+1 -1 --1 "- +1"] + foreach num $numbers { + lappend result [string is wideinteger -strict $num] + } + set result +} {1 1 0 0 0 1 0 0} +test string-6.108 {string is double, Bug 1382287} { + set x 2turtledoves + string is double $x + string is double $x +} 0 +test string-6.109 {string is double, Bug 1360532} { + string is double 1\u00a0 +} 0 catch {rename largest_int {}} test string-7.1 {string last, too few args} { list [catch {string last a} msg] $msg -} {1 {wrong # args: should be "string last subString string ?startIndex?"}} +} {1 {wrong # args: should be "string last needleString haystackString ?startIndex?"}} test string-7.2 {string last, bad args} { list [catch {string last a b c} msg] $msg -} {1 {bad index "c": must be integer or end?-integer?}} +} {1 {bad index "c": must be integer?[+-]integer? or end?[+-]integer?}} test string-7.3 {string last, too many args} { list [catch {string last a b c d} msg] $msg -} {1 {wrong # args: should be "string last subString string ?startIndex?"}} +} {1 {wrong # args: should be "string last needleString haystackString ?startIndex?"}} test string-7.4 {string last} { string la xxx xxxx123xx345x678 } 1 @@ -760,10 +819,10 @@ test string-10.18 {string map, empty argument} { test string-10.19 {string map, empty arguments} { string map -nocase {{} abc f bar {} def} foo } baroo -test string-10.20 {string map, nasty sharing crash from [Bug 1018562]} { - set a {a b} - string map $a $a -} {b b} +test string-10.20 {string map, dictionaries don't alter map ordering} { + set map {aa X a Y} + list [string map [dict create aa X a Y] aaa] [string map $map aaa] [dict size $map] [string map $map aaa] +} {XY XY 2 XY} test string-10.21 {string map, ABR checks} { string map {longstring foob} long } long @@ -794,6 +853,10 @@ test string-10.29 {string map, ABR checks} { test string-10.30 {string map, ABR checks} { string map {lon foob longstring bar} longlon } foobgfoob +test string-10.31 {string map, nasty sharing crash from [Bug 1018562]} { + set a {a b} + string map $a $a +} {b b} test string-11.1 {string match, too few args} { list [catch {string match a} msg] $msg @@ -822,9 +885,54 @@ test string-11.8 {string match} { test string-11.9 {string match} { string match *3*6*9 0123456789 } 1 +test string-11.9.1 {string match} { + string match *3*6*89 0123456789 +} 1 +test string-11.9.2 {string match} { + string match *3*456*89 0123456789 +} 1 +test string-11.9.3 {string match} { + string match *3*6* 0123456789 +} 1 +test string-11.9.4 {string match} { + string match *3*56* 0123456789 +} 1 +test string-11.9.5 {string match} { + string match *3*456*** 0123456789 +} 1 +test string-11.9.6 {string match} { + string match **3*456** 0123456789 +} 1 +test string-11.9.7 {string match} { + string match *3***456* 0123456789 +} 1 +test string-11.9.8 {string match} { + string match *3***\[456]* 0123456789 +} 1 +test string-11.9.9 {string match} { + string match *3***\[4-6]* 0123456789 +} 1 +test string-11.9.10 {string match} { + string match *3***\[4-6] 0123456789 +} 0 +test string-11.9.11 {string match} { + string match *3***\[4-6] 0123456 +} 1 test string-11.10 {string match} { string match *3*6*9 01234567890 } 0 +test string-11.10.1 {string match} { + string match *3*6*89 01234567890 +} 0 +test string-11.10.2 {string match} { + string match *3*456*89 01234567890 +} 0 +test string-11.10.3 {string match} { + string match **3*456*89 01234567890 +} 0 +test string-11.10.4 {string match} { + string match *3*456***89 01234567890 +} 0 test string-11.11 {string match} { string match a?c abc } 1 @@ -915,6 +1023,21 @@ test string-11.38 {string match case, reverse range} { test string-11.39 {string match, *\ case} { string match {*\abc} abc } 1 +test string-11.39.1 {string match, *\ case} { + string match {*ab\c} abc +} 1 +test string-11.39.2 {string match, *\ case} { + string match {*ab\*} ab* +} 1 +test string-11.39.3 {string match, *\ case} { + string match {*ab\*} abc +} 0 +test string-11.39.4 {string match, *\ case} { + string match {*ab\\*} {ab\c} +} 1 +test string-11.39.5 {string match, *\ case} { + string match {*ab\\*} {ab\*} +} 1 test string-11.40 {string match, *special case} { string match {*[ab]} abc } 0 @@ -1003,7 +1126,7 @@ test string-12.5 {string range, last > length} { string range abcdefghijklmnop 7 1000 } {hijklmnop} test string-12.6 {string range} { - string range abcdefghijklmnop 10 e + string range abcdefghijklmnop 10 end } {klmnop} test string-12.7 {string range, last < first} { string range abcdefghijklmnop 10 9 @@ -1022,15 +1145,15 @@ test string-12.11 {string range} { } {abcdefghijklmnop} test string-12.12 {string range} { list [catch {string range abc abc 1} msg] $msg -} {1 {bad index "abc": must be integer or end?-integer?}} +} {1 {bad index "abc": must be integer?[+-]integer? or end?[+-]integer?}} test string-12.13 {string range} { list [catch {string range abc 1 eof} msg] $msg -} {1 {bad index "eof": must be integer or end?-integer?}} +} {1 {bad index "eof": must be integer?[+-]integer? or end?[+-]integer?}} test string-12.14 {string range} { string range abcdefghijklmnop end-1 end } {op} test string-12.15 {string range} { - string range abcdefghijklmnop e 1000 + string range abcdefghijklmnop end 1000 } {p} test string-12.16 {string range} { string range abcdefghijklmnop end end-1 @@ -1050,6 +1173,7 @@ test string-12.19 {string range, bytearray object} { test string-12.20 {string range, out of bounds indices} { string range \u00ff 0 1 } \u00ff +# Bug 1410553 test string-12.21 {string range, regenerates correct reps, bug 1410553} { set bytes "\x00 \x03 \x41" set rxBuffer {} @@ -1065,6 +1189,11 @@ test string-12.21 {string range, regenerates correct reps, bug 1410553} { binary scan $rxCRC "H*" rxCRC_hex list $input_hex $rxBuffer_hex $rxCRC_hex } {000341 000341 0341} +test string-12.22 {string range, shimmering binary/index} { + set s 0000000001 + binary scan $s a* x + string range $s $s end +} 000000001 test string-13.1 {string repeat} { list [catch {string repeat} msg] $msg @@ -1128,7 +1257,7 @@ test string-14.6 {string replace} { string replace abcdefghijklmnop 7 1000 } {abcdefg} test string-14.7 {string replace} { - string replace abcdefghijklmnop 10 e + string replace abcdefghijklmnop 10 end } {abcdefghij} test string-14.8 {string replace} { string replace abcdefghijklmnop 10 9 @@ -1147,15 +1276,15 @@ test string-14.12 {string replace} { } {} test string-14.13 {string replace} { list [catch {string replace abc abc 1} msg] $msg -} {1 {bad index "abc": must be integer or end?-integer?}} +} {1 {bad index "abc": must be integer?[+-]integer? or end?[+-]integer?}} test string-14.14 {string replace} { list [catch {string replace abc 1 eof} msg] $msg -} {1 {bad index "eof": must be integer or end?-integer?}} +} {1 {bad index "eof": must be integer?[+-]integer? or end?[+-]integer?}} test string-14.15 {string replace} { string replace abcdefghijklmnop end-10 end-2 NEW } {abcdeNEWop} test string-14.16 {string replace} { - string replace abcdefghijklmnop 0 e foo + string replace abcdefghijklmnop 0 end foo } {foo} test string-14.17 {string replace} { string replace abcdefghijklmnop end end-1 @@ -1166,7 +1295,7 @@ test string-15.1 {string tolower too few args} { } {1 {wrong # args: should be "string tolower string ?first? ?last?"}} test string-15.2 {string tolower bad args} { list [catch {string tolower a b} msg] $msg -} {1 {bad index "b": must be integer or end?-integer?}} +} {1 {bad index "b": must be integer?[+-]integer? or end?[+-]integer?}} test string-15.3 {string tolower too many args} { list [catch {string tolower ABC 1 end oops} msg] $msg } {1 {wrong # args: should be "string tolower string ?first? ?last?"}} @@ -1197,7 +1326,7 @@ test string-16.1 {string toupper} { } {1 {wrong # args: should be "string toupper string ?first? ?last?"}} test string-16.2 {string toupper} { list [catch {string toupper a b} msg] $msg -} {1 {bad index "b": must be integer or end?-integer?}} +} {1 {bad index "b": must be integer?[+-]integer? or end?[+-]integer?}} test string-16.3 {string toupper} { list [catch {string toupper a 1 end oops} msg] $msg } {1 {wrong # args: should be "string toupper string ?first? ?last?"}} @@ -1228,7 +1357,7 @@ test string-17.1 {string totitle} { } {1 {wrong # args: should be "string totitle string ?first? ?last?"}} test string-17.2 {string totitle} { list [catch {string totitle a b} msg] $msg -} {1 {bad index "b": must be integer or end?-integer?}} +} {1 {bad index "b": must be integer?[+-]integer? or end?[+-]integer?}} test string-17.3 {string totitle} { string totitle abCDEf } {Abcdef} @@ -1291,7 +1420,7 @@ test string-20.1 {string trimright errors} { } {1 {wrong # args: should be "string trimright string ?chars?"}} test string-20.2 {string trimright errors} { list [catch {string trimg a} msg] $msg -} {1 {bad option "trimg": must be bytelength, compare, equal, first, index, is, last, length, map, match, range, repeat, replace, tolower, toupper, totitle, trim, trimleft, trimright, wordend, or wordstart}} +} {1 {unknown or ambiguous subcommand "trimg": must be bytelength, compare, equal, first, index, is, last, length, map, match, range, repeat, replace, reverse, tolower, totitle, toupper, trim, trimleft, trimright, wordend, or wordstart}} test string-20.3 {string trimright} { string trimright " XYZ " } { XYZ} @@ -1310,7 +1439,7 @@ test string-21.2 {string wordend} { } {1 {wrong # args: should be "string wordend string index"}} test string-21.3 {string wordend} { list [catch {string wordend a gorp} msg] $msg -} {1 {bad index "gorp": must be integer or end?-integer?}} +} {1 {bad index "gorp": must be integer?[+-]integer? or end?[+-]integer?}} test string-21.4 {string wordend} { string wordend abc. -1 } 3 @@ -1347,7 +1476,7 @@ test string-21.14 {string wordend, unicode} { test string-22.1 {string wordstart} { list [catch {string word a} msg] $msg -} {1 {ambiguous option "word": must be bytelength, compare, equal, first, index, is, last, length, map, match, range, repeat, replace, tolower, toupper, totitle, trim, trimleft, trimright, wordend, or wordstart}} +} {1 {unknown or ambiguous subcommand "word": must be bytelength, compare, equal, first, index, is, last, length, map, match, range, repeat, replace, reverse, tolower, totitle, toupper, trim, trimleft, trimright, wordend, or wordstart}} test string-22.2 {string wordstart} { list [catch {string wordstart a} msg] $msg } {1 {wrong # args: should be "string wordstart string index"}} @@ -1356,7 +1485,7 @@ test string-22.3 {string wordstart} { } {1 {wrong # args: should be "string wordstart string index"}} test string-22.4 {string wordstart} { list [catch {string wordstart a gorp} msg] $msg -} {1 {bad index "gorp": must be integer or end?-integer?}} +} {1 {bad index "gorp": must be integer?[+-]integer? or end?[+-]integer?}} test string-22.5 {string wordstart} { string wordstart "one two three_words" 400 } 8 @@ -1390,8 +1519,154 @@ test string-23.0 {string is boolean, Bug 1187123} testindexobj { catch {testindexobj $x foo bar soom} string is boolean $x } 0 +test string-23.1 {string is command with empty string} { + set s "" + list \ + [string is alnum $s] \ + [string is alpha $s] \ + [string is ascii $s] \ + [string is control $s] \ + [string is boolean $s] \ + [string is digit $s] \ + [string is double $s] \ + [string is false $s] \ + [string is graph $s] \ + [string is integer $s] \ + [string is lower $s] \ + [string is print $s] \ + [string is punct $s] \ + [string is space $s] \ + [string is true $s] \ + [string is upper $s] \ + [string is wordchar $s] \ + [string is xdigit $s] \ +} {1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1} +test string-23.2 {string is command with empty string} { + set s "" + list \ + [string is alnum -strict $s] \ + [string is alpha -strict $s] \ + [string is ascii -strict $s] \ + [string is control -strict $s] \ + [string is boolean -strict $s] \ + [string is digit -strict $s] \ + [string is double -strict $s] \ + [string is false -strict $s] \ + [string is graph -strict $s] \ + [string is integer -strict $s] \ + [string is lower -strict $s] \ + [string is print -strict $s] \ + [string is punct -strict $s] \ + [string is space -strict $s] \ + [string is true -strict $s] \ + [string is upper -strict $s] \ + [string is wordchar -strict $s] \ + [string is xdigit -strict $s] \ + +} {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0} + +test string-24.1 {string reverse command} -body { + string reverse +} -returnCodes error -result "wrong # args: should be \"string reverse string\"" +test string-24.2 {string reverse command} -body { + string reverse a b +} -returnCodes error -result "wrong # args: should be \"string reverse string\"" +test string-24.3 {string reverse command - shared string} { + set x abcde + string reverse $x +} edcba +test string-24.4 {string reverse command - unshared string} { + set x abc + set y de + string reverse $x$y +} edcba +test string-24.5 {string reverse command - shared unicode string} { + set x abcde\udead + string reverse $x +} \udeadedcba +test string-24.6 {string reverse command - unshared string} { + set x abc + set y de\udead + string reverse $x$y +} \udeadedcba +test string-24.7 {string reverse command - simple case} { + string reverse a +} a +test string-24.8 {string reverse command - simple case} { + string reverse \udead +} \udead +test string-24.9 {string reverse command - simple case} { + string reverse {} +} {} +test string-24.10 {string reverse command - corner case} { + set x \ubeef\udead + string reverse $x +} \udead\ubeef +test string-24.11 {string reverse command - corner case} { + set x \ubeef + set y \udead + string reverse $x$y +} \udead\ubeef +test string-24.12 {string reverse command - corner case} { + set x \ubeef + set y \udead + string is ascii [string reverse $x$y] +} 0 + +test string-25.1 {string is list} { + string is list {a b c} +} 1 +test string-25.2 {string is list} { + string is list "a \{b c" +} 0 +test string-25.3 {string is list} { + string is list {a {b c}d e} +} 0 +test string-25.4 {string is list} { + string is list {} +} 1 +test string-25.5 {string is list} { + string is list -strict {a b c} +} 1 +test string-25.6 {string is list} { + string is list -strict "a \{b c" +} 0 +test string-25.7 {string is list} { + string is list -strict {a {b c}d e} +} 0 +test string-25.8 {string is list} { + string is list -strict {} +} 1 +test string-25.9 {string is list} { + set x {} + list [string is list -failindex x {a b c}] $x +} {1 {}} +test string-25.10 {string is list} { + set x {} + list [string is list -failindex x "a \{b c"] $x +} {0 2} +test string-25.11 {string is list} { + set x {} + list [string is list -failindex x {a b {b c}d e}] $x +} {0 4} +test string-25.12 {string is list} { + set x {} + list [string is list -failindex x {}] $x +} {1 {}} +test string-25.13 {string is list} { + set x {} + list [string is list -failindex x { {b c}d e}] $x +} {0 2} +test string-25.14 {string is list} { + set x {} + list [string is list -failindex x "\uabcd {b c}d e"] $x +} {0 2} # cleanup ::tcltest::cleanupTests return + +# Local Variables: +# mode: tcl +# End: |