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