os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/stringComp.test
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/stringComp.test	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,719 @@
     1.4 +# Commands covered:  string
     1.5 +#
     1.6 +# This file contains a collection of tests for one or more of the Tcl
     1.7 +# built-in commands.  Sourcing this file into Tcl runs the tests and
     1.8 +# generates output for errors.  No output means no errors were found.
     1.9 +#
    1.10 +# This differs from the original string tests in that the tests call
    1.11 +# things in procs, which uses the compiled string code instead of
    1.12 +# the runtime parse string code.  The tests of import should match
    1.13 +# their equivalent number in string.test.
    1.14 +#
    1.15 +# Copyright (c) 2001 by ActiveState Corporation.
    1.16 +# Copyright (c) 2001 by Kevin B. Kenny.  All rights reserved.
    1.17 +#
    1.18 +# See the file "license.terms" for information on usage and redistribution
    1.19 +# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    1.20 +#
    1.21 +# RCS: @(#) $Id: stringComp.test,v 1.6.2.1 2004/10/28 00:01:12 dgp Exp $
    1.22 +
    1.23 +if {[lsearch [namespace children] ::tcltest] == -1} {
    1.24 +    package require tcltest
    1.25 +    namespace import -force ::tcltest::*
    1.26 +}
    1.27 +
    1.28 +# Some tests require the testobj command
    1.29 +
    1.30 +set ::tcltest::testConstraints(testobj) \
    1.31 +	[expr {[info commands testobj] != {}}]
    1.32 +
    1.33 +test stringComp-1.1 {error conditions} {
    1.34 +    proc foo {} {string gorp a b}
    1.35 +    list [catch {foo} msg] $msg
    1.36 +} {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.37 +test stringComp-1.2 {error conditions} {
    1.38 +    proc foo {} {string}
    1.39 +    list [catch {foo} msg] $msg
    1.40 +} {1 {wrong # args: should be "string option arg ?arg ...?"}}
    1.41 +test stringComp-1.3 {error condition - undefined method during compile} {
    1.42 +    # We don't want this to complain about 'never' because it may never
    1.43 +    # be called, or string may get redefined.  This must compile OK.
    1.44 +    proc foo {str i} {
    1.45 +        if {"yes" == "no"} { string never called but complains here }
    1.46 +        string index $str $i
    1.47 +    }
    1.48 +    foo abc 0
    1.49 +} a
    1.50 +
    1.51 +test stringComp-2.1 {string compare, too few args} {
    1.52 +    proc foo {} {string compare a}
    1.53 +    list [catch {foo} msg] $msg
    1.54 +} {1 {wrong # args: should be "string compare ?-nocase? ?-length int? string1 string2"}}
    1.55 +test stringComp-2.2 {string compare, bad args} {
    1.56 +    proc foo {} {string compare a b c}
    1.57 +    list [catch {foo} msg] $msg
    1.58 +} {1 {bad option "a": must be -nocase or -length}}
    1.59 +test stringComp-2.3 {string compare, bad args} {
    1.60 +    list [catch {string compare -length -nocase str1 str2} msg] $msg
    1.61 +} {1 {expected integer but got "-nocase"}}
    1.62 +test stringComp-2.4 {string compare, too many args} {
    1.63 +    list [catch {string compare -length 10 -nocase str1 str2 str3} msg] $msg
    1.64 +} {1 {wrong # args: should be "string compare ?-nocase? ?-length int? string1 string2"}}
    1.65 +test stringComp-2.5 {string compare with length unspecified} {
    1.66 +    list [catch {string compare -length 10 10} msg] $msg
    1.67 +} {1 {wrong # args: should be "string compare ?-nocase? ?-length int? string1 string2"}}
    1.68 +test stringComp-2.6 {string compare} {
    1.69 +    proc foo {} {string compare abcde abdef}
    1.70 +    foo
    1.71 +} -1
    1.72 +test stringComp-2.7 {string compare, shortest method name} {
    1.73 +    proc foo {} {string c abcde ABCDE}
    1.74 +    foo
    1.75 +} 1
    1.76 +test stringComp-2.8 {string compare} {
    1.77 +    proc foo {} {string compare abcde abcde}
    1.78 +    foo
    1.79 +} 0
    1.80 +test stringComp-2.9 {string compare with length} {
    1.81 +    proc foo {} {string compare -length 2 abcde abxyz}
    1.82 +    foo
    1.83 +} 0
    1.84 +test stringComp-2.10 {string compare with special index} {
    1.85 +    proc foo {} {string compare -length end-3 abcde abxyz}
    1.86 +    list [catch {foo} msg] $msg
    1.87 +} {1 {expected integer but got "end-3"}}
    1.88 +test stringComp-2.11 {string compare, unicode} {
    1.89 +    proc foo {} {string compare ab\u7266 ab\u7267}
    1.90 +    foo
    1.91 +} -1
    1.92 +test stringComp-2.12 {string compare, high bit} {
    1.93 +    # This test will fail if the underlying comparaison
    1.94 +    # is using signed chars instead of unsigned chars.
    1.95 +    # (like SunOS's default memcmp thus the compat/memcmp.c)
    1.96 +    proc foo {} {string compare "\x80" "@"}
    1.97 +    foo
    1.98 +    # Nb this tests works also in utf8 space because \x80 is
    1.99 +    # translated into a 2 or more bytelength but whose first byte has
   1.100 +    # the high bit set.
   1.101 +} 1
   1.102 +test stringComp-2.13 {string compare -nocase} {
   1.103 +    proc foo {} {string compare -nocase abcde abdef}
   1.104 +    foo
   1.105 +} -1
   1.106 +test stringComp-2.14 {string compare -nocase} {
   1.107 +    proc foo {} {string c -nocase abcde ABCDE}
   1.108 +    foo
   1.109 +} 0
   1.110 +test stringComp-2.15 {string compare -nocase} {
   1.111 +    proc foo {} {string compare -nocase abcde abcde}
   1.112 +    foo
   1.113 +} 0
   1.114 +test stringComp-2.16 {string compare -nocase with length} {
   1.115 +    proc foo {} {string compare -length 2 -nocase abcde Abxyz}
   1.116 +    foo
   1.117 +} 0
   1.118 +test stringComp-2.17 {string compare -nocase with length} {
   1.119 +    proc foo {} {string compare -nocase -length 3 abcde Abxyz}
   1.120 +    foo
   1.121 +} -1
   1.122 +test stringComp-2.18 {string compare -nocase with length <= 0} {
   1.123 +    proc foo {} {string compare -nocase -length -1 abcde AbCdEf}
   1.124 +    foo
   1.125 +} -1
   1.126 +test stringComp-2.19 {string compare -nocase with excessive length} {
   1.127 +    proc foo {} {string compare -nocase -length 50 AbCdEf abcde}
   1.128 +    foo
   1.129 +} 1
   1.130 +test stringComp-2.20 {string compare -len unicode} {
   1.131 +    # These are strings that are 6 BYTELENGTH long, but the length
   1.132 +    # shouldn't make a different because there are actually 3 CHARS long
   1.133 +    proc foo {} {string compare -len 5 \334\334\334 \334\334\374}
   1.134 +    foo
   1.135 +} -1
   1.136 +test stringComp-2.21 {string compare -nocase with special index} {
   1.137 +    proc foo {} {string compare -nocase -length end-3 Abcde abxyz}
   1.138 +    list [catch {foo} msg] $msg
   1.139 +} {1 {expected integer but got "end-3"}}
   1.140 +test stringComp-2.22 {string compare, null strings} {
   1.141 +    proc foo {} {string compare "" ""}
   1.142 +    foo
   1.143 +} 0
   1.144 +test stringComp-2.23 {string compare, null strings} {
   1.145 +    proc foo {} {string compare "" foo}
   1.146 +    foo
   1.147 +} -1
   1.148 +test stringComp-2.24 {string compare, null strings} {
   1.149 +    proc foo {} {string compare foo ""}
   1.150 +    foo
   1.151 +} 1
   1.152 +test stringComp-2.25 {string compare -nocase, null strings} {
   1.153 +    proc foo {} {string compare -nocase "" ""}
   1.154 +    foo
   1.155 +} 0
   1.156 +test stringComp-2.26 {string compare -nocase, null strings} {
   1.157 +    proc foo {} {string compare -nocase "" foo}
   1.158 +    foo
   1.159 +} -1
   1.160 +test stringComp-2.27 {string compare -nocase, null strings} {
   1.161 +    proc foo {} {string compare -nocase foo ""}
   1.162 +    foo
   1.163 +} 1
   1.164 +test stringComp-2.28 {string compare with length, unequal strings} {
   1.165 +    proc foo {} {string compare -length 2 abc abde}
   1.166 +    foo
   1.167 +} 0
   1.168 +test stringComp-2.29 {string compare with length, unequal strings} {
   1.169 +    proc foo {} {string compare -length 2 ab abde}
   1.170 +    foo
   1.171 +} 0
   1.172 +test stringComp-2.30 {string compare with NUL character vs. other ASCII} {
   1.173 +    # Be careful here, since UTF-8 rep comparison with memcmp() of
   1.174 +    # these puts chars in the wrong order
   1.175 +    proc foo {} {string compare \x00 \x01}
   1.176 +    foo
   1.177 +} -1
   1.178 +test stringComp-2.31 {string compare, high bit} {
   1.179 +    proc foo {} {string compare "a\x80" "a@"}
   1.180 +    foo
   1.181 +} 1
   1.182 +test stringComp-2.32 {string compare, high bit} {
   1.183 +    proc foo {} {string compare "a\x00" "a\x01"}
   1.184 +    foo
   1.185 +} -1
   1.186 +test stringComp-2.33 {string compare, high bit} {
   1.187 +    proc foo {} {string compare "\x00\x00" "\x00\x01"}
   1.188 +    foo
   1.189 +} -1
   1.190 +
   1.191 +# only need a few tests on equal, since it uses the same code as
   1.192 +# string compare, but just modifies the return output
   1.193 +test stringComp-3.1 {string equal} {
   1.194 +    proc foo {} {string equal abcde abdef}
   1.195 +    foo
   1.196 +} 0
   1.197 +test stringComp-3.2 {string equal} {
   1.198 +    proc foo {} {string eq abcde ABCDE}
   1.199 +    foo
   1.200 +} 0
   1.201 +test stringComp-3.3 {string equal} {
   1.202 +    proc foo {} {string equal abcde abcde}
   1.203 +    foo
   1.204 +} 1
   1.205 +test stringComp-3.4 {string equal -nocase} {
   1.206 +    proc foo {} {string equal -nocase \334\334\334\334\374\374\374\374 \334\334\334\334\334\334\334\334}
   1.207 +    foo
   1.208 +} 1
   1.209 +test stringComp-3.5 {string equal -nocase} {
   1.210 +    proc foo {} {string equal -nocase abcde abdef}
   1.211 +    foo
   1.212 +} 0
   1.213 +test stringComp-3.6 {string equal -nocase} {
   1.214 +    proc foo {} {string eq -nocase abcde ABCDE}
   1.215 +    foo
   1.216 +} 1
   1.217 +test stringComp-3.7 {string equal -nocase} {
   1.218 +    proc foo {} {string equal -nocase abcde abcde}
   1.219 +    foo
   1.220 +} 1
   1.221 +test stringComp-3.8 {string equal with length, unequal strings} {
   1.222 +    proc foo {} {string equal -length 2 abc abde}
   1.223 +    foo
   1.224 +} 1
   1.225 +
   1.226 +test stringComp-4.1 {string first, too few args} {
   1.227 +    proc foo {} {string first a}
   1.228 +    list [catch {foo} msg] $msg
   1.229 +} {1 {wrong # args: should be "string first subString string ?startIndex?"}}
   1.230 +test stringComp-4.2 {string first, bad args} {
   1.231 +    proc foo {} {string first a b c}
   1.232 +    list [catch {foo} msg] $msg
   1.233 +} {1 {bad index "c": must be integer or end?-integer?}}
   1.234 +test stringComp-4.3 {string first, too many args} {
   1.235 +    proc foo {} {string first a b 5 d}
   1.236 +    list [catch {foo} msg] $msg
   1.237 +} {1 {wrong # args: should be "string first subString string ?startIndex?"}}
   1.238 +test stringComp-4.4 {string first} {
   1.239 +    proc foo {} {string first bq abcdefgbcefgbqrs}
   1.240 +    foo
   1.241 +} 12
   1.242 +test stringComp-4.5 {string first} {
   1.243 +    proc foo {} {string fir bcd abcdefgbcefgbqrs}
   1.244 +    foo
   1.245 +} 1
   1.246 +test stringComp-4.6 {string first} {
   1.247 +    proc foo {} {string f b abcdefgbcefgbqrs}
   1.248 +    foo
   1.249 +} 1
   1.250 +test stringComp-4.7 {string first} {
   1.251 +    proc foo {} {string first xxx x123xx345xxx789xxx012}
   1.252 +    foo
   1.253 +} 9
   1.254 +test stringComp-4.8 {string first} {
   1.255 +    proc foo {} {string first "" x123xx345xxx789xxx012}
   1.256 +    foo
   1.257 +} -1
   1.258 +test stringComp-4.9 {string first, unicode} {
   1.259 +    proc foo {} {string first x abc\u7266x}
   1.260 +    foo
   1.261 +} 4
   1.262 +test stringComp-4.10 {string first, unicode} {
   1.263 +    proc foo {} {string first \u7266 abc\u7266x}
   1.264 +    foo
   1.265 +} 3
   1.266 +test stringComp-4.11 {string first, start index} {
   1.267 +    proc foo {} {string first \u7266 abc\u7266x 3}
   1.268 +    foo
   1.269 +} 3
   1.270 +test stringComp-4.12 {string first, start index} {
   1.271 +    proc foo {} {string first \u7266 abc\u7266x 4}
   1.272 +    foo
   1.273 +} -1
   1.274 +test stringComp-4.13 {string first, start index} {
   1.275 +    proc foo {} {string first \u7266 abc\u7266x end-2}
   1.276 +    foo
   1.277 +} 3
   1.278 +test stringComp-4.14 {string first, negative start index} {
   1.279 +    proc foo {} {string first b abc -1}
   1.280 +    foo
   1.281 +} 1
   1.282 +
   1.283 +test stringComp-5.1 {string index} {
   1.284 +    proc foo {} {string index}
   1.285 +    list [catch {foo} msg] $msg
   1.286 +} {1 {wrong # args: should be "string index string charIndex"}}
   1.287 +test stringComp-5.2 {string index} {
   1.288 +    proc foo {} {string index a b c}
   1.289 +    list [catch {foo} msg] $msg
   1.290 +} {1 {wrong # args: should be "string index string charIndex"}}
   1.291 +test stringComp-5.3 {string index} {
   1.292 +    proc foo {} {string index abcde 0}
   1.293 +    foo
   1.294 +} a
   1.295 +test stringComp-5.4 {string index} {
   1.296 +    proc foo {} {string in abcde 4}
   1.297 +    foo
   1.298 +} e
   1.299 +test stringComp-5.5 {string index} {
   1.300 +    proc foo {} {string index abcde 5}
   1.301 +    foo
   1.302 +} {}
   1.303 +test stringComp-5.6 {string index} {
   1.304 +    proc foo {} {string index abcde -10}
   1.305 +    list [catch {foo} msg] $msg
   1.306 +} {0 {}}
   1.307 +test stringComp-5.7 {string index} {
   1.308 +    proc foo {} {string index a xyz}
   1.309 +    list [catch {foo} msg] $msg
   1.310 +} {1 {bad index "xyz": must be integer or end?-integer?}}
   1.311 +test stringComp-5.8 {string index} {
   1.312 +    proc foo {} {string index abc end}
   1.313 +    foo
   1.314 +} c
   1.315 +test stringComp-5.9 {string index} {
   1.316 +    proc foo {} {string index abc end-1}
   1.317 +    foo
   1.318 +} b
   1.319 +test stringComp-5.10 {string index, unicode} {
   1.320 +    proc foo {} {string index abc\u7266d 4}
   1.321 +    foo
   1.322 +} d
   1.323 +test stringComp-5.11 {string index, unicode} {
   1.324 +    proc foo {} {string index abc\u7266d 3}
   1.325 +    foo
   1.326 +} \u7266
   1.327 +test stringComp-5.12 {string index, unicode over char length, under byte length} {
   1.328 +    proc foo {} {string index \334\374\334\374 6}
   1.329 +    foo
   1.330 +} {}
   1.331 +test stringComp-5.13 {string index, bytearray object} {
   1.332 +    proc foo {} {string index [binary format a5 fuz] 0}
   1.333 +    foo
   1.334 +} f
   1.335 +test stringComp-5.14 {string index, bytearray object} {
   1.336 +    proc foo {} {string index [binary format I* {0x50515253 0x52}] 3}
   1.337 +    foo
   1.338 +} S
   1.339 +test stringComp-5.15 {string index, bytearray object} {
   1.340 +    proc foo {} {
   1.341 +	set b [binary format I* {0x50515253 0x52}]
   1.342 +	set i1 [string index $b end-6]
   1.343 +	set i2 [string index $b 1]
   1.344 +	string compare $i1 $i2
   1.345 +    }
   1.346 +    foo
   1.347 +} 0
   1.348 +test stringComp-5.16 {string index, bytearray object with string obj shimmering} {
   1.349 +    proc foo {} {
   1.350 +	set str "0123456789\x00 abcdedfghi"
   1.351 +	binary scan $str H* dump
   1.352 +	string compare [string index $str 10] \x00
   1.353 +    }
   1.354 +    foo
   1.355 +} 0
   1.356 +test stringComp-5.17 {string index, bad integer} {
   1.357 +    proc foo {} {string index "abc" 08}
   1.358 +    list [catch {foo} msg] $msg
   1.359 +} {1 {bad index "08": must be integer or end?-integer? (looks like invalid octal number)}}
   1.360 +test stringComp-5.18 {string index, bad integer} {
   1.361 +    proc foo {} {string index "abc" end-00289}
   1.362 +    list [catch {foo} msg] $msg
   1.363 +} {1 {bad index "end-00289": must be integer or end?-integer? (looks like invalid octal number)}}
   1.364 +test stringComp-5.19 {string index, bytearray object out of bounds} {
   1.365 +    proc foo {} {string index [binary format I* {0x50515253 0x52}] -1}
   1.366 +    foo
   1.367 +} {}
   1.368 +test stringComp-5.20 {string index, bytearray object out of bounds} {
   1.369 +    proc foo {} {string index [binary format I* {0x50515253 0x52}] 20}
   1.370 +    foo
   1.371 +} {}
   1.372 +
   1.373 +
   1.374 +proc largest_int {} {
   1.375 +    # This will give us what the largest valid int on this machine is,
   1.376 +    # so we can test for overflow properly below on >32 bit systems
   1.377 +    set int 1
   1.378 +    set exp 7; # assume we get at least 8 bits
   1.379 +    while {$int > 0} { set int [expr {1 << [incr exp]}] }
   1.380 +    return [expr {$int-1}]
   1.381 +}
   1.382 +
   1.383 +## string is
   1.384 +## not yet bc
   1.385 +
   1.386 +catch {rename largest_int {}}
   1.387 +
   1.388 +## string last
   1.389 +## not yet bc
   1.390 +
   1.391 +## string length
   1.392 +## not yet bc
   1.393 +test stringComp-8.1 {string bytelength} {
   1.394 +    proc foo {} {string bytelength}
   1.395 +    list [catch {foo} msg] $msg
   1.396 +} {1 {wrong # args: should be "string bytelength string"}}
   1.397 +test stringComp-8.2 {string bytelength} {
   1.398 +    proc foo {} {string bytelength a b}
   1.399 +    list [catch {foo} msg] $msg
   1.400 +} {1 {wrong # args: should be "string bytelength string"}}
   1.401 +test stringComp-8.3 {string bytelength} {
   1.402 +    proc foo {} {string bytelength "\u00c7"}
   1.403 +    foo
   1.404 +} 2
   1.405 +test stringComp-8.4 {string bytelength} {
   1.406 +    proc foo {} {string b ""}
   1.407 +    foo
   1.408 +} 0
   1.409 +
   1.410 +## string length
   1.411 +##
   1.412 +test stringComp-9.1 {string length} {
   1.413 +    proc foo {} {string length}
   1.414 +    list [catch {foo} msg] $msg
   1.415 +} {1 {wrong # args: should be "string length string"}}
   1.416 +test stringComp-9.2 {string length} {
   1.417 +    proc foo {} {string length a b}
   1.418 +    list [catch {foo} msg] $msg
   1.419 +} {1 {wrong # args: should be "string length string"}}
   1.420 +test stringComp-9.3 {string length} {
   1.421 +    proc foo {} {string length "a little string"}
   1.422 +    foo
   1.423 +} 15
   1.424 +test stringComp-9.4 {string length} {
   1.425 +    proc foo {} {string le ""}
   1.426 +    foo
   1.427 +} 0
   1.428 +test stringComp-9.5 {string length, unicode} {
   1.429 +    proc foo {} {string le "abcd\u7266"}
   1.430 +    foo
   1.431 +} 5
   1.432 +test stringComp-9.6 {string length, bytearray object} {
   1.433 +    proc foo {} {string length [binary format a5 foo]}
   1.434 +    foo
   1.435 +} 5
   1.436 +test stringComp-9.7 {string length, bytearray object} {
   1.437 +    proc foo {} {string length [binary format I* {0x50515253 0x52}]}
   1.438 +    foo
   1.439 +} 8
   1.440 +
   1.441 +## string map
   1.442 +## not yet bc
   1.443 +
   1.444 +## string match
   1.445 +##
   1.446 +test stringComp-11.1 {string match, too few args} {
   1.447 +    proc foo {} {string match a}
   1.448 +    list [catch {foo} msg] $msg
   1.449 +} {1 {wrong # args: should be "string match ?-nocase? pattern string"}}
   1.450 +test stringComp-11.2 {string match, too many args} {
   1.451 +    proc foo {} {string match a b c d}
   1.452 +    list [catch {foo} msg] $msg
   1.453 +} {1 {wrong # args: should be "string match ?-nocase? pattern string"}}
   1.454 +test stringComp-11.3 {string match} {
   1.455 +    proc foo {} {string match abc abc}
   1.456 +    foo
   1.457 +} 1
   1.458 +test stringComp-11.4 {string match} {
   1.459 +    proc foo {} {string mat abc abd}
   1.460 +    foo
   1.461 +} 0
   1.462 +test stringComp-11.5 {string match} {
   1.463 +    proc foo {} {string match ab*c abc}
   1.464 +    foo
   1.465 +} 1
   1.466 +test stringComp-11.6 {string match} {
   1.467 +    proc foo {} {string match ab**c abc}
   1.468 +    foo
   1.469 +} 1
   1.470 +test stringComp-11.7 {string match} {
   1.471 +    proc foo {} {string match ab* abcdef}
   1.472 +    foo
   1.473 +} 1
   1.474 +test stringComp-11.8 {string match} {
   1.475 +    proc foo {} {string match *c abc}
   1.476 +    foo
   1.477 +} 1
   1.478 +test stringComp-11.9 {string match} {
   1.479 +    proc foo {} {string match *3*6*9 0123456789}
   1.480 +    foo
   1.481 +} 1
   1.482 +test stringComp-11.10 {string match} {
   1.483 +    proc foo {} {string match *3*6*9 01234567890}
   1.484 +    foo
   1.485 +} 0
   1.486 +test stringComp-11.11 {string match} {
   1.487 +    proc foo {} {string match a?c abc}
   1.488 +    foo
   1.489 +} 1
   1.490 +test stringComp-11.12 {string match} {
   1.491 +    proc foo {} {string match a??c abc}
   1.492 +    foo
   1.493 +} 0
   1.494 +test stringComp-11.13 {string match} {
   1.495 +    proc foo {} {string match ?1??4???8? 0123456789}
   1.496 +    foo
   1.497 +} 1
   1.498 +test stringComp-11.14 {string match} {
   1.499 +    proc foo {} {string match {[abc]bc} abc}
   1.500 +    foo
   1.501 +} 1
   1.502 +test stringComp-11.15 {string match} {
   1.503 +    proc foo {} {string match {a[abc]c} abc}
   1.504 +    foo
   1.505 +} 1
   1.506 +test stringComp-11.16 {string match} {
   1.507 +    proc foo {} {string match {a[xyz]c} abc}
   1.508 +    foo
   1.509 +} 0
   1.510 +test stringComp-11.17 {string match} {
   1.511 +    proc foo {} {string match {12[2-7]45} 12345}
   1.512 +    foo
   1.513 +} 1
   1.514 +test stringComp-11.18 {string match} {
   1.515 +    proc foo {} {string match {12[ab2-4cd]45} 12345}
   1.516 +    foo
   1.517 +} 1
   1.518 +test stringComp-11.19 {string match} {
   1.519 +    proc foo {} {string match {12[ab2-4cd]45} 12b45}
   1.520 +    foo
   1.521 +} 1
   1.522 +test stringComp-11.20 {string match} {
   1.523 +    proc foo {} {string match {12[ab2-4cd]45} 12d45}
   1.524 +    foo
   1.525 +} 1
   1.526 +test stringComp-11.21 {string match} {
   1.527 +    proc foo {} {string match {12[ab2-4cd]45} 12145}
   1.528 +    foo
   1.529 +} 0
   1.530 +test stringComp-11.22 {string match} {
   1.531 +    proc foo {} {string match {12[ab2-4cd]45} 12545}
   1.532 +    foo
   1.533 +} 0
   1.534 +test stringComp-11.23 {string match} {
   1.535 +    proc foo {} {string match {a\*b} a*b}
   1.536 +    foo
   1.537 +} 1
   1.538 +test stringComp-11.24 {string match} {
   1.539 +    proc foo {} {string match {a\*b} ab}
   1.540 +    foo
   1.541 +} 0
   1.542 +test stringComp-11.25 {string match} {
   1.543 +    proc foo {} {string match {a\*\?\[\]\\\x} "a*?\[\]\\x"}
   1.544 +    foo
   1.545 +} 1
   1.546 +test stringComp-11.26 {string match} {
   1.547 +    proc foo {} {string match ** ""}
   1.548 +    foo
   1.549 +} 1
   1.550 +test stringComp-11.27 {string match} {
   1.551 +    proc foo {} {string match *. ""}
   1.552 +    foo
   1.553 +} 0
   1.554 +test stringComp-11.28 {string match} {
   1.555 +    proc foo {} {string match "" ""}
   1.556 +    foo
   1.557 +} 1
   1.558 +test stringComp-11.29 {string match} {
   1.559 +    proc foo {} {string match \[a a}
   1.560 +    foo
   1.561 +} 1
   1.562 +test stringComp-11.30 {string match, bad args} {
   1.563 +    proc foo {} {string match - b c}
   1.564 +    list [catch {foo} msg] $msg
   1.565 +} {1 {bad option "-": must be -nocase}}
   1.566 +test stringComp-11.31 {string match case} {
   1.567 +    proc foo {} {string match a A}
   1.568 +    foo
   1.569 +} 0
   1.570 +test stringComp-11.32 {string match nocase} {
   1.571 +    proc foo {} {string match -n a A}
   1.572 +    foo
   1.573 +} 1
   1.574 +test stringComp-11.33 {string match nocase} {
   1.575 +    proc foo {} {string match -nocase a\334 A\374}
   1.576 +    foo
   1.577 +} 1
   1.578 +test stringComp-11.34 {string match nocase} {
   1.579 +    proc foo {} {string match -nocase a*f ABCDEf}
   1.580 +    foo
   1.581 +} 1
   1.582 +test stringComp-11.35 {string match case, false hope} {
   1.583 +    # This is true because '_' lies between the A-Z and a-z ranges
   1.584 +    proc foo {} {string match {[A-z]} _}
   1.585 +    foo
   1.586 +} 1
   1.587 +test stringComp-11.36 {string match nocase range} {
   1.588 +    # This is false because although '_' lies between the A-Z and a-z ranges,
   1.589 +    # we lower case the end points before checking the ranges.
   1.590 +    proc foo {} {string match -nocase {[A-z]} _}
   1.591 +    foo
   1.592 +} 0
   1.593 +test stringComp-11.37 {string match nocase} {
   1.594 +    proc foo {} {string match -nocase {[A-fh-Z]} g}
   1.595 +    foo
   1.596 +} 0
   1.597 +test stringComp-11.38 {string match case, reverse range} {
   1.598 +    proc foo {} {string match {[A-fh-Z]} g}
   1.599 +    foo
   1.600 +} 1
   1.601 +test stringComp-11.39 {string match, *\ case} {
   1.602 +    proc foo {} {string match {*\abc} abc}
   1.603 +    foo
   1.604 +} 1
   1.605 +test stringComp-11.40 {string match, *special case} {
   1.606 +    proc foo {} {string match {*[ab]} abc}
   1.607 +    foo
   1.608 +} 0
   1.609 +test stringComp-11.41 {string match, *special case} {
   1.610 +    proc foo {} {string match {*[ab]*} abc}
   1.611 +    foo
   1.612 +} 1
   1.613 +test stringComp-11.42 {string match, *special case} {
   1.614 +    proc foo {} {string match "*\\" "\\"}
   1.615 +    foo
   1.616 +} 0
   1.617 +test stringComp-11.43 {string match, *special case} {
   1.618 +    proc foo {} {string match "*\\\\" "\\"}
   1.619 +    foo
   1.620 +} 1
   1.621 +test stringComp-11.44 {string match, *special case} {
   1.622 +    proc foo {} {string match "*???" "12345"}
   1.623 +    foo
   1.624 +} 1
   1.625 +test stringComp-11.45 {string match, *special case} {
   1.626 +    proc foo {} {string match "*???" "12"}
   1.627 +    foo
   1.628 +} 0
   1.629 +test stringComp-11.46 {string match, *special case} {
   1.630 +    proc foo {} {string match "*\\*" "abc*"}
   1.631 +    foo
   1.632 +} 1
   1.633 +test stringComp-11.47 {string match, *special case} {
   1.634 +    proc foo {} {string match "*\\*" "*"}
   1.635 +    foo
   1.636 +} 1
   1.637 +test stringComp-11.48 {string match, *special case} {
   1.638 +    proc foo {} {string match "*\\*" "*abc"}
   1.639 +    foo
   1.640 +} 0
   1.641 +test stringComp-11.49 {string match, *special case} {
   1.642 +    proc foo {} {string match "?\\*" "a*"}
   1.643 +    foo
   1.644 +} 1
   1.645 +test stringComp-11.50 {string match, *special case} {
   1.646 +    proc foo {} {string match "\\" "\\"}
   1.647 +    foo
   1.648 +} 0
   1.649 +test stringComp-11.51 {string match; *, -nocase and UTF-8} {
   1.650 +    proc foo {} {string match -nocase [binary format I 717316707] \
   1.651 +	    [binary format I 2028036707]}
   1.652 +    foo
   1.653 +} 1
   1.654 +test stringComp-11.52 {string match, null char in string} {
   1.655 +    proc foo {} {
   1.656 +	set ptn "*abc*"
   1.657 +	foreach elem [list "\u0000@abc" "@abc" "\u0000@abc\u0000" "blahabcblah"] {
   1.658 +	    lappend out [string match $ptn $elem]
   1.659 +	}
   1.660 +	set out
   1.661 +    }
   1.662 +    foo
   1.663 +} {1 1 1 1}
   1.664 +test stringComp-11.53 {string match, null char in pattern} {
   1.665 +    proc foo {} {
   1.666 +	set out ""
   1.667 +	foreach {ptn elem} [list \
   1.668 +		"*\u0000abc\u0000"  "\u0000abc\u0000" \
   1.669 +		"*\u0000abc\u0000"  "\u0000abc\u0000ef" \
   1.670 +		"*\u0000abc\u0000*" "\u0000abc\u0000ef" \
   1.671 +		"*\u0000abc\u0000"  "@\u0000abc\u0000ef" \
   1.672 +		"*\u0000abc\u0000*"  "@\u0000abc\u0000ef" \
   1.673 +		] {
   1.674 +	    lappend out [string match $ptn $elem]
   1.675 +	}
   1.676 +	set out
   1.677 +    }
   1.678 +    foo
   1.679 +} {1 0 1 0 1}
   1.680 +test stringComp-11.54 {string match, failure} {
   1.681 +    proc foo {} {
   1.682 +	set longString ""
   1.683 +	for {set i 0} {$i < 10} {incr i} {
   1.684 +	    append longString "abcdefghijklmnopqrstuvwxy\u0000z01234567890123"
   1.685 +	}
   1.686 +	list [string match *cba* $longString] \
   1.687 +		[string match *a*l*\u0000* $longString] \
   1.688 +		[string match *a*l*\u0000*123 $longString] \
   1.689 +		[string match *a*l*\u0000*123* $longString] \
   1.690 +		[string match *a*l*\u0000*cba* $longString] \
   1.691 +		[string match *===* $longString]
   1.692 +    }
   1.693 +    foo
   1.694 +} {0 1 1 1 0 0}
   1.695 +
   1.696 +## string range
   1.697 +## not yet bc
   1.698 +
   1.699 +## string repeat
   1.700 +## not yet bc
   1.701 +
   1.702 +## string replace
   1.703 +## not yet bc
   1.704 +
   1.705 +## string tolower
   1.706 +## not yet bc
   1.707 +
   1.708 +## string toupper
   1.709 +## not yet bc
   1.710 +
   1.711 +## string totitle
   1.712 +## not yet bc
   1.713 +
   1.714 +## string trim*
   1.715 +## not yet bc
   1.716 +
   1.717 +## string word*
   1.718 +## not yet bc
   1.719 +
   1.720 +# cleanup
   1.721 +::tcltest::cleanupTests
   1.722 +return