sl@0
|
1 |
# Commands covered: string
|
sl@0
|
2 |
#
|
sl@0
|
3 |
# This file contains a collection of tests for one or more of the Tcl
|
sl@0
|
4 |
# built-in commands. Sourcing this file into Tcl runs the tests and
|
sl@0
|
5 |
# generates output for errors. No output means no errors were found.
|
sl@0
|
6 |
#
|
sl@0
|
7 |
# Copyright (c) 1991-1993 The Regents of the University of California.
|
sl@0
|
8 |
# Copyright (c) 1994 Sun Microsystems, Inc.
|
sl@0
|
9 |
# Copyright (c) 1998-1999 by Scriptics Corporation.
|
sl@0
|
10 |
# Copyright (c) 2001 by Kevin B. Kenny. All rights reserved.
|
sl@0
|
11 |
#
|
sl@0
|
12 |
# See the file "license.terms" for information on usage and redistribution
|
sl@0
|
13 |
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
sl@0
|
14 |
#
|
sl@0
|
15 |
# RCS: @(#) $Id: string.test,v 1.36.2.7 2006/01/23 12:11:15 msofer Exp $
|
sl@0
|
16 |
|
sl@0
|
17 |
if {[lsearch [namespace children] ::tcltest] == -1} {
|
sl@0
|
18 |
package require tcltest
|
sl@0
|
19 |
namespace import -force ::tcltest::*
|
sl@0
|
20 |
}
|
sl@0
|
21 |
|
sl@0
|
22 |
# Some tests require the testobj command
|
sl@0
|
23 |
|
sl@0
|
24 |
set ::tcltest::testConstraints(testobj) \
|
sl@0
|
25 |
[expr {[info commands testobj] != {}}]
|
sl@0
|
26 |
set ::tcltest::testConstraints(testindexobj) \
|
sl@0
|
27 |
[expr {[info commands testindexobj] != {}}]
|
sl@0
|
28 |
|
sl@0
|
29 |
test string-1.1 {error conditions} {
|
sl@0
|
30 |
list [catch {string gorp a b} msg] $msg
|
sl@0
|
31 |
} {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}}
|
sl@0
|
32 |
test string-1.2 {error conditions} {
|
sl@0
|
33 |
list [catch {string} msg] $msg
|
sl@0
|
34 |
} {1 {wrong # args: should be "string option arg ?arg ...?"}}
|
sl@0
|
35 |
|
sl@0
|
36 |
test string-2.1 {string compare, too few args} {
|
sl@0
|
37 |
list [catch {string compare a} msg] $msg
|
sl@0
|
38 |
} {1 {wrong # args: should be "string compare ?-nocase? ?-length int? string1 string2"}}
|
sl@0
|
39 |
test string-2.2 {string compare, bad args} {
|
sl@0
|
40 |
list [catch {string compare a b c} msg] $msg
|
sl@0
|
41 |
} {1 {bad option "a": must be -nocase or -length}}
|
sl@0
|
42 |
test string-2.3 {string compare, bad args} {
|
sl@0
|
43 |
list [catch {string compare -length -nocase str1 str2} msg] $msg
|
sl@0
|
44 |
} {1 {expected integer but got "-nocase"}}
|
sl@0
|
45 |
test string-2.4 {string compare, too many args} {
|
sl@0
|
46 |
list [catch {string compare -length 10 -nocase str1 str2 str3} msg] $msg
|
sl@0
|
47 |
} {1 {wrong # args: should be "string compare ?-nocase? ?-length int? string1 string2"}}
|
sl@0
|
48 |
test string-2.5 {string compare with length unspecified} {
|
sl@0
|
49 |
list [catch {string compare -length 10 10} msg] $msg
|
sl@0
|
50 |
} {1 {wrong # args: should be "string compare ?-nocase? ?-length int? string1 string2"}}
|
sl@0
|
51 |
test string-2.6 {string compare} {
|
sl@0
|
52 |
string compare abcde abdef
|
sl@0
|
53 |
} -1
|
sl@0
|
54 |
test string-2.7 {string compare, shortest method name} {
|
sl@0
|
55 |
string c abcde ABCDE
|
sl@0
|
56 |
} 1
|
sl@0
|
57 |
test string-2.8 {string compare} {
|
sl@0
|
58 |
string compare abcde abcde
|
sl@0
|
59 |
} 0
|
sl@0
|
60 |
test string-2.9 {string compare with length} {
|
sl@0
|
61 |
string compare -length 2 abcde abxyz
|
sl@0
|
62 |
} 0
|
sl@0
|
63 |
test string-2.10 {string compare with special index} {
|
sl@0
|
64 |
list [catch {string compare -length end-3 abcde abxyz} msg] $msg
|
sl@0
|
65 |
} {1 {expected integer but got "end-3"}}
|
sl@0
|
66 |
test string-2.11 {string compare, unicode} {
|
sl@0
|
67 |
string compare ab\u7266 ab\u7267
|
sl@0
|
68 |
} -1
|
sl@0
|
69 |
test string-2.12 {string compare, high bit} {
|
sl@0
|
70 |
# This test will fail if the underlying comparaison
|
sl@0
|
71 |
# is using signed chars instead of unsigned chars.
|
sl@0
|
72 |
# (like SunOS's default memcmp thus the compat/memcmp.c)
|
sl@0
|
73 |
string compare "\x80" "@"
|
sl@0
|
74 |
# Nb this tests works also in utf8 space because \x80 is
|
sl@0
|
75 |
# translated into a 2 or more bytelength but whose first byte has
|
sl@0
|
76 |
# the high bit set.
|
sl@0
|
77 |
} 1
|
sl@0
|
78 |
test string-2.13 {string compare -nocase} {
|
sl@0
|
79 |
string compare -nocase abcde abdef
|
sl@0
|
80 |
} -1
|
sl@0
|
81 |
test string-2.14 {string compare -nocase} {
|
sl@0
|
82 |
string c -nocase abcde ABCDE
|
sl@0
|
83 |
} 0
|
sl@0
|
84 |
test string-2.15 {string compare -nocase} {
|
sl@0
|
85 |
string compare -nocase abcde abcde
|
sl@0
|
86 |
} 0
|
sl@0
|
87 |
test string-2.16 {string compare -nocase with length} {
|
sl@0
|
88 |
string compare -length 2 -nocase abcde Abxyz
|
sl@0
|
89 |
} 0
|
sl@0
|
90 |
test string-2.17 {string compare -nocase with length} {
|
sl@0
|
91 |
string compare -nocase -length 3 abcde Abxyz
|
sl@0
|
92 |
} -1
|
sl@0
|
93 |
test string-2.18 {string compare -nocase with length <= 0} {
|
sl@0
|
94 |
string compare -nocase -length -1 abcde AbCdEf
|
sl@0
|
95 |
} -1
|
sl@0
|
96 |
test string-2.19 {string compare -nocase with excessive length} {
|
sl@0
|
97 |
string compare -nocase -length 50 AbCdEf abcde
|
sl@0
|
98 |
} 1
|
sl@0
|
99 |
test string-2.20 {string compare -len unicode} {
|
sl@0
|
100 |
# These are strings that are 6 BYTELENGTH long, but the length
|
sl@0
|
101 |
# shouldn't make a different because there are actually 3 CHARS long
|
sl@0
|
102 |
string compare -len 5 \334\334\334 \334\334\374
|
sl@0
|
103 |
} -1
|
sl@0
|
104 |
test string-2.21 {string compare -nocase with special index} {
|
sl@0
|
105 |
list [catch {string compare -nocase -length end-3 Abcde abxyz} msg] $msg
|
sl@0
|
106 |
} {1 {expected integer but got "end-3"}}
|
sl@0
|
107 |
test string-2.22 {string compare, null strings} {
|
sl@0
|
108 |
string compare "" ""
|
sl@0
|
109 |
} 0
|
sl@0
|
110 |
test string-2.23 {string compare, null strings} {
|
sl@0
|
111 |
string compare "" foo
|
sl@0
|
112 |
} -1
|
sl@0
|
113 |
test string-2.24 {string compare, null strings} {
|
sl@0
|
114 |
string compare foo ""
|
sl@0
|
115 |
} 1
|
sl@0
|
116 |
test string-2.25 {string compare -nocase, null strings} {
|
sl@0
|
117 |
string compare -nocase "" ""
|
sl@0
|
118 |
} 0
|
sl@0
|
119 |
test string-2.26 {string compare -nocase, null strings} {
|
sl@0
|
120 |
string compare -nocase "" foo
|
sl@0
|
121 |
} -1
|
sl@0
|
122 |
test string-2.27 {string compare -nocase, null strings} {
|
sl@0
|
123 |
string compare -nocase foo ""
|
sl@0
|
124 |
} 1
|
sl@0
|
125 |
test string-2.28 {string compare with length, unequal strings} {
|
sl@0
|
126 |
string compare -length 2 abc abde
|
sl@0
|
127 |
} 0
|
sl@0
|
128 |
test string-2.29 {string compare with length, unequal strings} {
|
sl@0
|
129 |
string compare -length 2 ab abde
|
sl@0
|
130 |
} 0
|
sl@0
|
131 |
test string-2.30 {string compare with NUL character vs. other ASCII} {
|
sl@0
|
132 |
# Be careful here, since UTF-8 rep comparison with memcmp() of
|
sl@0
|
133 |
# these puts chars in the wrong order
|
sl@0
|
134 |
string compare \x00 \x01
|
sl@0
|
135 |
} -1
|
sl@0
|
136 |
test string-2.31 {string compare, high bit} {
|
sl@0
|
137 |
proc foo {} {string compare "a\x80" "a@"}
|
sl@0
|
138 |
foo
|
sl@0
|
139 |
} 1
|
sl@0
|
140 |
test string-2.32 {string compare, high bit} {
|
sl@0
|
141 |
proc foo {} {string compare "a\x00" "a\x01"}
|
sl@0
|
142 |
foo
|
sl@0
|
143 |
} -1
|
sl@0
|
144 |
test string-2.33 {string compare, high bit} {
|
sl@0
|
145 |
proc foo {} {string compare "\x00\x00" "\x00\x01"}
|
sl@0
|
146 |
foo
|
sl@0
|
147 |
} -1
|
sl@0
|
148 |
|
sl@0
|
149 |
# only need a few tests on equal, since it uses the same code as
|
sl@0
|
150 |
# string compare, but just modifies the return output
|
sl@0
|
151 |
test string-3.1 {string equal} {
|
sl@0
|
152 |
string equal abcde abdef
|
sl@0
|
153 |
} 0
|
sl@0
|
154 |
test string-3.2 {string equal} {
|
sl@0
|
155 |
string eq abcde ABCDE
|
sl@0
|
156 |
} 0
|
sl@0
|
157 |
test string-3.3 {string equal} {
|
sl@0
|
158 |
string equal abcde abcde
|
sl@0
|
159 |
} 1
|
sl@0
|
160 |
test string-3.4 {string equal -nocase} {
|
sl@0
|
161 |
string equal -nocase \334\334\334\334\374\374\374\374 \334\334\334\334\334\334\334\334
|
sl@0
|
162 |
} 1
|
sl@0
|
163 |
test string-3.5 {string equal -nocase} {
|
sl@0
|
164 |
string equal -nocase abcde abdef
|
sl@0
|
165 |
} 0
|
sl@0
|
166 |
test string-3.6 {string equal -nocase} {
|
sl@0
|
167 |
string eq -nocase abcde ABCDE
|
sl@0
|
168 |
} 1
|
sl@0
|
169 |
test string-3.7 {string equal -nocase} {
|
sl@0
|
170 |
string equal -nocase abcde abcde
|
sl@0
|
171 |
} 1
|
sl@0
|
172 |
test string-3.8 {string equal with length, unequal strings} {
|
sl@0
|
173 |
string equal -length 2 abc abde
|
sl@0
|
174 |
} 1
|
sl@0
|
175 |
|
sl@0
|
176 |
test string-4.1 {string first, too few args} {
|
sl@0
|
177 |
list [catch {string first a} msg] $msg
|
sl@0
|
178 |
} {1 {wrong # args: should be "string first subString string ?startIndex?"}}
|
sl@0
|
179 |
test string-4.2 {string first, bad args} {
|
sl@0
|
180 |
list [catch {string first a b c} msg] $msg
|
sl@0
|
181 |
} {1 {bad index "c": must be integer or end?-integer?}}
|
sl@0
|
182 |
test string-4.3 {string first, too many args} {
|
sl@0
|
183 |
list [catch {string first a b 5 d} msg] $msg
|
sl@0
|
184 |
} {1 {wrong # args: should be "string first subString string ?startIndex?"}}
|
sl@0
|
185 |
test string-4.4 {string first} {
|
sl@0
|
186 |
string first bq abcdefgbcefgbqrs
|
sl@0
|
187 |
} 12
|
sl@0
|
188 |
test string-4.5 {string first} {
|
sl@0
|
189 |
string fir bcd abcdefgbcefgbqrs
|
sl@0
|
190 |
} 1
|
sl@0
|
191 |
test string-4.6 {string first} {
|
sl@0
|
192 |
string f b abcdefgbcefgbqrs
|
sl@0
|
193 |
} 1
|
sl@0
|
194 |
test string-4.7 {string first} {
|
sl@0
|
195 |
string first xxx x123xx345xxx789xxx012
|
sl@0
|
196 |
} 9
|
sl@0
|
197 |
test string-4.8 {string first} {
|
sl@0
|
198 |
string first "" x123xx345xxx789xxx012
|
sl@0
|
199 |
} -1
|
sl@0
|
200 |
test string-4.9 {string first, unicode} {
|
sl@0
|
201 |
string first x abc\u7266x
|
sl@0
|
202 |
} 4
|
sl@0
|
203 |
test string-4.10 {string first, unicode} {
|
sl@0
|
204 |
string first \u7266 abc\u7266x
|
sl@0
|
205 |
} 3
|
sl@0
|
206 |
test string-4.11 {string first, start index} {
|
sl@0
|
207 |
string first \u7266 abc\u7266x 3
|
sl@0
|
208 |
} 3
|
sl@0
|
209 |
test string-4.12 {string first, start index} {
|
sl@0
|
210 |
string first \u7266 abc\u7266x 4
|
sl@0
|
211 |
} -1
|
sl@0
|
212 |
test string-4.13 {string first, start index} {
|
sl@0
|
213 |
string first \u7266 abc\u7266x end-2
|
sl@0
|
214 |
} 3
|
sl@0
|
215 |
test string-4.14 {string first, negative start index} {
|
sl@0
|
216 |
string first b abc -1
|
sl@0
|
217 |
} 1
|
sl@0
|
218 |
test string-4.15 {string first, ability to two-byte encoded utf-8 chars} {
|
sl@0
|
219 |
# Test for a bug in Tcl 8.3 where test for all-single-byte-encoded
|
sl@0
|
220 |
# strings was incorrect, leading to an index returned by [string first]
|
sl@0
|
221 |
# which pointed past the end of the string.
|
sl@0
|
222 |
set uchar \u057e ;# character with two-byte encoding in utf-8
|
sl@0
|
223 |
string first % %#$uchar$uchar#$uchar$uchar#% 3
|
sl@0
|
224 |
} 8
|
sl@0
|
225 |
|
sl@0
|
226 |
test string-5.1 {string index} {
|
sl@0
|
227 |
list [catch {string index} msg] $msg
|
sl@0
|
228 |
} {1 {wrong # args: should be "string index string charIndex"}}
|
sl@0
|
229 |
test string-5.2 {string index} {
|
sl@0
|
230 |
list [catch {string index a b c} msg] $msg
|
sl@0
|
231 |
} {1 {wrong # args: should be "string index string charIndex"}}
|
sl@0
|
232 |
test string-5.3 {string index} {
|
sl@0
|
233 |
string index abcde 0
|
sl@0
|
234 |
} a
|
sl@0
|
235 |
test string-5.4 {string index} {
|
sl@0
|
236 |
string in abcde 4
|
sl@0
|
237 |
} e
|
sl@0
|
238 |
test string-5.5 {string index} {
|
sl@0
|
239 |
string index abcde 5
|
sl@0
|
240 |
} {}
|
sl@0
|
241 |
test string-5.6 {string index} {
|
sl@0
|
242 |
list [catch {string index abcde -10} msg] $msg
|
sl@0
|
243 |
} {0 {}}
|
sl@0
|
244 |
test string-5.7 {string index} {
|
sl@0
|
245 |
list [catch {string index a xyz} msg] $msg
|
sl@0
|
246 |
} {1 {bad index "xyz": must be integer or end?-integer?}}
|
sl@0
|
247 |
test string-5.8 {string index} {
|
sl@0
|
248 |
string index abc end
|
sl@0
|
249 |
} c
|
sl@0
|
250 |
test string-5.9 {string index} {
|
sl@0
|
251 |
string index abc end-1
|
sl@0
|
252 |
} b
|
sl@0
|
253 |
test string-5.10 {string index, unicode} {
|
sl@0
|
254 |
string index abc\u7266d 4
|
sl@0
|
255 |
} d
|
sl@0
|
256 |
test string-5.11 {string index, unicode} {
|
sl@0
|
257 |
string index abc\u7266d 3
|
sl@0
|
258 |
} \u7266
|
sl@0
|
259 |
test string-5.12 {string index, unicode over char length, under byte length} {
|
sl@0
|
260 |
string index \334\374\334\374 6
|
sl@0
|
261 |
} {}
|
sl@0
|
262 |
test string-5.13 {string index, bytearray object} {
|
sl@0
|
263 |
string index [binary format a5 fuz] 0
|
sl@0
|
264 |
} f
|
sl@0
|
265 |
test string-5.14 {string index, bytearray object} {
|
sl@0
|
266 |
string index [binary format I* {0x50515253 0x52}] 3
|
sl@0
|
267 |
} S
|
sl@0
|
268 |
test string-5.15 {string index, bytearray object} {
|
sl@0
|
269 |
set b [binary format I* {0x50515253 0x52}]
|
sl@0
|
270 |
set i1 [string index $b end-6]
|
sl@0
|
271 |
set i2 [string index $b 1]
|
sl@0
|
272 |
string compare $i1 $i2
|
sl@0
|
273 |
} 0
|
sl@0
|
274 |
test string-5.16 {string index, bytearray object with string obj shimmering} {
|
sl@0
|
275 |
set str "0123456789\x00 abcdedfghi"
|
sl@0
|
276 |
binary scan $str H* dump
|
sl@0
|
277 |
string compare [string index $str 10] \x00
|
sl@0
|
278 |
} 0
|
sl@0
|
279 |
test string-5.17 {string index, bad integer} {
|
sl@0
|
280 |
list [catch {string index "abc" 08} msg] $msg
|
sl@0
|
281 |
} {1 {bad index "08": must be integer or end?-integer? (looks like invalid octal number)}}
|
sl@0
|
282 |
test string-5.18 {string index, bad integer} {
|
sl@0
|
283 |
list [catch {string index "abc" end-00289} msg] $msg
|
sl@0
|
284 |
} {1 {bad index "end-00289": must be integer or end?-integer? (looks like invalid octal number)}}
|
sl@0
|
285 |
test string-5.19 {string index, bytearray object out of bounds} {
|
sl@0
|
286 |
string index [binary format I* {0x50515253 0x52}] -1
|
sl@0
|
287 |
} {}
|
sl@0
|
288 |
test string-5.20 {string index, bytearray object out of bounds} {
|
sl@0
|
289 |
string index [binary format I* {0x50515253 0x52}] 20
|
sl@0
|
290 |
} {}
|
sl@0
|
291 |
|
sl@0
|
292 |
|
sl@0
|
293 |
proc largest_int {} {
|
sl@0
|
294 |
# This will give us what the largest valid int on this machine is,
|
sl@0
|
295 |
# so we can test for overflow properly below on >32 bit systems
|
sl@0
|
296 |
set int 1
|
sl@0
|
297 |
set exp 7; # assume we get at least 8 bits
|
sl@0
|
298 |
while {$int > 0} { set int [expr {wide(1) << [incr exp]}] }
|
sl@0
|
299 |
return [expr {$int-1}]
|
sl@0
|
300 |
}
|
sl@0
|
301 |
|
sl@0
|
302 |
test string-6.1 {string is, too few args} {
|
sl@0
|
303 |
list [catch {string is} msg] $msg
|
sl@0
|
304 |
} {1 {wrong # args: should be "string is class ?-strict? ?-failindex var? str"}}
|
sl@0
|
305 |
test string-6.2 {string is, too few args} {
|
sl@0
|
306 |
list [catch {string is alpha} msg] $msg
|
sl@0
|
307 |
} {1 {wrong # args: should be "string is class ?-strict? ?-failindex var? str"}}
|
sl@0
|
308 |
test string-6.3 {string is, bad args} {
|
sl@0
|
309 |
list [catch {string is alpha -failin str} msg] $msg
|
sl@0
|
310 |
} {1 {wrong # args: should be "string is alpha ?-strict? ?-failindex var? str"}}
|
sl@0
|
311 |
test string-6.4 {string is, too many args} {
|
sl@0
|
312 |
list [catch {string is alpha -failin var -strict str more} msg] $msg
|
sl@0
|
313 |
} {1 {wrong # args: should be "string is class ?-strict? ?-failindex var? str"}}
|
sl@0
|
314 |
test string-6.5 {string is, class check} {
|
sl@0
|
315 |
list [catch {string is bogus str} msg] $msg
|
sl@0
|
316 |
} {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}}
|
sl@0
|
317 |
test string-6.6 {string is, ambiguous class} {
|
sl@0
|
318 |
list [catch {string is al str} msg] $msg
|
sl@0
|
319 |
} {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}}
|
sl@0
|
320 |
test string-6.7 {string is alpha, all ok} {
|
sl@0
|
321 |
string is alpha -strict -failindex var abc
|
sl@0
|
322 |
} 1
|
sl@0
|
323 |
test string-6.8 {string is, error in var} {
|
sl@0
|
324 |
list [string is alpha -failindex var abc5def] $var
|
sl@0
|
325 |
} {0 3}
|
sl@0
|
326 |
test string-6.9 {string is, var shouldn't get set} {
|
sl@0
|
327 |
catch {unset var}
|
sl@0
|
328 |
list [catch {string is alpha -failindex var abc; set var} msg] $msg
|
sl@0
|
329 |
} {1 {can't read "var": no such variable}}
|
sl@0
|
330 |
test string-6.10 {string is, ok on empty} {
|
sl@0
|
331 |
string is alpha {}
|
sl@0
|
332 |
} 1
|
sl@0
|
333 |
test string-6.11 {string is, -strict check against empty} {
|
sl@0
|
334 |
string is alpha -strict {}
|
sl@0
|
335 |
} 0
|
sl@0
|
336 |
test string-6.12 {string is alnum, true} {
|
sl@0
|
337 |
string is alnum abc123
|
sl@0
|
338 |
} 1
|
sl@0
|
339 |
test string-6.13 {string is alnum, false} {
|
sl@0
|
340 |
list [string is alnum -failindex var abc1.23] $var
|
sl@0
|
341 |
} {0 4}
|
sl@0
|
342 |
test string-6.14 {string is alnum, unicode} {
|
sl@0
|
343 |
string is alnum abcü
|
sl@0
|
344 |
} 1
|
sl@0
|
345 |
test string-6.15 {string is alpha, true} {
|
sl@0
|
346 |
string is alpha abc
|
sl@0
|
347 |
} 1
|
sl@0
|
348 |
test string-6.16 {string is alpha, false} {
|
sl@0
|
349 |
list [string is alpha -fail var a1bcde] $var
|
sl@0
|
350 |
} {0 1}
|
sl@0
|
351 |
test string-6.17 {string is alpha, unicode} {
|
sl@0
|
352 |
string is alpha abc\374
|
sl@0
|
353 |
} 1
|
sl@0
|
354 |
test string-6.18 {string is ascii, true} {
|
sl@0
|
355 |
string is ascii abc\u007Fend
|
sl@0
|
356 |
} 1
|
sl@0
|
357 |
test string-6.19 {string is ascii, false} {
|
sl@0
|
358 |
list [string is ascii -fail var abcdef\u0080more] $var
|
sl@0
|
359 |
} {0 6}
|
sl@0
|
360 |
test string-6.20 {string is boolean, true} {
|
sl@0
|
361 |
string is boolean true
|
sl@0
|
362 |
} 1
|
sl@0
|
363 |
test string-6.21 {string is boolean, true} {
|
sl@0
|
364 |
string is boolean f
|
sl@0
|
365 |
} 1
|
sl@0
|
366 |
test string-6.22 {string is boolean, true based on type} {
|
sl@0
|
367 |
string is bool [string compare a a]
|
sl@0
|
368 |
} 1
|
sl@0
|
369 |
test string-6.23 {string is boolean, false} {
|
sl@0
|
370 |
list [string is bool -fail var yada] $var
|
sl@0
|
371 |
} {0 0}
|
sl@0
|
372 |
test string-6.24 {string is digit, true} {
|
sl@0
|
373 |
string is digit 0123456789
|
sl@0
|
374 |
} 1
|
sl@0
|
375 |
test string-6.25 {string is digit, false} {
|
sl@0
|
376 |
list [string is digit -fail var 0123Ü567] $var
|
sl@0
|
377 |
} {0 4}
|
sl@0
|
378 |
test string-6.26 {string is digit, false} {
|
sl@0
|
379 |
list [string is digit -fail var +123567] $var
|
sl@0
|
380 |
} {0 0}
|
sl@0
|
381 |
test string-6.27 {string is double, true} {
|
sl@0
|
382 |
string is double 1
|
sl@0
|
383 |
} 1
|
sl@0
|
384 |
test string-6.28 {string is double, true} {
|
sl@0
|
385 |
string is double [expr double(1)]
|
sl@0
|
386 |
} 1
|
sl@0
|
387 |
test string-6.29 {string is double, true} {
|
sl@0
|
388 |
string is double 1.0
|
sl@0
|
389 |
} 1
|
sl@0
|
390 |
test string-6.30 {string is double, true} {
|
sl@0
|
391 |
string is double [string compare a a]
|
sl@0
|
392 |
} 1
|
sl@0
|
393 |
test string-6.31 {string is double, true} {
|
sl@0
|
394 |
string is double " +1.0e-1 "
|
sl@0
|
395 |
} 1
|
sl@0
|
396 |
test string-6.32 {string is double, true} {
|
sl@0
|
397 |
string is double "\n1.0\v"
|
sl@0
|
398 |
} 1
|
sl@0
|
399 |
test string-6.33 {string is double, false} {
|
sl@0
|
400 |
list [string is double -fail var 1abc] $var
|
sl@0
|
401 |
} {0 1}
|
sl@0
|
402 |
test string-6.34 {string is double, false} {
|
sl@0
|
403 |
list [string is double -fail var abc] $var
|
sl@0
|
404 |
} {0 0}
|
sl@0
|
405 |
test string-6.35 {string is double, false} {
|
sl@0
|
406 |
list [string is double -fail var " 1.0e4e4 "] $var
|
sl@0
|
407 |
} {0 8}
|
sl@0
|
408 |
test string-6.36 {string is double, false} {
|
sl@0
|
409 |
list [string is double -fail var "\n"] $var
|
sl@0
|
410 |
} {0 0}
|
sl@0
|
411 |
test string-6.37 {string is double, false on int overflow} {
|
sl@0
|
412 |
# Make it the largest int recognizable, with one more digit for overflow
|
sl@0
|
413 |
list [string is double -fail var [largest_int]0] $var
|
sl@0
|
414 |
} {0 -1}
|
sl@0
|
415 |
test string-6.38 {string is double, false on underflow} {
|
sl@0
|
416 |
catch {unset var}
|
sl@0
|
417 |
list [string is double -fail var 123e-9999] $var
|
sl@0
|
418 |
} {0 -1}
|
sl@0
|
419 |
test string-6.39 {string is double, false} {nonPortable} {
|
sl@0
|
420 |
# This test is non-portable because IRIX thinks
|
sl@0
|
421 |
# that .e1 is a valid double - this is really a bug
|
sl@0
|
422 |
# on IRIX as .e1 should NOT be a valid double
|
sl@0
|
423 |
|
sl@0
|
424 |
list [string is double -fail var .e1] $var
|
sl@0
|
425 |
} {0 0}
|
sl@0
|
426 |
test string-6.40 {string is false, true} {
|
sl@0
|
427 |
string is false false
|
sl@0
|
428 |
} 1
|
sl@0
|
429 |
test string-6.41 {string is false, true} {
|
sl@0
|
430 |
string is false FaLsE
|
sl@0
|
431 |
} 1
|
sl@0
|
432 |
test string-6.42 {string is false, true} {
|
sl@0
|
433 |
string is false N
|
sl@0
|
434 |
} 1
|
sl@0
|
435 |
test string-6.43 {string is false, true} {
|
sl@0
|
436 |
string is false 0
|
sl@0
|
437 |
} 1
|
sl@0
|
438 |
test string-6.44 {string is false, true} {
|
sl@0
|
439 |
string is false off
|
sl@0
|
440 |
} 1
|
sl@0
|
441 |
test string-6.45 {string is false, false} {
|
sl@0
|
442 |
list [string is false -fail var abc] $var
|
sl@0
|
443 |
} {0 0}
|
sl@0
|
444 |
test string-6.46 {string is false, false} {
|
sl@0
|
445 |
catch {unset var}
|
sl@0
|
446 |
list [string is false -fail var Y] $var
|
sl@0
|
447 |
} {0 0}
|
sl@0
|
448 |
test string-6.47 {string is false, false} {
|
sl@0
|
449 |
catch {unset var}
|
sl@0
|
450 |
list [string is false -fail var offensive] $var
|
sl@0
|
451 |
} {0 0}
|
sl@0
|
452 |
test string-6.48 {string is integer, true} {
|
sl@0
|
453 |
string is integer +1234567890
|
sl@0
|
454 |
} 1
|
sl@0
|
455 |
test string-6.49 {string is integer, true on type} {
|
sl@0
|
456 |
string is integer [expr int(50.0)]
|
sl@0
|
457 |
} 1
|
sl@0
|
458 |
test string-6.50 {string is integer, true} {
|
sl@0
|
459 |
string is integer [list -10]
|
sl@0
|
460 |
} 1
|
sl@0
|
461 |
test string-6.51 {string is integer, true as hex} {
|
sl@0
|
462 |
string is integer 0xabcdef
|
sl@0
|
463 |
} 1
|
sl@0
|
464 |
test string-6.52 {string is integer, true as octal} {
|
sl@0
|
465 |
string is integer 012345
|
sl@0
|
466 |
} 1
|
sl@0
|
467 |
test string-6.53 {string is integer, true with whitespace} {
|
sl@0
|
468 |
string is integer " \n1234\v"
|
sl@0
|
469 |
} 1
|
sl@0
|
470 |
test string-6.54 {string is integer, false} {
|
sl@0
|
471 |
list [string is integer -fail var 123abc] $var
|
sl@0
|
472 |
} {0 3}
|
sl@0
|
473 |
test string-6.55 {string is integer, false on overflow} {
|
sl@0
|
474 |
list [string is integer -fail var +[largest_int]0] $var
|
sl@0
|
475 |
} {0 -1}
|
sl@0
|
476 |
test string-6.56 {string is integer, false} {
|
sl@0
|
477 |
list [string is integer -fail var [expr double(1)]] $var
|
sl@0
|
478 |
} {0 1}
|
sl@0
|
479 |
test string-6.57 {string is integer, false} {
|
sl@0
|
480 |
list [string is integer -fail var " "] $var
|
sl@0
|
481 |
} {0 0}
|
sl@0
|
482 |
test string-6.58 {string is integer, false on bad octal} {
|
sl@0
|
483 |
list [string is integer -fail var 036963] $var
|
sl@0
|
484 |
} {0 3}
|
sl@0
|
485 |
test string-6.59 {string is integer, false on bad hex} {
|
sl@0
|
486 |
list [string is integer -fail var 0X345XYZ] $var
|
sl@0
|
487 |
} {0 5}
|
sl@0
|
488 |
test string-6.60 {string is lower, true} {
|
sl@0
|
489 |
string is lower abc
|
sl@0
|
490 |
} 1
|
sl@0
|
491 |
test string-6.61 {string is lower, unicode true} {
|
sl@0
|
492 |
string is lower abcüue
|
sl@0
|
493 |
} 1
|
sl@0
|
494 |
test string-6.62 {string is lower, false} {
|
sl@0
|
495 |
list [string is lower -fail var aBc] $var
|
sl@0
|
496 |
} {0 1}
|
sl@0
|
497 |
test string-6.63 {string is lower, false} {
|
sl@0
|
498 |
list [string is lower -fail var abc1] $var
|
sl@0
|
499 |
} {0 3}
|
sl@0
|
500 |
test string-6.64 {string is lower, unicode false} {
|
sl@0
|
501 |
list [string is lower -fail var abÜUE] $var
|
sl@0
|
502 |
} {0 2}
|
sl@0
|
503 |
test string-6.65 {string is space, true} {
|
sl@0
|
504 |
string is space " \t\n\v\f"
|
sl@0
|
505 |
} 1
|
sl@0
|
506 |
test string-6.66 {string is space, false} {
|
sl@0
|
507 |
list [string is space -fail var " \t\n\v1\f"] $var
|
sl@0
|
508 |
} {0 4}
|
sl@0
|
509 |
test string-6.67 {string is true, true} {
|
sl@0
|
510 |
string is true true
|
sl@0
|
511 |
} 1
|
sl@0
|
512 |
test string-6.68 {string is true, true} {
|
sl@0
|
513 |
string is true TrU
|
sl@0
|
514 |
} 1
|
sl@0
|
515 |
test string-6.69 {string is true, true} {
|
sl@0
|
516 |
string is true ye
|
sl@0
|
517 |
} 1
|
sl@0
|
518 |
test string-6.70 {string is true, true} {
|
sl@0
|
519 |
string is true 1
|
sl@0
|
520 |
} 1
|
sl@0
|
521 |
test string-6.71 {string is true, true} {
|
sl@0
|
522 |
string is true on
|
sl@0
|
523 |
} 1
|
sl@0
|
524 |
test string-6.72 {string is true, false} {
|
sl@0
|
525 |
list [string is true -fail var onto] $var
|
sl@0
|
526 |
} {0 0}
|
sl@0
|
527 |
test string-6.73 {string is true, false} {
|
sl@0
|
528 |
catch {unset var}
|
sl@0
|
529 |
list [string is true -fail var 25] $var
|
sl@0
|
530 |
} {0 0}
|
sl@0
|
531 |
test string-6.74 {string is true, false} {
|
sl@0
|
532 |
catch {unset var}
|
sl@0
|
533 |
list [string is true -fail var no] $var
|
sl@0
|
534 |
} {0 0}
|
sl@0
|
535 |
test string-6.75 {string is upper, true} {
|
sl@0
|
536 |
string is upper ABC
|
sl@0
|
537 |
} 1
|
sl@0
|
538 |
test string-6.76 {string is upper, unicode true} {
|
sl@0
|
539 |
string is upper ABCÜUE
|
sl@0
|
540 |
} 1
|
sl@0
|
541 |
test string-6.77 {string is upper, false} {
|
sl@0
|
542 |
list [string is upper -fail var AbC] $var
|
sl@0
|
543 |
} {0 1}
|
sl@0
|
544 |
test string-6.78 {string is upper, false} {
|
sl@0
|
545 |
list [string is upper -fail var AB2C] $var
|
sl@0
|
546 |
} {0 2}
|
sl@0
|
547 |
test string-6.79 {string is upper, unicode false} {
|
sl@0
|
548 |
list [string is upper -fail var ABCüue] $var
|
sl@0
|
549 |
} {0 3}
|
sl@0
|
550 |
test string-6.80 {string is wordchar, true} {
|
sl@0
|
551 |
string is wordchar abc_123
|
sl@0
|
552 |
} 1
|
sl@0
|
553 |
test string-6.81 {string is wordchar, unicode true} {
|
sl@0
|
554 |
string is wordchar abcüabÜAB\u5001
|
sl@0
|
555 |
} 1
|
sl@0
|
556 |
test string-6.82 {string is wordchar, false} {
|
sl@0
|
557 |
list [string is wordchar -fail var abcd.ef] $var
|
sl@0
|
558 |
} {0 4}
|
sl@0
|
559 |
test string-6.83 {string is wordchar, unicode false} {
|
sl@0
|
560 |
list [string is wordchar -fail var abc\u0080def] $var
|
sl@0
|
561 |
} {0 3}
|
sl@0
|
562 |
test string-6.84 {string is control} {
|
sl@0
|
563 |
## Control chars are in the ranges
|
sl@0
|
564 |
## 00..1F && 7F..9F
|
sl@0
|
565 |
list [string is control -fail var \x00\x01\x10\x1F\x7F\x80\x9F\x60] $var
|
sl@0
|
566 |
} {0 7}
|
sl@0
|
567 |
test string-6.85 {string is control} {
|
sl@0
|
568 |
string is control \u0100
|
sl@0
|
569 |
} 0
|
sl@0
|
570 |
test string-6.86 {string is graph} {
|
sl@0
|
571 |
## graph is any print char, except space
|
sl@0
|
572 |
list [string is gra -fail var "0123abc!@#\$\u0100 "] $var
|
sl@0
|
573 |
} {0 12}
|
sl@0
|
574 |
test string-6.87 {string is print} {
|
sl@0
|
575 |
## basically any printable char
|
sl@0
|
576 |
list [string is print -fail var "0123abc!@#\$\u0100 \u0010"] $var
|
sl@0
|
577 |
} {0 13}
|
sl@0
|
578 |
test string-6.88 {string is punct} {
|
sl@0
|
579 |
## any graph char that isn't alnum
|
sl@0
|
580 |
list [string is punct -fail var "_!@#\u00beq0"] $var
|
sl@0
|
581 |
} {0 4}
|
sl@0
|
582 |
test string-6.89 {string is xdigit} {
|
sl@0
|
583 |
list [string is xdigit -fail var 0123456789\u0061bcdefABCDEFg] $var
|
sl@0
|
584 |
} {0 22}
|
sl@0
|
585 |
|
sl@0
|
586 |
test string-6.90 {string is integer, bad integers} {
|
sl@0
|
587 |
# SF bug #634856
|
sl@0
|
588 |
set result ""
|
sl@0
|
589 |
set numbers [list 1 +1 ++1 +-1 -+1 -1 --1 "- +1"]
|
sl@0
|
590 |
foreach num $numbers {
|
sl@0
|
591 |
lappend result [string is int -strict $num]
|
sl@0
|
592 |
}
|
sl@0
|
593 |
set result
|
sl@0
|
594 |
} {1 1 0 0 0 1 0 0}
|
sl@0
|
595 |
test string-6.91 {string is double, bad doubles} {
|
sl@0
|
596 |
set result ""
|
sl@0
|
597 |
set numbers [list 1.0 +1.0 ++1.0 +-1.0 -+1.0 -1.0 --1.0 "- +1.0"]
|
sl@0
|
598 |
foreach num $numbers {
|
sl@0
|
599 |
lappend result [string is double -strict $num]
|
sl@0
|
600 |
}
|
sl@0
|
601 |
set result
|
sl@0
|
602 |
} {1 1 0 0 0 1 0 0}
|
sl@0
|
603 |
test string-6.92 {string is double, 32-bit overflow} {
|
sl@0
|
604 |
# Bug 718878
|
sl@0
|
605 |
set x 0x100000000
|
sl@0
|
606 |
list [string is integer -failindex var $x] $var
|
sl@0
|
607 |
} {0 -1}
|
sl@0
|
608 |
test string-6.93 {string is double, 32-bit overflow} {
|
sl@0
|
609 |
# Bug 718878
|
sl@0
|
610 |
set x 0x100000000
|
sl@0
|
611 |
append x ""
|
sl@0
|
612 |
list [string is integer -failindex var $x] $var
|
sl@0
|
613 |
} {0 -1}
|
sl@0
|
614 |
test string-6.94 {string is double, 32-bit overflow} {
|
sl@0
|
615 |
# Bug 718878
|
sl@0
|
616 |
set x 0x100000000
|
sl@0
|
617 |
list [string is integer -failindex var [expr {$x}]] $var
|
sl@0
|
618 |
} {0 -1}
|
sl@0
|
619 |
|
sl@0
|
620 |
catch {rename largest_int {}}
|
sl@0
|
621 |
|
sl@0
|
622 |
test string-7.1 {string last, too few args} {
|
sl@0
|
623 |
list [catch {string last a} msg] $msg
|
sl@0
|
624 |
} {1 {wrong # args: should be "string last subString string ?startIndex?"}}
|
sl@0
|
625 |
test string-7.2 {string last, bad args} {
|
sl@0
|
626 |
list [catch {string last a b c} msg] $msg
|
sl@0
|
627 |
} {1 {bad index "c": must be integer or end?-integer?}}
|
sl@0
|
628 |
test string-7.3 {string last, too many args} {
|
sl@0
|
629 |
list [catch {string last a b c d} msg] $msg
|
sl@0
|
630 |
} {1 {wrong # args: should be "string last subString string ?startIndex?"}}
|
sl@0
|
631 |
test string-7.4 {string last} {
|
sl@0
|
632 |
string la xxx xxxx123xx345x678
|
sl@0
|
633 |
} 1
|
sl@0
|
634 |
test string-7.5 {string last} {
|
sl@0
|
635 |
string last xx xxxx123xx345x678
|
sl@0
|
636 |
} 7
|
sl@0
|
637 |
test string-7.6 {string last} {
|
sl@0
|
638 |
string las x xxxx123xx345x678
|
sl@0
|
639 |
} 12
|
sl@0
|
640 |
test string-7.7 {string last, unicode} {
|
sl@0
|
641 |
string las x xxxx12\u7266xx345x678
|
sl@0
|
642 |
} 12
|
sl@0
|
643 |
test string-7.8 {string last, unicode} {
|
sl@0
|
644 |
string las \u7266 xxxx12\u7266xx345x678
|
sl@0
|
645 |
} 6
|
sl@0
|
646 |
test string-7.9 {string last, stop index} {
|
sl@0
|
647 |
string las \u7266 xxxx12\u7266xx345x678
|
sl@0
|
648 |
} 6
|
sl@0
|
649 |
test string-7.10 {string last, unicode} {
|
sl@0
|
650 |
string las \u7266 xxxx12\u7266xx345x678
|
sl@0
|
651 |
} 6
|
sl@0
|
652 |
test string-7.11 {string last, start index} {
|
sl@0
|
653 |
string last \u7266 abc\u7266x 3
|
sl@0
|
654 |
} 3
|
sl@0
|
655 |
test string-7.12 {string last, start index} {
|
sl@0
|
656 |
string last \u7266 abc\u7266x 2
|
sl@0
|
657 |
} -1
|
sl@0
|
658 |
test string-7.13 {string last, start index} {
|
sl@0
|
659 |
## Constrain to last 'a' should work
|
sl@0
|
660 |
string last ba badbad end-1
|
sl@0
|
661 |
} 3
|
sl@0
|
662 |
test string-7.14 {string last, start index} {
|
sl@0
|
663 |
## Constrain to last 'b' should skip last 'ba'
|
sl@0
|
664 |
string last ba badbad end-2
|
sl@0
|
665 |
} 0
|
sl@0
|
666 |
test string-7.15 {string last, start index} {
|
sl@0
|
667 |
string last \334a \334ad\334ad 0
|
sl@0
|
668 |
} -1
|
sl@0
|
669 |
test string-7.16 {string last, start index} {
|
sl@0
|
670 |
string last \334a \334ad\334ad end-1
|
sl@0
|
671 |
} 3
|
sl@0
|
672 |
|
sl@0
|
673 |
test string-8.1 {string bytelength} {
|
sl@0
|
674 |
list [catch {string bytelength} msg] $msg
|
sl@0
|
675 |
} {1 {wrong # args: should be "string bytelength string"}}
|
sl@0
|
676 |
test string-8.2 {string bytelength} {
|
sl@0
|
677 |
list [catch {string bytelength a b} msg] $msg
|
sl@0
|
678 |
} {1 {wrong # args: should be "string bytelength string"}}
|
sl@0
|
679 |
test string-8.3 {string bytelength} {
|
sl@0
|
680 |
string bytelength "\u00c7"
|
sl@0
|
681 |
} 2
|
sl@0
|
682 |
test string-8.4 {string bytelength} {
|
sl@0
|
683 |
string b ""
|
sl@0
|
684 |
} 0
|
sl@0
|
685 |
|
sl@0
|
686 |
test string-9.1 {string length} {
|
sl@0
|
687 |
list [catch {string length} msg] $msg
|
sl@0
|
688 |
} {1 {wrong # args: should be "string length string"}}
|
sl@0
|
689 |
test string-9.2 {string length} {
|
sl@0
|
690 |
list [catch {string length a b} msg] $msg
|
sl@0
|
691 |
} {1 {wrong # args: should be "string length string"}}
|
sl@0
|
692 |
test string-9.3 {string length} {
|
sl@0
|
693 |
string length "a little string"
|
sl@0
|
694 |
} 15
|
sl@0
|
695 |
test string-9.4 {string length} {
|
sl@0
|
696 |
string le ""
|
sl@0
|
697 |
} 0
|
sl@0
|
698 |
test string-9.5 {string length, unicode} {
|
sl@0
|
699 |
string le "abcd\u7266"
|
sl@0
|
700 |
} 5
|
sl@0
|
701 |
test string-9.6 {string length, bytearray object} {
|
sl@0
|
702 |
string length [binary format a5 foo]
|
sl@0
|
703 |
} 5
|
sl@0
|
704 |
test string-9.7 {string length, bytearray object} {
|
sl@0
|
705 |
string length [binary format I* {0x50515253 0x52}]
|
sl@0
|
706 |
} 8
|
sl@0
|
707 |
|
sl@0
|
708 |
test string-10.1 {string map, too few args} {
|
sl@0
|
709 |
list [catch {string map} msg] $msg
|
sl@0
|
710 |
} {1 {wrong # args: should be "string map ?-nocase? charMap string"}}
|
sl@0
|
711 |
test string-10.2 {string map, bad args} {
|
sl@0
|
712 |
list [catch {string map {a b} abba oops} msg] $msg
|
sl@0
|
713 |
} {1 {bad option "a b": must be -nocase}}
|
sl@0
|
714 |
test string-10.3 {string map, too many args} {
|
sl@0
|
715 |
list [catch {string map -nocase {a b} str1 str2} msg] $msg
|
sl@0
|
716 |
} {1 {wrong # args: should be "string map ?-nocase? charMap string"}}
|
sl@0
|
717 |
test string-10.4 {string map} {
|
sl@0
|
718 |
string map {a b} abba
|
sl@0
|
719 |
} {bbbb}
|
sl@0
|
720 |
test string-10.5 {string map} {
|
sl@0
|
721 |
string map {a b} a
|
sl@0
|
722 |
} {b}
|
sl@0
|
723 |
test string-10.6 {string map -nocase} {
|
sl@0
|
724 |
string map -nocase {a b} Abba
|
sl@0
|
725 |
} {bbbb}
|
sl@0
|
726 |
test string-10.7 {string map} {
|
sl@0
|
727 |
string map {abc 321 ab * a A} aabcabaababcab
|
sl@0
|
728 |
} {A321*A*321*}
|
sl@0
|
729 |
test string-10.8 {string map -nocase} {
|
sl@0
|
730 |
string map -nocase {aBc 321 Ab * a A} aabcabaababcab
|
sl@0
|
731 |
} {A321*A*321*}
|
sl@0
|
732 |
test string-10.9 {string map -nocase} {
|
sl@0
|
733 |
string map -no {abc 321 Ab * a A} aAbCaBaAbAbcAb
|
sl@0
|
734 |
} {A321*A*321*}
|
sl@0
|
735 |
test string-10.10 {string map} {
|
sl@0
|
736 |
list [catch {string map {a b c} abba} msg] $msg
|
sl@0
|
737 |
} {1 {char map list unbalanced}}
|
sl@0
|
738 |
test string-10.11 {string map, nulls} {
|
sl@0
|
739 |
string map {\x00 NULL blah \x00nix} {qwerty}
|
sl@0
|
740 |
} {qwerty}
|
sl@0
|
741 |
test string-10.12 {string map, unicode} {
|
sl@0
|
742 |
string map [list \374 ue UE \334] "a\374ueUE\000EU"
|
sl@0
|
743 |
} aueue\334\0EU
|
sl@0
|
744 |
test string-10.13 {string map, -nocase unicode} {
|
sl@0
|
745 |
string map -nocase [list \374 ue UE \334] "a\374ueUE\000EU"
|
sl@0
|
746 |
} aue\334\334\0EU
|
sl@0
|
747 |
test string-10.14 {string map, -nocase null arguments} {
|
sl@0
|
748 |
string map -nocase {{} abc} foo
|
sl@0
|
749 |
} foo
|
sl@0
|
750 |
test string-10.15 {string map, one pair case} {
|
sl@0
|
751 |
string map -nocase {abc 32} aAbCaBaAbAbcAb
|
sl@0
|
752 |
} {a32aBaAb32Ab}
|
sl@0
|
753 |
test string-10.16 {string map, one pair case} {
|
sl@0
|
754 |
string map -nocase {ab 4321} aAbCaBaAbAbcAb
|
sl@0
|
755 |
} {a4321C4321a43214321c4321}
|
sl@0
|
756 |
test string-10.17 {string map, one pair case} {
|
sl@0
|
757 |
string map {Ab 4321} aAbCaBaAbAbcAb
|
sl@0
|
758 |
} {a4321CaBa43214321c4321}
|
sl@0
|
759 |
test string-10.18 {string map, empty argument} {
|
sl@0
|
760 |
string map -nocase {{} abc} foo
|
sl@0
|
761 |
} foo
|
sl@0
|
762 |
test string-10.19 {string map, empty arguments} {
|
sl@0
|
763 |
string map -nocase {{} abc f bar {} def} foo
|
sl@0
|
764 |
} baroo
|
sl@0
|
765 |
test string-10.20 {string map, nasty sharing crash from [Bug 1018562]} {
|
sl@0
|
766 |
set a {a b}
|
sl@0
|
767 |
string map $a $a
|
sl@0
|
768 |
} {b b}
|
sl@0
|
769 |
test string-10.21 {string map, ABR checks} {
|
sl@0
|
770 |
string map {longstring foob} long
|
sl@0
|
771 |
} long
|
sl@0
|
772 |
test string-10.22 {string map, ABR checks} {
|
sl@0
|
773 |
string map {long foob} long
|
sl@0
|
774 |
} foob
|
sl@0
|
775 |
test string-10.23 {string map, ABR checks} {
|
sl@0
|
776 |
string map {lon foob} long
|
sl@0
|
777 |
} foobg
|
sl@0
|
778 |
test string-10.24 {string map, ABR checks} {
|
sl@0
|
779 |
string map {lon foob} longlo
|
sl@0
|
780 |
} foobglo
|
sl@0
|
781 |
test string-10.25 {string map, ABR checks} {
|
sl@0
|
782 |
string map {lon foob} longlon
|
sl@0
|
783 |
} foobgfoob
|
sl@0
|
784 |
test string-10.26 {string map, ABR checks} {
|
sl@0
|
785 |
string map {longstring foob longstring bar} long
|
sl@0
|
786 |
} long
|
sl@0
|
787 |
test string-10.27 {string map, ABR checks} {
|
sl@0
|
788 |
string map {long foob longstring bar} long
|
sl@0
|
789 |
} foob
|
sl@0
|
790 |
test string-10.28 {string map, ABR checks} {
|
sl@0
|
791 |
string map {lon foob longstring bar} long
|
sl@0
|
792 |
} foobg
|
sl@0
|
793 |
test string-10.29 {string map, ABR checks} {
|
sl@0
|
794 |
string map {lon foob longstring bar} longlo
|
sl@0
|
795 |
} foobglo
|
sl@0
|
796 |
test string-10.30 {string map, ABR checks} {
|
sl@0
|
797 |
string map {lon foob longstring bar} longlon
|
sl@0
|
798 |
} foobgfoob
|
sl@0
|
799 |
|
sl@0
|
800 |
test string-11.1 {string match, too few args} {
|
sl@0
|
801 |
list [catch {string match a} msg] $msg
|
sl@0
|
802 |
} {1 {wrong # args: should be "string match ?-nocase? pattern string"}}
|
sl@0
|
803 |
test string-11.2 {string match, too many args} {
|
sl@0
|
804 |
list [catch {string match a b c d} msg] $msg
|
sl@0
|
805 |
} {1 {wrong # args: should be "string match ?-nocase? pattern string"}}
|
sl@0
|
806 |
test string-11.3 {string match} {
|
sl@0
|
807 |
string match abc abc
|
sl@0
|
808 |
} 1
|
sl@0
|
809 |
test string-11.4 {string match} {
|
sl@0
|
810 |
string mat abc abd
|
sl@0
|
811 |
} 0
|
sl@0
|
812 |
test string-11.5 {string match} {
|
sl@0
|
813 |
string match ab*c abc
|
sl@0
|
814 |
} 1
|
sl@0
|
815 |
test string-11.6 {string match} {
|
sl@0
|
816 |
string match ab**c abc
|
sl@0
|
817 |
} 1
|
sl@0
|
818 |
test string-11.7 {string match} {
|
sl@0
|
819 |
string match ab* abcdef
|
sl@0
|
820 |
} 1
|
sl@0
|
821 |
test string-11.8 {string match} {
|
sl@0
|
822 |
string match *c abc
|
sl@0
|
823 |
} 1
|
sl@0
|
824 |
test string-11.9 {string match} {
|
sl@0
|
825 |
string match *3*6*9 0123456789
|
sl@0
|
826 |
} 1
|
sl@0
|
827 |
test string-11.10 {string match} {
|
sl@0
|
828 |
string match *3*6*9 01234567890
|
sl@0
|
829 |
} 0
|
sl@0
|
830 |
test string-11.11 {string match} {
|
sl@0
|
831 |
string match a?c abc
|
sl@0
|
832 |
} 1
|
sl@0
|
833 |
test string-11.12 {string match} {
|
sl@0
|
834 |
string match a??c abc
|
sl@0
|
835 |
} 0
|
sl@0
|
836 |
test string-11.13 {string match} {
|
sl@0
|
837 |
string match ?1??4???8? 0123456789
|
sl@0
|
838 |
} 1
|
sl@0
|
839 |
test string-11.14 {string match} {
|
sl@0
|
840 |
string match {[abc]bc} abc
|
sl@0
|
841 |
} 1
|
sl@0
|
842 |
test string-11.15 {string match} {
|
sl@0
|
843 |
string match {a[abc]c} abc
|
sl@0
|
844 |
} 1
|
sl@0
|
845 |
test string-11.16 {string match} {
|
sl@0
|
846 |
string match {a[xyz]c} abc
|
sl@0
|
847 |
} 0
|
sl@0
|
848 |
test string-11.17 {string match} {
|
sl@0
|
849 |
string match {12[2-7]45} 12345
|
sl@0
|
850 |
} 1
|
sl@0
|
851 |
test string-11.18 {string match} {
|
sl@0
|
852 |
string match {12[ab2-4cd]45} 12345
|
sl@0
|
853 |
} 1
|
sl@0
|
854 |
test string-11.19 {string match} {
|
sl@0
|
855 |
string match {12[ab2-4cd]45} 12b45
|
sl@0
|
856 |
} 1
|
sl@0
|
857 |
test string-11.20 {string match} {
|
sl@0
|
858 |
string match {12[ab2-4cd]45} 12d45
|
sl@0
|
859 |
} 1
|
sl@0
|
860 |
test string-11.21 {string match} {
|
sl@0
|
861 |
string match {12[ab2-4cd]45} 12145
|
sl@0
|
862 |
} 0
|
sl@0
|
863 |
test string-11.22 {string match} {
|
sl@0
|
864 |
string match {12[ab2-4cd]45} 12545
|
sl@0
|
865 |
} 0
|
sl@0
|
866 |
test string-11.23 {string match} {
|
sl@0
|
867 |
string match {a\*b} a*b
|
sl@0
|
868 |
} 1
|
sl@0
|
869 |
test string-11.24 {string match} {
|
sl@0
|
870 |
string match {a\*b} ab
|
sl@0
|
871 |
} 0
|
sl@0
|
872 |
test string-11.25 {string match} {
|
sl@0
|
873 |
string match {a\*\?\[\]\\\x} "a*?\[\]\\x"
|
sl@0
|
874 |
} 1
|
sl@0
|
875 |
test string-11.26 {string match} {
|
sl@0
|
876 |
string match ** ""
|
sl@0
|
877 |
} 1
|
sl@0
|
878 |
test string-11.27 {string match} {
|
sl@0
|
879 |
string match *. ""
|
sl@0
|
880 |
} 0
|
sl@0
|
881 |
test string-11.28 {string match} {
|
sl@0
|
882 |
string match "" ""
|
sl@0
|
883 |
} 1
|
sl@0
|
884 |
test string-11.29 {string match} {
|
sl@0
|
885 |
string match \[a a
|
sl@0
|
886 |
} 1
|
sl@0
|
887 |
test string-11.30 {string match, bad args} {
|
sl@0
|
888 |
list [catch {string match - b c} msg] $msg
|
sl@0
|
889 |
} {1 {bad option "-": must be -nocase}}
|
sl@0
|
890 |
test string-11.31 {string match case} {
|
sl@0
|
891 |
string match a A
|
sl@0
|
892 |
} 0
|
sl@0
|
893 |
test string-11.32 {string match nocase} {
|
sl@0
|
894 |
string match -n a A
|
sl@0
|
895 |
} 1
|
sl@0
|
896 |
test string-11.33 {string match nocase} {
|
sl@0
|
897 |
string match -nocase a\334 A\374
|
sl@0
|
898 |
} 1
|
sl@0
|
899 |
test string-11.34 {string match nocase} {
|
sl@0
|
900 |
string match -nocase a*f ABCDEf
|
sl@0
|
901 |
} 1
|
sl@0
|
902 |
test string-11.35 {string match case, false hope} {
|
sl@0
|
903 |
# This is true because '_' lies between the A-Z and a-z ranges
|
sl@0
|
904 |
string match {[A-z]} _
|
sl@0
|
905 |
} 1
|
sl@0
|
906 |
test string-11.36 {string match nocase range} {
|
sl@0
|
907 |
# This is false because although '_' lies between the A-Z and a-z ranges,
|
sl@0
|
908 |
# we lower case the end points before checking the ranges.
|
sl@0
|
909 |
string match -nocase {[A-z]} _
|
sl@0
|
910 |
} 0
|
sl@0
|
911 |
test string-11.37 {string match nocase} {
|
sl@0
|
912 |
string match -nocase {[A-fh-Z]} g
|
sl@0
|
913 |
} 0
|
sl@0
|
914 |
test string-11.38 {string match case, reverse range} {
|
sl@0
|
915 |
string match {[A-fh-Z]} g
|
sl@0
|
916 |
} 1
|
sl@0
|
917 |
test string-11.39 {string match, *\ case} {
|
sl@0
|
918 |
string match {*\abc} abc
|
sl@0
|
919 |
} 1
|
sl@0
|
920 |
test string-11.40 {string match, *special case} {
|
sl@0
|
921 |
string match {*[ab]} abc
|
sl@0
|
922 |
} 0
|
sl@0
|
923 |
test string-11.41 {string match, *special case} {
|
sl@0
|
924 |
string match {*[ab]*} abc
|
sl@0
|
925 |
} 1
|
sl@0
|
926 |
test string-11.42 {string match, *special case} {
|
sl@0
|
927 |
string match "*\\" "\\"
|
sl@0
|
928 |
} 0
|
sl@0
|
929 |
test string-11.43 {string match, *special case} {
|
sl@0
|
930 |
string match "*\\\\" "\\"
|
sl@0
|
931 |
} 1
|
sl@0
|
932 |
test string-11.44 {string match, *special case} {
|
sl@0
|
933 |
string match "*???" "12345"
|
sl@0
|
934 |
} 1
|
sl@0
|
935 |
test string-11.45 {string match, *special case} {
|
sl@0
|
936 |
string match "*???" "12"
|
sl@0
|
937 |
} 0
|
sl@0
|
938 |
test string-11.46 {string match, *special case} {
|
sl@0
|
939 |
string match "*\\*" "abc*"
|
sl@0
|
940 |
} 1
|
sl@0
|
941 |
test string-11.47 {string match, *special case} {
|
sl@0
|
942 |
string match "*\\*" "*"
|
sl@0
|
943 |
} 1
|
sl@0
|
944 |
test string-11.48 {string match, *special case} {
|
sl@0
|
945 |
string match "*\\*" "*abc"
|
sl@0
|
946 |
} 0
|
sl@0
|
947 |
test string-11.49 {string match, *special case} {
|
sl@0
|
948 |
string match "?\\*" "a*"
|
sl@0
|
949 |
} 1
|
sl@0
|
950 |
test string-11.50 {string match, *special case} {
|
sl@0
|
951 |
string match "\\" "\\"
|
sl@0
|
952 |
} 0
|
sl@0
|
953 |
test string-11.51 {string match; *, -nocase and UTF-8} {
|
sl@0
|
954 |
string match -nocase [binary format I 717316707] \
|
sl@0
|
955 |
[binary format I 2028036707]
|
sl@0
|
956 |
} 1
|
sl@0
|
957 |
test string-11.52 {string match, null char in string} {
|
sl@0
|
958 |
set out ""
|
sl@0
|
959 |
set ptn "*abc*"
|
sl@0
|
960 |
foreach elem [list "\u0000@abc" "@abc" "\u0000@abc\u0000" "blahabcblah"] {
|
sl@0
|
961 |
lappend out [string match $ptn $elem]
|
sl@0
|
962 |
}
|
sl@0
|
963 |
set out
|
sl@0
|
964 |
} {1 1 1 1}
|
sl@0
|
965 |
test string-11.53 {string match, null char in pattern} {
|
sl@0
|
966 |
set out ""
|
sl@0
|
967 |
foreach {ptn elem} [list \
|
sl@0
|
968 |
"*\u0000abc\u0000" "\u0000abc\u0000" \
|
sl@0
|
969 |
"*\u0000abc\u0000" "\u0000abc\u0000ef" \
|
sl@0
|
970 |
"*\u0000abc\u0000*" "\u0000abc\u0000ef" \
|
sl@0
|
971 |
"*\u0000abc\u0000" "@\u0000abc\u0000ef" \
|
sl@0
|
972 |
"*\u0000abc\u0000*" "@\u0000abc\u0000ef" \
|
sl@0
|
973 |
] {
|
sl@0
|
974 |
lappend out [string match $ptn $elem]
|
sl@0
|
975 |
}
|
sl@0
|
976 |
set out
|
sl@0
|
977 |
} {1 0 1 0 1}
|
sl@0
|
978 |
test string-11.54 {string match, failure} {
|
sl@0
|
979 |
set longString ""
|
sl@0
|
980 |
for {set i 0} {$i < 10} {incr i} {
|
sl@0
|
981 |
append longString "abcdefghijklmnopqrstuvwxy\u0000z01234567890123"
|
sl@0
|
982 |
}
|
sl@0
|
983 |
string first $longString 123
|
sl@0
|
984 |
list [string match *cba* $longString] \
|
sl@0
|
985 |
[string match *a*l*\u0000* $longString] \
|
sl@0
|
986 |
[string match *a*l*\u0000*123 $longString] \
|
sl@0
|
987 |
[string match *a*l*\u0000*123* $longString] \
|
sl@0
|
988 |
[string match *a*l*\u0000*cba* $longString] \
|
sl@0
|
989 |
[string match *===* $longString]
|
sl@0
|
990 |
} {0 1 1 1 0 0}
|
sl@0
|
991 |
|
sl@0
|
992 |
test string-12.1 {string range} {
|
sl@0
|
993 |
list [catch {string range} msg] $msg
|
sl@0
|
994 |
} {1 {wrong # args: should be "string range string first last"}}
|
sl@0
|
995 |
test string-12.2 {string range} {
|
sl@0
|
996 |
list [catch {string range a 1} msg] $msg
|
sl@0
|
997 |
} {1 {wrong # args: should be "string range string first last"}}
|
sl@0
|
998 |
test string-12.3 {string range} {
|
sl@0
|
999 |
list [catch {string range a 1 2 3} msg] $msg
|
sl@0
|
1000 |
} {1 {wrong # args: should be "string range string first last"}}
|
sl@0
|
1001 |
test string-12.4 {string range} {
|
sl@0
|
1002 |
string range abcdefghijklmnop 2 14
|
sl@0
|
1003 |
} {cdefghijklmno}
|
sl@0
|
1004 |
test string-12.5 {string range, last > length} {
|
sl@0
|
1005 |
string range abcdefghijklmnop 7 1000
|
sl@0
|
1006 |
} {hijklmnop}
|
sl@0
|
1007 |
test string-12.6 {string range} {
|
sl@0
|
1008 |
string range abcdefghijklmnop 10 e
|
sl@0
|
1009 |
} {klmnop}
|
sl@0
|
1010 |
test string-12.7 {string range, last < first} {
|
sl@0
|
1011 |
string range abcdefghijklmnop 10 9
|
sl@0
|
1012 |
} {}
|
sl@0
|
1013 |
test string-12.8 {string range, first < 0} {
|
sl@0
|
1014 |
string range abcdefghijklmnop -3 2
|
sl@0
|
1015 |
} {abc}
|
sl@0
|
1016 |
test string-12.9 {string range} {
|
sl@0
|
1017 |
string range abcdefghijklmnop -3 -2
|
sl@0
|
1018 |
} {}
|
sl@0
|
1019 |
test string-12.10 {string range} {
|
sl@0
|
1020 |
string range abcdefghijklmnop 1000 1010
|
sl@0
|
1021 |
} {}
|
sl@0
|
1022 |
test string-12.11 {string range} {
|
sl@0
|
1023 |
string range abcdefghijklmnop -100 end
|
sl@0
|
1024 |
} {abcdefghijklmnop}
|
sl@0
|
1025 |
test string-12.12 {string range} {
|
sl@0
|
1026 |
list [catch {string range abc abc 1} msg] $msg
|
sl@0
|
1027 |
} {1 {bad index "abc": must be integer or end?-integer?}}
|
sl@0
|
1028 |
test string-12.13 {string range} {
|
sl@0
|
1029 |
list [catch {string range abc 1 eof} msg] $msg
|
sl@0
|
1030 |
} {1 {bad index "eof": must be integer or end?-integer?}}
|
sl@0
|
1031 |
test string-12.14 {string range} {
|
sl@0
|
1032 |
string range abcdefghijklmnop end-1 end
|
sl@0
|
1033 |
} {op}
|
sl@0
|
1034 |
test string-12.15 {string range} {
|
sl@0
|
1035 |
string range abcdefghijklmnop e 1000
|
sl@0
|
1036 |
} {p}
|
sl@0
|
1037 |
test string-12.16 {string range} {
|
sl@0
|
1038 |
string range abcdefghijklmnop end end-1
|
sl@0
|
1039 |
} {}
|
sl@0
|
1040 |
test string-12.17 {string range, unicode} {
|
sl@0
|
1041 |
string range ab\u7266cdefghijklmnop 5 5
|
sl@0
|
1042 |
} e
|
sl@0
|
1043 |
test string-12.18 {string range, unicode} {
|
sl@0
|
1044 |
string range ab\u7266cdefghijklmnop 2 3
|
sl@0
|
1045 |
} \u7266c
|
sl@0
|
1046 |
test string-12.19 {string range, bytearray object} {
|
sl@0
|
1047 |
set b [binary format I* {0x50515253 0x52}]
|
sl@0
|
1048 |
set r1 [string range $b 1 end-1]
|
sl@0
|
1049 |
set r2 [string range $b 1 6]
|
sl@0
|
1050 |
string equal $r1 $r2
|
sl@0
|
1051 |
} 1
|
sl@0
|
1052 |
test string-12.20 {string range, out of bounds indices} {
|
sl@0
|
1053 |
string range \u00ff 0 1
|
sl@0
|
1054 |
} \u00ff
|
sl@0
|
1055 |
test string-12.21 {string range, regenerates correct reps, bug 1410553} {
|
sl@0
|
1056 |
set bytes "\x00 \x03 \x41"
|
sl@0
|
1057 |
set rxBuffer {}
|
sl@0
|
1058 |
foreach ch $bytes {
|
sl@0
|
1059 |
append rxBuffer $ch
|
sl@0
|
1060 |
if {$ch eq "\x03"} {
|
sl@0
|
1061 |
string length $rxBuffer
|
sl@0
|
1062 |
}
|
sl@0
|
1063 |
}
|
sl@0
|
1064 |
set rxCRC [string range $rxBuffer end-1 end]
|
sl@0
|
1065 |
binary scan [join $bytes {}] "H*" input_hex
|
sl@0
|
1066 |
binary scan $rxBuffer "H*" rxBuffer_hex
|
sl@0
|
1067 |
binary scan $rxCRC "H*" rxCRC_hex
|
sl@0
|
1068 |
list $input_hex $rxBuffer_hex $rxCRC_hex
|
sl@0
|
1069 |
} {000341 000341 0341}
|
sl@0
|
1070 |
|
sl@0
|
1071 |
test string-13.1 {string repeat} {
|
sl@0
|
1072 |
list [catch {string repeat} msg] $msg
|
sl@0
|
1073 |
} {1 {wrong # args: should be "string repeat string count"}}
|
sl@0
|
1074 |
test string-13.2 {string repeat} {
|
sl@0
|
1075 |
list [catch {string repeat abc 10 oops} msg] $msg
|
sl@0
|
1076 |
} {1 {wrong # args: should be "string repeat string count"}}
|
sl@0
|
1077 |
test string-13.3 {string repeat} {
|
sl@0
|
1078 |
string repeat {} 100
|
sl@0
|
1079 |
} {}
|
sl@0
|
1080 |
test string-13.4 {string repeat} {
|
sl@0
|
1081 |
string repeat { } 5
|
sl@0
|
1082 |
} { }
|
sl@0
|
1083 |
test string-13.5 {string repeat} {
|
sl@0
|
1084 |
string repeat abc 3
|
sl@0
|
1085 |
} {abcabcabc}
|
sl@0
|
1086 |
test string-13.6 {string repeat} {
|
sl@0
|
1087 |
string repeat abc -1
|
sl@0
|
1088 |
} {}
|
sl@0
|
1089 |
test string-13.7 {string repeat} {
|
sl@0
|
1090 |
list [catch {string repeat abc end} msg] $msg
|
sl@0
|
1091 |
} {1 {expected integer but got "end"}}
|
sl@0
|
1092 |
test string-13.8 {string repeat} {
|
sl@0
|
1093 |
string repeat {} -1000
|
sl@0
|
1094 |
} {}
|
sl@0
|
1095 |
test string-13.9 {string repeat} {
|
sl@0
|
1096 |
string repeat {} 0
|
sl@0
|
1097 |
} {}
|
sl@0
|
1098 |
test string-13.10 {string repeat} {
|
sl@0
|
1099 |
string repeat def 0
|
sl@0
|
1100 |
} {}
|
sl@0
|
1101 |
test string-13.11 {string repeat} {
|
sl@0
|
1102 |
string repeat def 1
|
sl@0
|
1103 |
} def
|
sl@0
|
1104 |
test string-13.12 {string repeat} {
|
sl@0
|
1105 |
string repeat ab\u7266cd 3
|
sl@0
|
1106 |
} ab\u7266cdab\u7266cdab\u7266cd
|
sl@0
|
1107 |
test string-13.13 {string repeat} {
|
sl@0
|
1108 |
string repeat \x00 3
|
sl@0
|
1109 |
} \x00\x00\x00
|
sl@0
|
1110 |
test string-13.14 {string repeat} {
|
sl@0
|
1111 |
# The string range will ensure us that string repeat gets a unicode string
|
sl@0
|
1112 |
string repeat [string range ab\u7266cd 2 3] 3
|
sl@0
|
1113 |
} \u7266c\u7266c\u7266c
|
sl@0
|
1114 |
|
sl@0
|
1115 |
test string-14.1 {string replace} {
|
sl@0
|
1116 |
list [catch {string replace} msg] $msg
|
sl@0
|
1117 |
} {1 {wrong # args: should be "string replace string first last ?string?"}}
|
sl@0
|
1118 |
test string-14.2 {string replace} {
|
sl@0
|
1119 |
list [catch {string replace a 1} msg] $msg
|
sl@0
|
1120 |
} {1 {wrong # args: should be "string replace string first last ?string?"}}
|
sl@0
|
1121 |
test string-14.3 {string replace} {
|
sl@0
|
1122 |
list [catch {string replace a 1 2 3 4} msg] $msg
|
sl@0
|
1123 |
} {1 {wrong # args: should be "string replace string first last ?string?"}}
|
sl@0
|
1124 |
test string-14.4 {string replace} {
|
sl@0
|
1125 |
} {}
|
sl@0
|
1126 |
test string-14.5 {string replace} {
|
sl@0
|
1127 |
string replace abcdefghijklmnop 2 14
|
sl@0
|
1128 |
} {abp}
|
sl@0
|
1129 |
test string-14.6 {string replace} {
|
sl@0
|
1130 |
string replace abcdefghijklmnop 7 1000
|
sl@0
|
1131 |
} {abcdefg}
|
sl@0
|
1132 |
test string-14.7 {string replace} {
|
sl@0
|
1133 |
string replace abcdefghijklmnop 10 e
|
sl@0
|
1134 |
} {abcdefghij}
|
sl@0
|
1135 |
test string-14.8 {string replace} {
|
sl@0
|
1136 |
string replace abcdefghijklmnop 10 9
|
sl@0
|
1137 |
} {abcdefghijklmnop}
|
sl@0
|
1138 |
test string-14.9 {string replace} {
|
sl@0
|
1139 |
string replace abcdefghijklmnop -3 2
|
sl@0
|
1140 |
} {defghijklmnop}
|
sl@0
|
1141 |
test string-14.10 {string replace} {
|
sl@0
|
1142 |
string replace abcdefghijklmnop -3 -2
|
sl@0
|
1143 |
} {abcdefghijklmnop}
|
sl@0
|
1144 |
test string-14.11 {string replace} {
|
sl@0
|
1145 |
string replace abcdefghijklmnop 1000 1010
|
sl@0
|
1146 |
} {abcdefghijklmnop}
|
sl@0
|
1147 |
test string-14.12 {string replace} {
|
sl@0
|
1148 |
string replace abcdefghijklmnop -100 end
|
sl@0
|
1149 |
} {}
|
sl@0
|
1150 |
test string-14.13 {string replace} {
|
sl@0
|
1151 |
list [catch {string replace abc abc 1} msg] $msg
|
sl@0
|
1152 |
} {1 {bad index "abc": must be integer or end?-integer?}}
|
sl@0
|
1153 |
test string-14.14 {string replace} {
|
sl@0
|
1154 |
list [catch {string replace abc 1 eof} msg] $msg
|
sl@0
|
1155 |
} {1 {bad index "eof": must be integer or end?-integer?}}
|
sl@0
|
1156 |
test string-14.15 {string replace} {
|
sl@0
|
1157 |
string replace abcdefghijklmnop end-10 end-2 NEW
|
sl@0
|
1158 |
} {abcdeNEWop}
|
sl@0
|
1159 |
test string-14.16 {string replace} {
|
sl@0
|
1160 |
string replace abcdefghijklmnop 0 e foo
|
sl@0
|
1161 |
} {foo}
|
sl@0
|
1162 |
test string-14.17 {string replace} {
|
sl@0
|
1163 |
string replace abcdefghijklmnop end end-1
|
sl@0
|
1164 |
} {abcdefghijklmnop}
|
sl@0
|
1165 |
|
sl@0
|
1166 |
test string-15.1 {string tolower too few args} {
|
sl@0
|
1167 |
list [catch {string tolower} msg] $msg
|
sl@0
|
1168 |
} {1 {wrong # args: should be "string tolower string ?first? ?last?"}}
|
sl@0
|
1169 |
test string-15.2 {string tolower bad args} {
|
sl@0
|
1170 |
list [catch {string tolower a b} msg] $msg
|
sl@0
|
1171 |
} {1 {bad index "b": must be integer or end?-integer?}}
|
sl@0
|
1172 |
test string-15.3 {string tolower too many args} {
|
sl@0
|
1173 |
list [catch {string tolower ABC 1 end oops} msg] $msg
|
sl@0
|
1174 |
} {1 {wrong # args: should be "string tolower string ?first? ?last?"}}
|
sl@0
|
1175 |
test string-15.4 {string tolower} {
|
sl@0
|
1176 |
string tolower ABCDeF
|
sl@0
|
1177 |
} {abcdef}
|
sl@0
|
1178 |
test string-15.5 {string tolower} {
|
sl@0
|
1179 |
string tolower "ABC XyZ"
|
sl@0
|
1180 |
} {abc xyz}
|
sl@0
|
1181 |
test string-15.6 {string tolower} {
|
sl@0
|
1182 |
string tolower {123#$&*()}
|
sl@0
|
1183 |
} {123#$&*()}
|
sl@0
|
1184 |
test string-15.7 {string tolower} {
|
sl@0
|
1185 |
string tolower ABC 1
|
sl@0
|
1186 |
} AbC
|
sl@0
|
1187 |
test string-15.8 {string tolower} {
|
sl@0
|
1188 |
string tolower ABC 1 end
|
sl@0
|
1189 |
} Abc
|
sl@0
|
1190 |
test string-15.9 {string tolower} {
|
sl@0
|
1191 |
string tolower ABC 0 end-1
|
sl@0
|
1192 |
} abC
|
sl@0
|
1193 |
test string-15.10 {string tolower, unicode} {
|
sl@0
|
1194 |
string tolower ABCabc\xc7\xe7
|
sl@0
|
1195 |
} "abcabc\xe7\xe7"
|
sl@0
|
1196 |
|
sl@0
|
1197 |
test string-16.1 {string toupper} {
|
sl@0
|
1198 |
list [catch {string toupper} msg] $msg
|
sl@0
|
1199 |
} {1 {wrong # args: should be "string toupper string ?first? ?last?"}}
|
sl@0
|
1200 |
test string-16.2 {string toupper} {
|
sl@0
|
1201 |
list [catch {string toupper a b} msg] $msg
|
sl@0
|
1202 |
} {1 {bad index "b": must be integer or end?-integer?}}
|
sl@0
|
1203 |
test string-16.3 {string toupper} {
|
sl@0
|
1204 |
list [catch {string toupper a 1 end oops} msg] $msg
|
sl@0
|
1205 |
} {1 {wrong # args: should be "string toupper string ?first? ?last?"}}
|
sl@0
|
1206 |
test string-16.4 {string toupper} {
|
sl@0
|
1207 |
string toupper abCDEf
|
sl@0
|
1208 |
} {ABCDEF}
|
sl@0
|
1209 |
test string-16.5 {string toupper} {
|
sl@0
|
1210 |
string toupper "abc xYz"
|
sl@0
|
1211 |
} {ABC XYZ}
|
sl@0
|
1212 |
test string-16.6 {string toupper} {
|
sl@0
|
1213 |
string toupper {123#$&*()}
|
sl@0
|
1214 |
} {123#$&*()}
|
sl@0
|
1215 |
test string-16.7 {string toupper} {
|
sl@0
|
1216 |
string toupper abc 1
|
sl@0
|
1217 |
} aBc
|
sl@0
|
1218 |
test string-16.8 {string toupper} {
|
sl@0
|
1219 |
string toupper abc 1 end
|
sl@0
|
1220 |
} aBC
|
sl@0
|
1221 |
test string-16.9 {string toupper} {
|
sl@0
|
1222 |
string toupper abc 0 end-1
|
sl@0
|
1223 |
} ABc
|
sl@0
|
1224 |
test string-16.10 {string toupper, unicode} {
|
sl@0
|
1225 |
string toupper ABCabc\xc7\xe7
|
sl@0
|
1226 |
} "ABCABC\xc7\xc7"
|
sl@0
|
1227 |
|
sl@0
|
1228 |
test string-17.1 {string totitle} {
|
sl@0
|
1229 |
list [catch {string totitle} msg] $msg
|
sl@0
|
1230 |
} {1 {wrong # args: should be "string totitle string ?first? ?last?"}}
|
sl@0
|
1231 |
test string-17.2 {string totitle} {
|
sl@0
|
1232 |
list [catch {string totitle a b} msg] $msg
|
sl@0
|
1233 |
} {1 {bad index "b": must be integer or end?-integer?}}
|
sl@0
|
1234 |
test string-17.3 {string totitle} {
|
sl@0
|
1235 |
string totitle abCDEf
|
sl@0
|
1236 |
} {Abcdef}
|
sl@0
|
1237 |
test string-17.4 {string totitle} {
|
sl@0
|
1238 |
string totitle "abc xYz"
|
sl@0
|
1239 |
} {Abc xyz}
|
sl@0
|
1240 |
test string-17.5 {string totitle} {
|
sl@0
|
1241 |
string totitle {123#$&*()}
|
sl@0
|
1242 |
} {123#$&*()}
|
sl@0
|
1243 |
test string-17.6 {string totitle, unicode} {
|
sl@0
|
1244 |
string totitle ABCabc\xc7\xe7
|
sl@0
|
1245 |
} "Abcabc\xe7\xe7"
|
sl@0
|
1246 |
test string-17.7 {string totitle, unicode} {
|
sl@0
|
1247 |
string totitle \u01f3BCabc\xc7\xe7
|
sl@0
|
1248 |
} "\u01f2bcabc\xe7\xe7"
|
sl@0
|
1249 |
|
sl@0
|
1250 |
test string-18.1 {string trim} {
|
sl@0
|
1251 |
list [catch {string trim} msg] $msg
|
sl@0
|
1252 |
} {1 {wrong # args: should be "string trim string ?chars?"}}
|
sl@0
|
1253 |
test string-18.2 {string trim} {
|
sl@0
|
1254 |
list [catch {string trim a b c} msg] $msg
|
sl@0
|
1255 |
} {1 {wrong # args: should be "string trim string ?chars?"}}
|
sl@0
|
1256 |
test string-18.3 {string trim} {
|
sl@0
|
1257 |
string trim " XYZ "
|
sl@0
|
1258 |
} {XYZ}
|
sl@0
|
1259 |
test string-18.4 {string trim} {
|
sl@0
|
1260 |
string trim "\t\nXYZ\t\n\r\n"
|
sl@0
|
1261 |
} {XYZ}
|
sl@0
|
1262 |
test string-18.5 {string trim} {
|
sl@0
|
1263 |
string trim " A XYZ A "
|
sl@0
|
1264 |
} {A XYZ A}
|
sl@0
|
1265 |
test string-18.6 {string trim} {
|
sl@0
|
1266 |
string trim "XXYYZZABC XXYYZZ" ZYX
|
sl@0
|
1267 |
} {ABC }
|
sl@0
|
1268 |
test string-18.7 {string trim} {
|
sl@0
|
1269 |
string trim " \t\r "
|
sl@0
|
1270 |
} {}
|
sl@0
|
1271 |
test string-18.8 {string trim} {
|
sl@0
|
1272 |
string trim {abcdefg} {}
|
sl@0
|
1273 |
} {abcdefg}
|
sl@0
|
1274 |
test string-18.9 {string trim} {
|
sl@0
|
1275 |
string trim {}
|
sl@0
|
1276 |
} {}
|
sl@0
|
1277 |
test string-18.10 {string trim} {
|
sl@0
|
1278 |
string trim ABC DEF
|
sl@0
|
1279 |
} {ABC}
|
sl@0
|
1280 |
test string-18.11 {string trim, unicode} {
|
sl@0
|
1281 |
string trim "\xe7\xe8 AB\xe7C \xe8\xe7" \xe7\xe8
|
sl@0
|
1282 |
} " AB\xe7C "
|
sl@0
|
1283 |
|
sl@0
|
1284 |
test string-19.1 {string trimleft} {
|
sl@0
|
1285 |
list [catch {string trimleft} msg] $msg
|
sl@0
|
1286 |
} {1 {wrong # args: should be "string trimleft string ?chars?"}}
|
sl@0
|
1287 |
test string-19.2 {string trimleft} {
|
sl@0
|
1288 |
string trimleft " XYZ "
|
sl@0
|
1289 |
} {XYZ }
|
sl@0
|
1290 |
|
sl@0
|
1291 |
test string-20.1 {string trimright errors} {
|
sl@0
|
1292 |
list [catch {string trimright} msg] $msg
|
sl@0
|
1293 |
} {1 {wrong # args: should be "string trimright string ?chars?"}}
|
sl@0
|
1294 |
test string-20.2 {string trimright errors} {
|
sl@0
|
1295 |
list [catch {string trimg a} msg] $msg
|
sl@0
|
1296 |
} {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}}
|
sl@0
|
1297 |
test string-20.3 {string trimright} {
|
sl@0
|
1298 |
string trimright " XYZ "
|
sl@0
|
1299 |
} { XYZ}
|
sl@0
|
1300 |
test string-20.4 {string trimright} {
|
sl@0
|
1301 |
string trimright " "
|
sl@0
|
1302 |
} {}
|
sl@0
|
1303 |
test string-20.5 {string trimright} {
|
sl@0
|
1304 |
string trimright ""
|
sl@0
|
1305 |
} {}
|
sl@0
|
1306 |
|
sl@0
|
1307 |
test string-21.1 {string wordend} {
|
sl@0
|
1308 |
list [catch {string wordend a} msg] $msg
|
sl@0
|
1309 |
} {1 {wrong # args: should be "string wordend string index"}}
|
sl@0
|
1310 |
test string-21.2 {string wordend} {
|
sl@0
|
1311 |
list [catch {string wordend a b c} msg] $msg
|
sl@0
|
1312 |
} {1 {wrong # args: should be "string wordend string index"}}
|
sl@0
|
1313 |
test string-21.3 {string wordend} {
|
sl@0
|
1314 |
list [catch {string wordend a gorp} msg] $msg
|
sl@0
|
1315 |
} {1 {bad index "gorp": must be integer or end?-integer?}}
|
sl@0
|
1316 |
test string-21.4 {string wordend} {
|
sl@0
|
1317 |
string wordend abc. -1
|
sl@0
|
1318 |
} 3
|
sl@0
|
1319 |
test string-21.5 {string wordend} {
|
sl@0
|
1320 |
string wordend abc. 100
|
sl@0
|
1321 |
} 4
|
sl@0
|
1322 |
test string-21.6 {string wordend} {
|
sl@0
|
1323 |
string wordend "word_one two three" 2
|
sl@0
|
1324 |
} 8
|
sl@0
|
1325 |
test string-21.7 {string wordend} {
|
sl@0
|
1326 |
string wordend "one .&# three" 5
|
sl@0
|
1327 |
} 6
|
sl@0
|
1328 |
test string-21.8 {string wordend} {
|
sl@0
|
1329 |
string worde "x.y" 0
|
sl@0
|
1330 |
} 1
|
sl@0
|
1331 |
test string-21.9 {string wordend} {
|
sl@0
|
1332 |
string worde "x.y" end-1
|
sl@0
|
1333 |
} 2
|
sl@0
|
1334 |
test string-21.10 {string wordend, unicode} {
|
sl@0
|
1335 |
string wordend "xyz\u00c7de fg" 0
|
sl@0
|
1336 |
} 6
|
sl@0
|
1337 |
test string-21.11 {string wordend, unicode} {
|
sl@0
|
1338 |
string wordend "xyz\uc700de fg" 0
|
sl@0
|
1339 |
} 6
|
sl@0
|
1340 |
test string-21.12 {string wordend, unicode} {
|
sl@0
|
1341 |
string wordend "xyz\u203fde fg" 0
|
sl@0
|
1342 |
} 6
|
sl@0
|
1343 |
test string-21.13 {string wordend, unicode} {
|
sl@0
|
1344 |
string wordend "xyz\u2045de fg" 0
|
sl@0
|
1345 |
} 3
|
sl@0
|
1346 |
test string-21.14 {string wordend, unicode} {
|
sl@0
|
1347 |
string wordend "\uc700\uc700 abc" 8
|
sl@0
|
1348 |
} 6
|
sl@0
|
1349 |
|
sl@0
|
1350 |
test string-22.1 {string wordstart} {
|
sl@0
|
1351 |
list [catch {string word a} msg] $msg
|
sl@0
|
1352 |
} {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}}
|
sl@0
|
1353 |
test string-22.2 {string wordstart} {
|
sl@0
|
1354 |
list [catch {string wordstart a} msg] $msg
|
sl@0
|
1355 |
} {1 {wrong # args: should be "string wordstart string index"}}
|
sl@0
|
1356 |
test string-22.3 {string wordstart} {
|
sl@0
|
1357 |
list [catch {string wordstart a b c} msg] $msg
|
sl@0
|
1358 |
} {1 {wrong # args: should be "string wordstart string index"}}
|
sl@0
|
1359 |
test string-22.4 {string wordstart} {
|
sl@0
|
1360 |
list [catch {string wordstart a gorp} msg] $msg
|
sl@0
|
1361 |
} {1 {bad index "gorp": must be integer or end?-integer?}}
|
sl@0
|
1362 |
test string-22.5 {string wordstart} {
|
sl@0
|
1363 |
string wordstart "one two three_words" 400
|
sl@0
|
1364 |
} 8
|
sl@0
|
1365 |
test string-22.6 {string wordstart} {
|
sl@0
|
1366 |
string wordstart "one two three_words" 2
|
sl@0
|
1367 |
} 0
|
sl@0
|
1368 |
test string-22.7 {string wordstart} {
|
sl@0
|
1369 |
string wordstart "one two three_words" -2
|
sl@0
|
1370 |
} 0
|
sl@0
|
1371 |
test string-22.8 {string wordstart} {
|
sl@0
|
1372 |
string wordstart "one .*&^ three" 6
|
sl@0
|
1373 |
} 6
|
sl@0
|
1374 |
test string-22.9 {string wordstart} {
|
sl@0
|
1375 |
string wordstart "one two three" 4
|
sl@0
|
1376 |
} 4
|
sl@0
|
1377 |
test string-22.10 {string wordstart} {
|
sl@0
|
1378 |
string wordstart "one two three" end-5
|
sl@0
|
1379 |
} 7
|
sl@0
|
1380 |
test string-22.11 {string wordstart, unicode} {
|
sl@0
|
1381 |
string wordstart "one tw\u00c7o three" 7
|
sl@0
|
1382 |
} 4
|
sl@0
|
1383 |
test string-22.12 {string wordstart, unicode} {
|
sl@0
|
1384 |
string wordstart "ab\uc700\uc700 cdef ghi" 12
|
sl@0
|
1385 |
} 10
|
sl@0
|
1386 |
test string-22.13 {string wordstart, unicode} {
|
sl@0
|
1387 |
string wordstart "\uc700\uc700 abc" 8
|
sl@0
|
1388 |
} 3
|
sl@0
|
1389 |
|
sl@0
|
1390 |
test string-23.0 {string is boolean, Bug 1187123} testindexobj {
|
sl@0
|
1391 |
set x 5
|
sl@0
|
1392 |
catch {testindexobj $x foo bar soom}
|
sl@0
|
1393 |
string is boolean $x
|
sl@0
|
1394 |
} 0
|
sl@0
|
1395 |
|
sl@0
|
1396 |
|
sl@0
|
1397 |
# cleanup
|
sl@0
|
1398 |
::tcltest::cleanupTests
|
sl@0
|
1399 |
return
|