1 |
578 |
markom |
# The tests in this file cover the procedures in tclCmdMZ.c.
|
2 |
|
|
#
|
3 |
|
|
# This file contains a collection of tests for one or more of the Tcl
|
4 |
|
|
# built-in commands. Sourcing this file into Tcl runs the tests and
|
5 |
|
|
# generates output for errors. No output means no errors were found.
|
6 |
|
|
#
|
7 |
|
|
# Copyright (c) 1991-1993 The Regents of the University of California.
|
8 |
|
|
# Copyright (c) 1994 Sun Microsystems, Inc.
|
9 |
|
|
#
|
10 |
|
|
# See the file "license.terms" for information on usage and redistribution
|
11 |
|
|
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
12 |
|
|
#
|
13 |
|
|
# SCCS: @(#) cmdMZ.test 1.20 98/01/08 18:23:43
|
14 |
|
|
|
15 |
|
|
if {[string compare test [info procs test]] == 1} then {source defs}
|
16 |
|
|
|
17 |
|
|
# Tcl_PwdObjCmd
|
18 |
|
|
|
19 |
|
|
test cmdMZ-1.1 {Tcl_PwdObjCmd} {
|
20 |
|
|
list [catch {pwd a} msg] $msg
|
21 |
|
|
} {1 {wrong # args: should be "pwd"}}
|
22 |
|
|
test cmdMZ-1.2 {Tcl_PwdObjCmd: simple pwd} {
|
23 |
|
|
catch pwd
|
24 |
|
|
} 0
|
25 |
|
|
test cmdMZ-1.3 {Tcl_PwdObjCmd: simple pwd} {
|
26 |
|
|
expr [string length pwd]>0
|
27 |
|
|
} 1
|
28 |
|
|
test cmdMZ-1.4 {Tcl_PwdObjCmd: failure} {unixOnly} {
|
29 |
|
|
file delete -force foo
|
30 |
|
|
file mkdir foo
|
31 |
|
|
set cwd [pwd]
|
32 |
|
|
cd foo
|
33 |
|
|
file attr . -permissions 000
|
34 |
|
|
set result [list [catch {pwd} msg] $msg]
|
35 |
|
|
cd $cwd
|
36 |
|
|
file delete -force foo
|
37 |
|
|
set result
|
38 |
|
|
} {1 {error getting working directory name: permission denied}}
|
39 |
|
|
|
40 |
|
|
# The tests for Tcl_RegexpObjCmd, Tcl_RegsubObjCmd are in regexp.test
|
41 |
|
|
|
42 |
|
|
# Tcl_RenameObjCmd
|
43 |
|
|
|
44 |
|
|
test cmdMZ-2.1 {Tcl_RenameObjCmd: error conditions} {
|
45 |
|
|
list [catch {rename r1} msg] $msg $errorCode
|
46 |
|
|
} {1 {wrong # args: should be "rename oldName newName"} NONE}
|
47 |
|
|
test cmdMZ-2.2 {Tcl_RenameObjCmd: error conditions} {
|
48 |
|
|
list [catch {rename r1 r2 r3} msg] $msg $errorCode
|
49 |
|
|
} {1 {wrong # args: should be "rename oldName newName"} NONE}
|
50 |
|
|
test cmdMZ-2.3 {Tcl_RenameObjCmd: success} {
|
51 |
|
|
catch {rename r2 {}}
|
52 |
|
|
proc r1 {} {return "r1"}
|
53 |
|
|
rename r1 r2
|
54 |
|
|
r2
|
55 |
|
|
} {r1}
|
56 |
|
|
test cmdMZ-2.4 {Tcl_RenameObjCmd: success} {
|
57 |
|
|
proc r1 {} {return "r1"}
|
58 |
|
|
rename r1 {}
|
59 |
|
|
list [catch {r1} msg] $msg
|
60 |
|
|
} {1 {invalid command name "r1"}}
|
61 |
|
|
|
62 |
|
|
# The tests for Tcl_ReturnObjCmd are in proc-old.test
|
63 |
|
|
# The tests for Tcl_ScanObjCmd are in scan.test
|
64 |
|
|
|
65 |
|
|
# Tcl_SourceObjCmd
|
66 |
|
|
|
67 |
|
|
test cmdMZ-3.1 {Tcl_SourceObjCmd: error conditions} {macOnly} {
|
68 |
|
|
list [catch {source} msg] $msg
|
69 |
|
|
} {1 {wrong # args: should be "source fileName" or "source -rsrc name ?fileName?" or "source -rsrcid id ?fileName?"}}
|
70 |
|
|
test cmdMZ-3.2 {Tcl_SourceObjCmd: error conditions} {macOnly} {
|
71 |
|
|
list [catch {source a b} msg] $msg
|
72 |
|
|
} {1 {wrong # args: should be "source fileName" or "source -rsrc name ?fileName?" or "source -rsrcid id ?fileName?"}}
|
73 |
|
|
test cmdMZ-3.3 {Tcl_SourceObjCmd: error conditions} {unixOrPc} {
|
74 |
|
|
list [catch {source} msg] $msg
|
75 |
|
|
} {1 {wrong # args: should be "source fileName"}}
|
76 |
|
|
test cmdMZ-3.4 {Tcl_SourceObjCmd: error conditions} {unixOrPc} {
|
77 |
|
|
list [catch {source a b} msg] $msg
|
78 |
|
|
} {1 {wrong # args: should be "source fileName"}}
|
79 |
|
|
test cmdMZ-3.5 {Tcl_SourceObjCmd: error in script} {
|
80 |
|
|
makeFile {
|
81 |
|
|
set x 146
|
82 |
|
|
error "error in sourced file"
|
83 |
|
|
set y $x
|
84 |
|
|
} source.file
|
85 |
|
|
list [catch {source source.file} msg] $msg $errorInfo
|
86 |
|
|
} {1 {error in sourced file} {error in sourced file
|
87 |
|
|
while executing
|
88 |
|
|
"error "error in sourced file""
|
89 |
|
|
(file "source.file" line 3)
|
90 |
|
|
invoked from within
|
91 |
|
|
"source source.file"}}
|
92 |
|
|
test cmdMZ-3.6 {Tcl_SourceObjCmd: simple script} {
|
93 |
|
|
makeFile {list result} source.file
|
94 |
|
|
source source.file
|
95 |
|
|
} result
|
96 |
|
|
|
97 |
|
|
# Tcl_SplitObjCmd
|
98 |
|
|
|
99 |
|
|
test cmdMZ-4.1 {Tcl_SplitObjCmd: split errors} {
|
100 |
|
|
list [catch split msg] $msg $errorCode
|
101 |
|
|
} {1 {wrong # args: should be "split string ?splitChars?"} NONE}
|
102 |
|
|
test cmdMZ-4.2 {Tcl_SplitObjCmd: split errors} {
|
103 |
|
|
list [catch {split a b c} msg] $msg $errorCode
|
104 |
|
|
} {1 {wrong # args: should be "split string ?splitChars?"} NONE}
|
105 |
|
|
test cmdMZ-4.3 {Tcl_SplitObjCmd: basic split commands} {
|
106 |
|
|
split "a\n b\t\r c\n "
|
107 |
|
|
} {a {} b {} {} c {} {}}
|
108 |
|
|
test cmdMZ-4.4 {Tcl_SplitObjCmd: basic split commands} {
|
109 |
|
|
split "word 1xyzword 2zword 3" xyz
|
110 |
|
|
} {{word 1} {} {} {word 2} {word 3}}
|
111 |
|
|
test cmdMZ-4.5 {Tcl_SplitObjCmd: basic split commands} {
|
112 |
|
|
split "12345" {}
|
113 |
|
|
} {1 2 3 4 5}
|
114 |
|
|
test cmdMZ-4.6 {Tcl_SplitObjCmd: basic split commands} {
|
115 |
|
|
split "a\}b\[c\{\]\$"
|
116 |
|
|
} "a\\}b\\\[c\\{\\\]\\\$"
|
117 |
|
|
test cmdMZ-4.7 {Tcl_SplitObjCmd: basic split commands} {
|
118 |
|
|
split {} {}
|
119 |
|
|
} {}
|
120 |
|
|
test cmdMZ-4.8 {Tcl_SplitObjCmd: basic split commands} {
|
121 |
|
|
split {}
|
122 |
|
|
} {}
|
123 |
|
|
test cmdMZ-4.9 {Tcl_SplitObjCmd: basic split commands} {
|
124 |
|
|
split { }
|
125 |
|
|
} {{} {} {} {}}
|
126 |
|
|
test cmdMZ-4.10 {Tcl_SplitObjCmd: basic split commands} {
|
127 |
|
|
proc foo {} {
|
128 |
|
|
set x {}
|
129 |
|
|
foreach f [split {]\n} {}] {
|
130 |
|
|
append x $f
|
131 |
|
|
}
|
132 |
|
|
return $x
|
133 |
|
|
}
|
134 |
|
|
foo
|
135 |
|
|
} {]\n}
|
136 |
|
|
test cmdMZ-4.11 {Tcl_SplitObjCmd: basic split commands} {
|
137 |
|
|
proc foo {} {
|
138 |
|
|
set x ab\000c
|
139 |
|
|
set y [split $x {}]
|
140 |
|
|
return $y
|
141 |
|
|
}
|
142 |
|
|
foo
|
143 |
|
|
} "a b \000 c"
|
144 |
|
|
test cmdMZ-4.12 {Tcl_SplitObjCmd: basic split commands} {
|
145 |
|
|
split "a0ab1b2bbb3\000c4" ab\000c
|
146 |
|
|
} {{} 0 {} 1 2 {} {} 3 {} 4}
|
147 |
|
|
test cmdMZ-4.13 {Tcl_SplitObjCmd: basic split commands} {
|
148 |
|
|
# if not UTF-8 aware, result is "a {} {} b qw\xe5 {} N wq"
|
149 |
|
|
split "a\u4e4eb qw\u5e4e\x4e wq" " \u4e4e"
|
150 |
|
|
} "a b qw\u5e4eN wq"
|
151 |
|
|
|
152 |
|
|
# Tcl_StringObjCmd
|
153 |
|
|
|
154 |
|
|
test cmdMZ-5.1 {Tcl_StringObjCmd: error conditions} {
|
155 |
|
|
list [catch {string} msg] $msg
|
156 |
|
|
} {1 {wrong # args: should be "string option arg ?arg ...?"}}
|
157 |
|
|
test cmdMZ-5.2 {Tcl_StringObjCmd: error conditions} {
|
158 |
|
|
list [catch {string gorp a b} msg] $msg
|
159 |
|
|
} {1 {bad option "gorp": must be compare, first, index, last, length, match, range, tolower, toupper, trim, trimleft, trimright, wordend, or wordstart}}
|
160 |
|
|
|
161 |
|
|
test cmdMZ-6.1 {Tcl_StringObjCmd: string compare} {
|
162 |
|
|
list [catch {string compare a} msg] $msg
|
163 |
|
|
} {1 {wrong # args: should be "string compare string1 string2"}}
|
164 |
|
|
test cmdMZ-6.2 {Tcl_StringObjCmd: string compare} {
|
165 |
|
|
list [catch {string compare a b c} msg] $msg
|
166 |
|
|
} {1 {wrong # args: should be "string compare string1 string2"}}
|
167 |
|
|
test cmdMZ-6.3 {Tcl_StringObjCmd: string compare} {
|
168 |
|
|
string compare abcde abdef
|
169 |
|
|
} -1
|
170 |
|
|
test cmdMZ-6.4 {Tcl_StringObjCmd: string compare} {
|
171 |
|
|
string c abcde ABCDE
|
172 |
|
|
} 1
|
173 |
|
|
test cmdMZ-6.5 {Tcl_StringObjCmd: string compare} {
|
174 |
|
|
string compare abcde abcde
|
175 |
|
|
} 0
|
176 |
|
|
test cmdMZ-6.6 {Tcl_StringObjCmd: string compare} {
|
177 |
|
|
string compare ab abcde
|
178 |
|
|
} -1
|
179 |
|
|
test cmdMZ-6.7 {Tcl_StringObjCmd: string compare} {
|
180 |
|
|
string compare abcde ab
|
181 |
|
|
} 1
|
182 |
|
|
test cmdMZ-6.8 {Tcl_StringObjCmd: string compare} {
|
183 |
|
|
string compare cde ab
|
184 |
|
|
} 1
|
185 |
|
|
test cmdMZ-6.9 {Tcl_StringObjCmd: string compare} {
|
186 |
|
|
string compare ab cde
|
187 |
|
|
} -1
|
188 |
|
|
test cmdMZ-6.10 {Tcl_StringObjCmd: string compare, unicode} {
|
189 |
|
|
string compare ab\u7266 ab\u7267
|
190 |
|
|
} -1
|
191 |
|
|
test cmdMZ-6.11 {Tcl_StringObjCmd: string compare, high bit} {
|
192 |
|
|
# This test will fail if the underlying comparaison
|
193 |
|
|
# is using signed chars instead of unsigned chars.
|
194 |
|
|
# (like SunOS's default memcmp thus the compat/memcmp.c)
|
195 |
|
|
string compare "\x80" "@"
|
196 |
|
|
# Nb this tests works also in utf8 space because \x80 is
|
197 |
|
|
# translated into a 2 or more bytes but whose first byte has
|
198 |
|
|
# the high bit set.
|
199 |
|
|
} 1
|
200 |
|
|
|
201 |
|
|
test cmdMZ-7.1 {Tcl_StringObjCmd: string first} {
|
202 |
|
|
list [catch {string first a} msg] $msg
|
203 |
|
|
} {1 {wrong # args: should be "string first string1 string2"}}
|
204 |
|
|
test cmdMZ-7.2 {Tcl_StringObjCmd: string first} {
|
205 |
|
|
list [catch {string first a b c} msg] $msg
|
206 |
|
|
} {1 {wrong # args: should be "string first string1 string2"}}
|
207 |
|
|
test cmdMZ-7.3 {Tcl_StringObjCmd: string first} {
|
208 |
|
|
string first bq abcdefgbcefgbqrs
|
209 |
|
|
} 12
|
210 |
|
|
test cmdMZ-7.4 {Tcl_StringObjCmd: string first} {
|
211 |
|
|
string fir bcd abcdefgbcefgbqrs
|
212 |
|
|
} 1
|
213 |
|
|
test cmdMZ-7.5 {Tcl_StringObjCmd: string first} {
|
214 |
|
|
string f b abcdefgbcefgbqrs
|
215 |
|
|
} 1
|
216 |
|
|
test cmdMZ-7.6 {Tcl_StringObjCmd: string first} {
|
217 |
|
|
string first xxx x123xx345xxx789xxx012
|
218 |
|
|
} 9
|
219 |
|
|
test cmdMZ-7.7 {Tcl_StringObjCmd: string first} {
|
220 |
|
|
string first "" x123xx345xxx789xxx012
|
221 |
|
|
} -1
|
222 |
|
|
test cmdMZ-7.8 {Tcl_StringObjCmd: string first, unicode} {
|
223 |
|
|
string first x abc\u7266x
|
224 |
|
|
} 4
|
225 |
|
|
test cmdMZ-7.9 {Tcl_StringObjCmd: string first, unicode} {
|
226 |
|
|
string first \u7266 abc\u7266x
|
227 |
|
|
} 3
|
228 |
|
|
|
229 |
|
|
test cmdMZ-8.1 {Tcl_StringObjCmd: string index} {
|
230 |
|
|
list [catch {string index} msg] $msg
|
231 |
|
|
} {1 {wrong # args: should be "string index string charIndex"}}
|
232 |
|
|
test cmdMZ-8.2 {Tcl_StringObjCmd: string index} {
|
233 |
|
|
list [catch {string index a b c} msg] $msg
|
234 |
|
|
} {1 {wrong # args: should be "string index string charIndex"}}
|
235 |
|
|
test cmdMZ-8.3 {Tcl_StringObjCmd: string index} {
|
236 |
|
|
list [catch {string index a xyz} msg] $msg
|
237 |
|
|
} {1 {expected integer but got "xyz"}}
|
238 |
|
|
test cmdMZ-8.4 {Tcl_StringObjCmd: string index} {
|
239 |
|
|
string index abcde 0
|
240 |
|
|
} a
|
241 |
|
|
test cmdMZ-8.5 {Tcl_StringObjCmd: string index} {
|
242 |
|
|
string i abcde 4
|
243 |
|
|
} e
|
244 |
|
|
test cmdMZ-8.6 {Tcl_StringObjCmd: string index} {
|
245 |
|
|
string index abcde 5
|
246 |
|
|
} {}
|
247 |
|
|
test cmdMZ-8.7 {Tcl_StringObjCmd: string index} {
|
248 |
|
|
list [catch {string index abcde -10} msg] $msg
|
249 |
|
|
} {0 {}}
|
250 |
|
|
test cmdMZ-8.8 {Tcl_StringObjCmd: string index, unicode} {
|
251 |
|
|
string index abc\u7266d 4
|
252 |
|
|
} d
|
253 |
|
|
test cmdMZ-8.9 {Tcl_StringObjCmd: string index, unicode} {
|
254 |
|
|
string index abc\u7266d 3
|
255 |
|
|
} \u7266
|
256 |
|
|
|
257 |
|
|
test cmdMZ-9.1 {Tcl_StringObjCmd: string last} {
|
258 |
|
|
list [catch {string last a} msg] $msg
|
259 |
|
|
} {1 {wrong # args: should be "string last string1 string2"}}
|
260 |
|
|
test cmdMZ-9.2 {Tcl_StringObjCmd: string last} {
|
261 |
|
|
list [catch {string last a b c} msg] $msg
|
262 |
|
|
} {1 {wrong # args: should be "string last string1 string2"}}
|
263 |
|
|
test cmdMZ-9.3 {Tcl_StringObjCmd: string last} {
|
264 |
|
|
string la xxx xxxx123xx345x678
|
265 |
|
|
} 1
|
266 |
|
|
test cmdMZ-9.4 {Tcl_StringObjCmd: string last} {
|
267 |
|
|
string last xx xxxx123xx345x678
|
268 |
|
|
} 7
|
269 |
|
|
test cmdMZ-9.5 {Tcl_StringObjCmd: string last} {
|
270 |
|
|
string las x xxxx123xx345x678
|
271 |
|
|
} 12
|
272 |
|
|
test cmdMZ-9.6 {Tcl_StringObjCmd: string last, unicode} {
|
273 |
|
|
string las x xxxx12\u7266xx345x678
|
274 |
|
|
} 12
|
275 |
|
|
test cmdMZ-9.7 {Tcl_StringObjCmd: string last, unicode} {
|
276 |
|
|
string las \u7266 xxxx12\u7266xx345x678
|
277 |
|
|
} 6
|
278 |
|
|
|
279 |
|
|
test cmdMZ-10.1 {Tcl_StringObjCmd: string length} {
|
280 |
|
|
list [catch {string length} msg] $msg
|
281 |
|
|
} {1 {wrong # args: should be "string length string"}}
|
282 |
|
|
test cmdMZ-10.2 {Tcl_StringObjCmd: string length} {
|
283 |
|
|
list [catch {string length a b} msg] $msg
|
284 |
|
|
} {1 {wrong # args: should be "string length string"}}
|
285 |
|
|
test cmdMZ-10.3 {Tcl_StringObjCmd: string length} {
|
286 |
|
|
string length "a little string"
|
287 |
|
|
} 15
|
288 |
|
|
test cmdMZ-10.4 {Tcl_StringObjCmd: string length} {
|
289 |
|
|
string le ""
|
290 |
|
|
} 0
|
291 |
|
|
test cmdMZ-10.5 {Tcl_StringObjCmd: string length, unicode} {
|
292 |
|
|
string le "abcd\u7266"
|
293 |
|
|
} 5
|
294 |
|
|
|
295 |
|
|
test cmdMZ-11.1 {Tcl_StringObjCmd: string match} {
|
296 |
|
|
list [catch {string match a} msg] $msg
|
297 |
|
|
} {1 {wrong # args: should be "string match pattern string"}}
|
298 |
|
|
test cmdMZ-11.2 {Tcl_StringObjCmd: string match} {
|
299 |
|
|
list [catch {string match a b c} msg] $msg
|
300 |
|
|
} {1 {wrong # args: should be "string match pattern string"}}
|
301 |
|
|
test cmdMZ-11.3 {Tcl_StringObjCmd: string match} {
|
302 |
|
|
string match abc abc
|
303 |
|
|
} 1
|
304 |
|
|
test cmdMZ-11.4 {Tcl_StringObjCmd: string match} {
|
305 |
|
|
string m abc abd
|
306 |
|
|
} 0
|
307 |
|
|
|
308 |
|
|
test cmdMZ-12.1 {Tcl_StringObjCmd: string range} {
|
309 |
|
|
list [catch {string range} msg] $msg
|
310 |
|
|
} {1 {wrong # args: should be "string range string first last"}}
|
311 |
|
|
test cmdMZ-12.2 {Tcl_StringObjCmd: string range} {
|
312 |
|
|
list [catch {string range a 1} msg] $msg
|
313 |
|
|
} {1 {wrong # args: should be "string range string first last"}}
|
314 |
|
|
test cmdMZ-12.3 {Tcl_StringObjCmd: string range} {
|
315 |
|
|
list [catch {string range a 1 2 3} msg] $msg
|
316 |
|
|
} {1 {wrong # args: should be "string range string first last"}}
|
317 |
|
|
test cmdMZ-12.4 {Tcl_StringObjCmd: string range} {
|
318 |
|
|
list [catch {string range abc abc 1} msg] $msg
|
319 |
|
|
} {1 {bad index "abc": must be integer or "end"}}
|
320 |
|
|
test cmdMZ-12.5 {Tcl_StringObjCmd: string range} {
|
321 |
|
|
list [catch {string range abc 1 eof} msg] $msg
|
322 |
|
|
} {1 {bad index "eof": must be integer or "end"}}
|
323 |
|
|
test cmdMZ-12.6 {Tcl_StringObjCmd: string range, first < 0} {
|
324 |
|
|
string range abcdefghijklmnop -3 2
|
325 |
|
|
} {abc}
|
326 |
|
|
test cmdMZ-12.7 {Tcl_StringObjCmd: string range} {
|
327 |
|
|
string range abcdefghijklmnop 2 14
|
328 |
|
|
} {cdefghijklmno}
|
329 |
|
|
test cmdMZ-12.8 {Tcl_StringObjCmd: string range, last > length} {
|
330 |
|
|
string range abcdefghijklmnop 7 1000
|
331 |
|
|
} {hijklmnop}
|
332 |
|
|
test cmdMZ-12.9 {Tcl_StringObjCmd: string range} {
|
333 |
|
|
string range abcdefghijklmnop 10 e
|
334 |
|
|
} {klmnop}
|
335 |
|
|
test cmdMZ-12.10 {Tcl_StringObjCmd: string range, last < first} {
|
336 |
|
|
string range abcdefghijklmnop 10 9
|
337 |
|
|
} {}
|
338 |
|
|
test cmdMZ-12.11 {Tcl_StringObjCmd: string range} {
|
339 |
|
|
string range abcdefghijklmnop -3 -2
|
340 |
|
|
} {}
|
341 |
|
|
test cmdMZ-12.12 {Tcl_StringObjCmd: string range} {
|
342 |
|
|
string range abcdefghijklmnop 1000 1010
|
343 |
|
|
} {}
|
344 |
|
|
test cmdMZ-12.13 {Tcl_StringObjCmd: string range} {
|
345 |
|
|
string range abcdefghijklmnop -100 end
|
346 |
|
|
} {abcdefghijklmnop}
|
347 |
|
|
test cmdMZ-12.14 {Tcl_StringObjCmd: string range} {
|
348 |
|
|
string range abcdefghijklmnop end end
|
349 |
|
|
} {p}
|
350 |
|
|
test cmdMZ-12.15 {Tcl_StringObjCmd: string range} {
|
351 |
|
|
string range abcdefghijklmnop e 1000
|
352 |
|
|
} {p}
|
353 |
|
|
test cmdMZ-12.16 {Tcl_StringObjCmd: string range, unicode} {
|
354 |
|
|
string range ab\u7266cdefghijklmnop 5 5
|
355 |
|
|
} e
|
356 |
|
|
test cmdMZ-12.17 {Tcl_StringObjCmd: string range, unicode} {
|
357 |
|
|
string range ab\u7266cdefghijklmnop 2 3
|
358 |
|
|
} \u7266c
|
359 |
|
|
|
360 |
|
|
test cmdMZ-13.1 {Tcl_StringObjCmd: string tolower} {
|
361 |
|
|
list [catch {string tolower} msg] $msg
|
362 |
|
|
} {1 {wrong # args: should be "string tolower string"}}
|
363 |
|
|
test cmdMZ-13.2 {Tcl_StringObjCmd: string tolower} {
|
364 |
|
|
list [catch {string tolower a b} msg] $msg
|
365 |
|
|
} {1 {wrong # args: should be "string tolower string"}}
|
366 |
|
|
test cmdMZ-13.3 {Tcl_StringObjCmd: string tolower} {
|
367 |
|
|
string tolower ABCDeF
|
368 |
|
|
} {abcdef}
|
369 |
|
|
test cmdMZ-13.4 {Tcl_StringObjCmd: string tolower} {
|
370 |
|
|
string tolower "ABC XyZ"
|
371 |
|
|
} {abc xyz}
|
372 |
|
|
test cmdMZ-13.5 {Tcl_StringObjCmd: string tolower} {
|
373 |
|
|
string tolower {123#$&*()}
|
374 |
|
|
} {123#$&*()}
|
375 |
|
|
test cmdMZ-13.6 {Tcl_StringObjCmd: string tolower, unicode} {hasIsoLocale} {
|
376 |
|
|
set_iso8859_1_locale
|
377 |
|
|
set result [string tolower ABCabc\xc7\xe7]
|
378 |
|
|
restore_locale
|
379 |
|
|
set result
|
380 |
|
|
} "abcabc\xe7\xe7"
|
381 |
|
|
|
382 |
|
|
test cmdMZ-14.1 {Tcl_StringObjCmd: string toupper} {
|
383 |
|
|
list [catch {string toupper} msg] $msg
|
384 |
|
|
} {1 {wrong # args: should be "string toupper string"}}
|
385 |
|
|
test cmdMZ-14.2 {Tcl_StringObjCmd: string toupper} {
|
386 |
|
|
list [catch {string toupper a b} msg] $msg
|
387 |
|
|
} {1 {wrong # args: should be "string toupper string"}}
|
388 |
|
|
test cmdMZ-14.3 {Tcl_StringObjCmd: string toupper} {
|
389 |
|
|
string toupper abCDEf
|
390 |
|
|
} {ABCDEF}
|
391 |
|
|
test cmdMZ-14.4 {Tcl_StringObjCmd: string toupper} {
|
392 |
|
|
string toupper "abc xYz"
|
393 |
|
|
} {ABC XYZ}
|
394 |
|
|
test cmdMZ-14.5 {Tcl_StringObjCmd: string toupper} {
|
395 |
|
|
string toupper {123#$&*()}
|
396 |
|
|
} {123#$&*()}
|
397 |
|
|
test cmdMZ-14.6 {Tcl_StringObjCmd: string toupper, unicode} {hasIsoLocale} {
|
398 |
|
|
set_iso8859_1_locale
|
399 |
|
|
set result [string toupper ABCabc\xc7\xe7]
|
400 |
|
|
restore_locale
|
401 |
|
|
set result
|
402 |
|
|
} "ABCABC\xc7\xc7"
|
403 |
|
|
|
404 |
|
|
test cmdMZ-15.1 {Tcl_StringObjCmd: string trim} {
|
405 |
|
|
list [catch {string trim} msg] $msg
|
406 |
|
|
} {1 {wrong # args: should be "string trim string ?chars?"}}
|
407 |
|
|
test cmdMZ-15.2 {Tcl_StringObjCmd: string trim} {
|
408 |
|
|
list [catch {string trim a b c} msg] $msg
|
409 |
|
|
} {1 {wrong # args: should be "string trim string ?chars?"}}
|
410 |
|
|
test cmdMZ-15.3 {Tcl_StringObjCmd: string trim} {
|
411 |
|
|
string trim " XYZ "
|
412 |
|
|
} {XYZ}
|
413 |
|
|
test cmdMZ-15.4 {Tcl_StringObjCmd: string trim} {
|
414 |
|
|
string trim "\t\nXYZ\t\n\r\n"
|
415 |
|
|
} {XYZ}
|
416 |
|
|
test cmdMZ-15.5 {Tcl_StringObjCmd: string trim} {
|
417 |
|
|
string trim " A XYZ A "
|
418 |
|
|
} {A XYZ A}
|
419 |
|
|
test cmdMZ-15.6 {Tcl_StringObjCmd: string trim} {
|
420 |
|
|
string trim "XXYYZZABC XXYYZZ" ZYX
|
421 |
|
|
} {ABC }
|
422 |
|
|
test cmdMZ-15.7 {Tcl_StringObjCmd: string trim} {
|
423 |
|
|
string trim " \t\r "
|
424 |
|
|
} {}
|
425 |
|
|
test cmdMZ-15.8 {Tcl_StringObjCmd: string trim} {
|
426 |
|
|
string trim {abcdefg} {}
|
427 |
|
|
} {abcdefg}
|
428 |
|
|
test cmdMZ-15.9 {Tcl_StringObjCmd: string trim} {
|
429 |
|
|
string trim {}
|
430 |
|
|
} {}
|
431 |
|
|
test cmdMZ-15.10 {Tcl_StringObjCmd: string trim} {
|
432 |
|
|
string trim ABC DEF
|
433 |
|
|
} {ABC}
|
434 |
|
|
test cmdMZ-15.11 {Tcl_StringObjCmd: string trim, unicode} {
|
435 |
|
|
string trim "\xe7\xe8 AB\xe7C \xe8\xe7" \xe7\xe8
|
436 |
|
|
} " AB\xe7C "
|
437 |
|
|
|
438 |
|
|
test cmdMZ-16.1 {Tcl_StringObjCmd: string trimleft} {
|
439 |
|
|
string trimleft " XYZ "
|
440 |
|
|
} {XYZ }
|
441 |
|
|
test cmdMZ-16.2 {Tcl_StringObjCmd: string trimleft} {
|
442 |
|
|
list [catch {string trimleft} msg] $msg
|
443 |
|
|
} {1 {wrong # args: should be "string trimleft string ?chars?"}}
|
444 |
|
|
test cmdMZ-16.3 {Tcl_StringObjCmd: string trimleft} {
|
445 |
|
|
string length [string trimleft " "]
|
446 |
|
|
} {0}
|
447 |
|
|
|
448 |
|
|
test cmdMZ-17.1 {Tcl_StringObjCmd: string trimright} {
|
449 |
|
|
string trimright " XYZ "
|
450 |
|
|
} { XYZ}
|
451 |
|
|
test cmdMZ-17.2 {Tcl_StringObjCmd: string trimright} {
|
452 |
|
|
string trimright " "
|
453 |
|
|
} {}
|
454 |
|
|
test cmdMZ-17.3 {Tcl_StringObjCmd: string trimright} {
|
455 |
|
|
string trimright ""
|
456 |
|
|
} {}
|
457 |
|
|
test cmdMZ-17.4 {Tcl_StringObjCmd: string trimright errors} {
|
458 |
|
|
list [catch {string trimright} msg] $msg
|
459 |
|
|
} {1 {wrong # args: should be "string trimright string ?chars?"}}
|
460 |
|
|
test cmdMZ-17.5 {Tcl_StringObjCmd: string trimright errors} {
|
461 |
|
|
list [catch {string trimg a} msg] $msg
|
462 |
|
|
} {1 {bad option "trimg": must be compare, first, index, last, length, match, range, tolower, toupper, trim, trimleft, trimright, wordend, or wordstart}}
|
463 |
|
|
|
464 |
|
|
test cmdMZ-18.1 {Tcl_StringObjCmd: string wordend} {
|
465 |
|
|
list [catch {string wordend a} msg] $msg
|
466 |
|
|
} {1 {wrong # args: should be "string wordend string index"}}
|
467 |
|
|
test cmdMZ-18.2 {Tcl_StringObjCmd: string wordend} {
|
468 |
|
|
list [catch {string wordend a b c} msg] $msg
|
469 |
|
|
} {1 {wrong # args: should be "string wordend string index"}}
|
470 |
|
|
test cmdMZ-18.3 {Tcl_StringObjCmd: string wordend} {
|
471 |
|
|
list [catch {string wordend a gorp} msg] $msg
|
472 |
|
|
} {1 {expected integer but got "gorp"}}
|
473 |
|
|
test cmdMZ-18.4 {Tcl_StringObjCmd: string wordend} {
|
474 |
|
|
string wordend abc. -1
|
475 |
|
|
} 3
|
476 |
|
|
test cmdMZ-18.5 {Tcl_StringObjCmd: string wordend} {
|
477 |
|
|
string wordend abc. 100
|
478 |
|
|
} 4
|
479 |
|
|
test cmdMZ-18.6 {Tcl_StringObjCmd: string wordend} {
|
480 |
|
|
string wordend "word_one two three" 2
|
481 |
|
|
} 8
|
482 |
|
|
test cmdMZ-18.7 {Tcl_StringObjCmd: string wordend} {
|
483 |
|
|
string wordend "one . three" 5
|
484 |
|
|
} 6
|
485 |
|
|
test cmdMZ-18.8 {Tcl_StringObjCmd: string wordend} {
|
486 |
|
|
string worde "x.y" 0
|
487 |
|
|
} 1
|
488 |
|
|
test cmdMZ-18.9 {Tcl_StringObjCmd: string wordend, unicode} {hasIsoLocale} {
|
489 |
|
|
set_iso8859_1_locale
|
490 |
|
|
set result [string wordend "xyz\u00c7de fg" 0]
|
491 |
|
|
restore_locale
|
492 |
|
|
set result
|
493 |
|
|
} 6
|
494 |
|
|
test cmdMZ-18.10 {Tcl_StringObjCmd: string wordend, unicode} {hasIsoLocale} {
|
495 |
|
|
set_iso8859_1_locale
|
496 |
|
|
set result [string wordend "xyz\uc700de fg" 0]
|
497 |
|
|
restore_locale
|
498 |
|
|
set result
|
499 |
|
|
} 3
|
500 |
|
|
test cmdMZ-18.11 {Tcl_StringObjCmd: string wordend, unicode} {hasIsoLocale} {
|
501 |
|
|
set_iso8859_1_locale
|
502 |
|
|
set result [string wordend "xyz\uc700de fg" 0]
|
503 |
|
|
restore_locale
|
504 |
|
|
set result
|
505 |
|
|
} 3
|
506 |
|
|
test cmdMZ-18.12 {Tcl_StringObjCmd: string wordend, unicode} {
|
507 |
|
|
string wordend "\uc700\uc700 abc" 8
|
508 |
|
|
} 6
|
509 |
|
|
|
510 |
|
|
test cmdMZ-19.1 {Tcl_StringObjCmd: string wordstart} {
|
511 |
|
|
list [catch {string word a} msg] $msg
|
512 |
|
|
} {1 {ambiguous option "word": must be compare, first, index, last, length, match, range, tolower, toupper, trim, trimleft, trimright, wordend, or wordstart}}
|
513 |
|
|
test cmdMZ-19.2 {Tcl_StringObjCmd: string wordstart} {
|
514 |
|
|
list [catch {string wordstart a} msg] $msg
|
515 |
|
|
} {1 {wrong # args: should be "string wordstart string index"}}
|
516 |
|
|
test cmdMZ-19.3 {Tcl_StringObjCmd: string wordstart} {
|
517 |
|
|
list [catch {string wordstart a b c} msg] $msg
|
518 |
|
|
} {1 {wrong # args: should be "string wordstart string index"}}
|
519 |
|
|
test cmdMZ-19.4 {Tcl_StringObjCmd: string wordstart} {
|
520 |
|
|
list [catch {string wordstart a gorp} msg] $msg
|
521 |
|
|
} {1 {expected integer but got "gorp"}}
|
522 |
|
|
test cmdMZ-19.5 {Tcl_StringObjCmd: string wordstart} {
|
523 |
|
|
string wordstart "one two three_words" 400
|
524 |
|
|
} 8
|
525 |
|
|
test cmdMZ-19.6 {Tcl_StringObjCmd: string wordstart} {
|
526 |
|
|
string wordstart "one two three_words" 2
|
527 |
|
|
} 0
|
528 |
|
|
test cmdMZ-19.7 {Tcl_StringObjCmd: string wordstart} {
|
529 |
|
|
string wordstart "one two three_words" -2
|
530 |
|
|
} 0
|
531 |
|
|
test cmdMZ-19.8 {Tcl_StringObjCmd: string wordstart} {
|
532 |
|
|
string wordstart "one .*&^ three" 6
|
533 |
|
|
} 6
|
534 |
|
|
test cmdMZ-19.9 {Tcl_StringObjCmd: string wordstart} {
|
535 |
|
|
string wordstart "one two three" 4
|
536 |
|
|
} 4
|
537 |
|
|
test cmdMZ-19.10 {Tcl_StringObjCmd: string wordstart, unicode} {hasIsoLocale} {
|
538 |
|
|
set_iso8859_1_locale
|
539 |
|
|
set result [string wordstart "one tw\u00c7o three" 7]
|
540 |
|
|
restore_locale
|
541 |
|
|
set result
|
542 |
|
|
} 4
|
543 |
|
|
test cmdMZ-19.11 {Tcl_StringObjCmd: string wordstart, unicode} {hasIsoLocale} {
|
544 |
|
|
set_iso8859_1_locale
|
545 |
|
|
set result [string wordstart "ab\uc700\uc700 cdef ghi" 12]
|
546 |
|
|
restore_locale
|
547 |
|
|
set result
|
548 |
|
|
} 10
|
549 |
|
|
test cmdMZ-19.12 {Tcl_StringObjCmd: string wordstart, unicode} {
|
550 |
|
|
string wordstart "\uc700\uc700 abc" 8
|
551 |
|
|
} 3
|
552 |
|
|
|
553 |
|
|
# The tests for Tcl_SubstObjCmd are in subst.test
|
554 |
|
|
# The tests for Tcl_SwitchObjCmd are in switch.test
|
555 |
|
|
# There are no tests for Tcl_TimeObjCmd
|
556 |
|
|
# The tests for Tcl_TraceObjCmd and TraceVarProc are in trace.test
|
557 |
|
|
# The tests for Tcl_WhileObjCmd are in while.test
|
558 |
|
|
|
559 |
|
|
return
|