sl@0
|
1 |
# This file contains a collection of tests for the procedures in the
|
sl@0
|
2 |
# file tclCmdIL.c. Sourcing this file into Tcl runs the tests and
|
sl@0
|
3 |
# generates output for errors. No output means no errors were found.
|
sl@0
|
4 |
#
|
sl@0
|
5 |
# Copyright (c) 1997 Sun Microsystems, Inc.
|
sl@0
|
6 |
# Copyright (c) 1998-1999 by Scriptics Corporation.
|
sl@0
|
7 |
#
|
sl@0
|
8 |
# See the file "license.terms" for information on usage and redistribution
|
sl@0
|
9 |
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
sl@0
|
10 |
#
|
sl@0
|
11 |
# RCS: @(#) $Id: cmdIL.test,v 1.14.6.2 2007/03/10 14:57:38 dkf Exp $
|
sl@0
|
12 |
|
sl@0
|
13 |
if {[lsearch [namespace children] ::tcltest] == -1} {
|
sl@0
|
14 |
package require tcltest
|
sl@0
|
15 |
namespace import -force ::tcltest::*
|
sl@0
|
16 |
}
|
sl@0
|
17 |
|
sl@0
|
18 |
test cmdIL-1.1 {Tcl_LsortObjCmd procedure} {
|
sl@0
|
19 |
list [catch {lsort} msg] $msg
|
sl@0
|
20 |
} {1 {wrong # args: should be "lsort ?options? list"}}
|
sl@0
|
21 |
test cmdIL-1.2 {Tcl_LsortObjCmd procedure} {
|
sl@0
|
22 |
list [catch {lsort -foo {1 3 2 5}} msg] $msg
|
sl@0
|
23 |
} {1 {bad option "-foo": must be -ascii, -command, -decreasing, -dictionary, -increasing, -index, -integer, -real, or -unique}}
|
sl@0
|
24 |
test cmdIL-1.3 {Tcl_LsortObjCmd procedure, default options} {
|
sl@0
|
25 |
lsort {d e c b a \{ d35 d300}
|
sl@0
|
26 |
} {a b c d d300 d35 e \{}
|
sl@0
|
27 |
test cmdIL-1.4 {Tcl_LsortObjCmd procedure, -ascii option} {
|
sl@0
|
28 |
lsort -integer -ascii {d e c b a d35 d300}
|
sl@0
|
29 |
} {a b c d d300 d35 e}
|
sl@0
|
30 |
test cmdIL-1.5 {Tcl_LsortObjCmd procedure, -command option} {
|
sl@0
|
31 |
list [catch {lsort -command {1 3 2 5}} msg] $msg
|
sl@0
|
32 |
} {1 {"-command" option must be followed by comparison command}}
|
sl@0
|
33 |
test cmdIL-1.6 {Tcl_LsortObjCmd procedure, -command option} {
|
sl@0
|
34 |
proc cmp {a b} {
|
sl@0
|
35 |
expr {[string match x* $b] - [string match x* $a]}
|
sl@0
|
36 |
}
|
sl@0
|
37 |
lsort -command cmp {x1 abc x2 def x3 x4}
|
sl@0
|
38 |
} {x1 x2 x3 x4 abc def}
|
sl@0
|
39 |
test cmdIL-1.7 {Tcl_LsortObjCmd procedure, -decreasing option} {
|
sl@0
|
40 |
lsort -decreasing {d e c b a d35 d300}
|
sl@0
|
41 |
} {e d35 d300 d c b a}
|
sl@0
|
42 |
test cmdIL-1.8 {Tcl_LsortObjCmd procedure, -dictionary option} {
|
sl@0
|
43 |
lsort -dictionary {d e c b a d35 d300}
|
sl@0
|
44 |
} {a b c d d35 d300 e}
|
sl@0
|
45 |
test cmdIL-1.9 {Tcl_LsortObjCmd procedure, -dictionary option} {
|
sl@0
|
46 |
lsort -dictionary {1k 0k 10k}
|
sl@0
|
47 |
} {0k 1k 10k}
|
sl@0
|
48 |
test cmdIL-1.10 {Tcl_LsortObjCmd procedure, -increasing option} {
|
sl@0
|
49 |
lsort -decreasing -increasing {d e c b a d35 d300}
|
sl@0
|
50 |
} {a b c d d300 d35 e}
|
sl@0
|
51 |
test cmdIL-1.11 {Tcl_LsortObjCmd procedure, -index option} {
|
sl@0
|
52 |
list [catch {lsort -index {1 3 2 5}} msg] $msg
|
sl@0
|
53 |
} {1 {"-index" option must be followed by list index}}
|
sl@0
|
54 |
test cmdIL-1.12 {Tcl_LsortObjCmd procedure, -index option} {
|
sl@0
|
55 |
list [catch {lsort -index foo {1 3 2 5}} msg] $msg
|
sl@0
|
56 |
} {1 {bad index "foo": must be integer or end?-integer?}}
|
sl@0
|
57 |
test cmdIL-1.13 {Tcl_LsortObjCmd procedure, -index option} {
|
sl@0
|
58 |
lsort -index end -integer {{2 25} {10 20 50 100} {3 16 42} 1}
|
sl@0
|
59 |
} {1 {2 25} {3 16 42} {10 20 50 100}}
|
sl@0
|
60 |
test cmdIL-1.14 {Tcl_LsortObjCmd procedure, -index option} {
|
sl@0
|
61 |
lsort -index 1 -integer {{1 25 100} {3 16 42} {10 20 50}}
|
sl@0
|
62 |
} {{3 16 42} {10 20 50} {1 25 100}}
|
sl@0
|
63 |
test cmdIL-1.15 {Tcl_LsortObjCmd procedure, -integer option} {
|
sl@0
|
64 |
lsort -integer {24 6 300 18}
|
sl@0
|
65 |
} {6 18 24 300}
|
sl@0
|
66 |
test cmdIL-1.16 {Tcl_LsortObjCmd procedure, -integer option} {
|
sl@0
|
67 |
list [catch {lsort -integer {1 3 2.4}} msg] $msg
|
sl@0
|
68 |
} {1 {expected integer but got "2.4"}}
|
sl@0
|
69 |
test cmdIL-1.17 {Tcl_LsortObjCmd procedure, -real option} {
|
sl@0
|
70 |
lsort -real {24.2 6e3 150e-1}
|
sl@0
|
71 |
} {150e-1 24.2 6e3}
|
sl@0
|
72 |
test cmdIL-1.18 {Tcl_LsortObjCmd procedure, bogus list} {
|
sl@0
|
73 |
list [catch {lsort "1 2 3 \{ 4"} msg] $msg
|
sl@0
|
74 |
} {1 {unmatched open brace in list}}
|
sl@0
|
75 |
test cmdIL-1.19 {Tcl_LsortObjCmd procedure, empty list} {
|
sl@0
|
76 |
lsort {}
|
sl@0
|
77 |
} {}
|
sl@0
|
78 |
test cmdIL-1.22 {Tcl_LsortObjCmd procedure, unique sort} {
|
sl@0
|
79 |
lsort -integer -unique {3 1 2 3 1 4 3}
|
sl@0
|
80 |
} {1 2 3 4}
|
sl@0
|
81 |
test cmdIL-1.23 {Tcl_LsortObjCmd procedure, unique sort with index} {
|
sl@0
|
82 |
# lsort -unique should return the last unique item
|
sl@0
|
83 |
lsort -unique -index 0 {{a b} {c b} {a c} {d a}}
|
sl@0
|
84 |
} {{a c} {c b} {d a}}
|
sl@0
|
85 |
test cmdIL-1.24 {Tcl_LsortObjCmd procedure, order of -index and -command} {
|
sl@0
|
86 |
catch {rename 1 ""}
|
sl@0
|
87 |
proc testcmp {a b} {return [string compare $a $b]}
|
sl@0
|
88 |
set l [list [list a b] [list c d]]
|
sl@0
|
89 |
set result [list [catch {lsort -command testcmp -index 1 $l} msg] $msg]
|
sl@0
|
90 |
rename testcmp ""
|
sl@0
|
91 |
set result
|
sl@0
|
92 |
} [list 0 [list [list a b] [list c d]]]
|
sl@0
|
93 |
test cmdIL-1.25 {Tcl_LsortObjCmd procedure, order of -index and -command} {
|
sl@0
|
94 |
catch {rename 1 ""}
|
sl@0
|
95 |
proc testcmp {a b} {return [string compare $a $b]}
|
sl@0
|
96 |
set l [list [list a b] [list c d]]
|
sl@0
|
97 |
set result [list [catch {lsort -index 1 -command testcmp $l} msg] $msg]
|
sl@0
|
98 |
rename testcmp ""
|
sl@0
|
99 |
set result
|
sl@0
|
100 |
} [list 0 [list [list a b] [list c d]]]
|
sl@0
|
101 |
# Note that the required order only exists in the end-1'th element;
|
sl@0
|
102 |
# indexing using the end element or any fixed offset from the start
|
sl@0
|
103 |
# will not work...
|
sl@0
|
104 |
test cmdIL-1.26 {Tcl_LsortObjCmd procedure, offset indexing from end} {
|
sl@0
|
105 |
lsort -index end-1 {{a 1 e i} {b 2 3 f g} {c 4 5 6 d h}}
|
sl@0
|
106 |
} {{c 4 5 6 d h} {a 1 e i} {b 2 3 f g}}
|
sl@0
|
107 |
test cmdIL-1.29 {Tcl_LsortObjCmd procedure, loss of list rep during sorting} {
|
sl@0
|
108 |
set l {1 2 3}
|
sl@0
|
109 |
proc testcmp args {string length $::l}
|
sl@0
|
110 |
string length [lsort -command testcmp $l]
|
sl@0
|
111 |
} 5
|
sl@0
|
112 |
|
sl@0
|
113 |
# Can't think of any good tests for the MergeSort and MergeLists
|
sl@0
|
114 |
# procedures, except a bunch of random lists to sort.
|
sl@0
|
115 |
|
sl@0
|
116 |
test cmdIL-2.1 {MergeSort and MergeLists procedures} {
|
sl@0
|
117 |
set result {}
|
sl@0
|
118 |
set r 1435753299
|
sl@0
|
119 |
proc rand {} {
|
sl@0
|
120 |
global r
|
sl@0
|
121 |
set r [expr {(16807 * $r) % (0x7fffffff)}]
|
sl@0
|
122 |
}
|
sl@0
|
123 |
for {set i 0} {$i < 150} {incr i} {
|
sl@0
|
124 |
set x {}
|
sl@0
|
125 |
for {set j 0} {$j < $i} {incr j} {
|
sl@0
|
126 |
lappend x [expr {[rand] & 0xfff}]
|
sl@0
|
127 |
}
|
sl@0
|
128 |
set y [lsort -integer $x]
|
sl@0
|
129 |
set old -1
|
sl@0
|
130 |
foreach el $y {
|
sl@0
|
131 |
if {$el < $old} {
|
sl@0
|
132 |
append result "list {$x} sorted to {$y}, element $el out of order\n"
|
sl@0
|
133 |
break
|
sl@0
|
134 |
}
|
sl@0
|
135 |
set old $el
|
sl@0
|
136 |
}
|
sl@0
|
137 |
}
|
sl@0
|
138 |
set result
|
sl@0
|
139 |
} {}
|
sl@0
|
140 |
|
sl@0
|
141 |
test cmdIL-3.1 {SortCompare procedure, skip comparisons after error} {
|
sl@0
|
142 |
set x 0
|
sl@0
|
143 |
proc cmp {a b} {
|
sl@0
|
144 |
global x
|
sl@0
|
145 |
incr x
|
sl@0
|
146 |
error "error #$x"
|
sl@0
|
147 |
}
|
sl@0
|
148 |
list [catch {lsort -integer -command cmp {48 6 28 190 16 2 3 6 1}} msg] \
|
sl@0
|
149 |
$msg $x
|
sl@0
|
150 |
} {1 {error #1} 1}
|
sl@0
|
151 |
test cmdIL-3.2 {SortCompare procedure, -index option} {
|
sl@0
|
152 |
list [catch {lsort -integer -index 2 "\\\{ {30 40 50}"} msg] $msg
|
sl@0
|
153 |
} {1 {unmatched open brace in list}}
|
sl@0
|
154 |
test cmdIL-3.3 {SortCompare procedure, -index option} {
|
sl@0
|
155 |
list [catch {lsort -integer -index 2 {{20 10} {15 30 40}}} msg] $msg
|
sl@0
|
156 |
} {1 {element 2 missing from sublist "20 10"}}
|
sl@0
|
157 |
test cmdIL-3.4 {SortCompare procedure, -index option} {
|
sl@0
|
158 |
list [catch {lsort -integer -index 2 "{a b c} \\\{"} msg] $msg
|
sl@0
|
159 |
} {1 {unmatched open brace in list}}
|
sl@0
|
160 |
test cmdIL-3.5 {SortCompare procedure, -index option} {
|
sl@0
|
161 |
list [catch {lsort -integer -index 2 {{20 10 13} {15}}} msg] $msg
|
sl@0
|
162 |
} {1 {element 2 missing from sublist "15"}}
|
sl@0
|
163 |
test cmdIL-3.6 {SortCompare procedure, -index option} {
|
sl@0
|
164 |
lsort -integer -index 2 {{1 15 30} {2 5 25} {3 25 20}}
|
sl@0
|
165 |
} {{3 25 20} {2 5 25} {1 15 30}}
|
sl@0
|
166 |
test cmdIL-3.7 {SortCompare procedure, -ascii option} {
|
sl@0
|
167 |
lsort -ascii {d e c b a d35 d300 100 20}
|
sl@0
|
168 |
} {100 20 a b c d d300 d35 e}
|
sl@0
|
169 |
test cmdIL-3.8 {SortCompare procedure, -dictionary option} {
|
sl@0
|
170 |
lsort -dictionary {d e c b a d35 d300 100 20}
|
sl@0
|
171 |
} {20 100 a b c d d35 d300 e}
|
sl@0
|
172 |
test cmdIL-3.9 {SortCompare procedure, -integer option} {
|
sl@0
|
173 |
list [catch {lsort -integer {x 3}} msg] $msg
|
sl@0
|
174 |
} {1 {expected integer but got "x"}}
|
sl@0
|
175 |
test cmdIL-3.10 {SortCompare procedure, -integer option} {
|
sl@0
|
176 |
list [catch {lsort -integer {3 q}} msg] $msg
|
sl@0
|
177 |
} {1 {expected integer but got "q"}}
|
sl@0
|
178 |
test cmdIL-3.11 {SortCompare procedure, -integer option} {
|
sl@0
|
179 |
lsort -integer {35 21 0x20 30 023 100 8}
|
sl@0
|
180 |
} {8 023 21 30 0x20 35 100}
|
sl@0
|
181 |
test cmdIL-3.12 {SortCompare procedure, -real option} {
|
sl@0
|
182 |
list [catch {lsort -real {6...4 3}} msg] $msg
|
sl@0
|
183 |
} {1 {expected floating-point number but got "6...4"}}
|
sl@0
|
184 |
test cmdIL-3.13 {SortCompare procedure, -real option} {
|
sl@0
|
185 |
list [catch {lsort -real {3 1x7}} msg] $msg
|
sl@0
|
186 |
} {1 {expected floating-point number but got "1x7"}}
|
sl@0
|
187 |
test cmdIL-3.14 {SortCompare procedure, -real option} {
|
sl@0
|
188 |
lsort -real {24 2.5e01 16.7 85e-1 10.004}
|
sl@0
|
189 |
} {85e-1 10.004 16.7 24 2.5e01}
|
sl@0
|
190 |
test cmdIL-3.15 {SortCompare procedure, -command option} {
|
sl@0
|
191 |
proc cmp {a b} {
|
sl@0
|
192 |
error "comparison error"
|
sl@0
|
193 |
}
|
sl@0
|
194 |
list [catch {lsort -command cmp {48 6}} msg] $msg $errorInfo
|
sl@0
|
195 |
} {1 {comparison error} {comparison error
|
sl@0
|
196 |
while executing
|
sl@0
|
197 |
"error "comparison error""
|
sl@0
|
198 |
(procedure "cmp" line 2)
|
sl@0
|
199 |
invoked from within
|
sl@0
|
200 |
"cmp 48 6"
|
sl@0
|
201 |
(-compare command)
|
sl@0
|
202 |
invoked from within
|
sl@0
|
203 |
"lsort -command cmp {48 6}"}}
|
sl@0
|
204 |
test cmdIL-3.16 {SortCompare procedure, -command option, long command} {
|
sl@0
|
205 |
proc cmp {dummy a b} {
|
sl@0
|
206 |
string compare $a $b
|
sl@0
|
207 |
}
|
sl@0
|
208 |
lsort -command {cmp {this argument is very very long in order to make the dstring overflow its statically allocated space}} {{this first element is also long in order to help expand the dstring} {the second element, last but not least, is quite long also, in order to make absolutely sure that space is allocated dynamically for the dstring}}
|
sl@0
|
209 |
} {{the second element, last but not least, is quite long also, in order to make absolutely sure that space is allocated dynamically for the dstring} {this first element is also long in order to help expand the dstring}}
|
sl@0
|
210 |
test cmdIL-3.17 {SortCompare procedure, -command option, non-integer result} {
|
sl@0
|
211 |
proc cmp {a b} {
|
sl@0
|
212 |
return foow
|
sl@0
|
213 |
}
|
sl@0
|
214 |
list [catch {lsort -command cmp {48 6}} msg] $msg
|
sl@0
|
215 |
} {1 {-compare command returned non-integer result}}
|
sl@0
|
216 |
test cmdIL-3.18 {SortCompare procedure, -command option} {
|
sl@0
|
217 |
proc cmp {a b} {
|
sl@0
|
218 |
expr {$b - $a}
|
sl@0
|
219 |
}
|
sl@0
|
220 |
lsort -command cmp {48 6 18 22 21 35 36}
|
sl@0
|
221 |
} {48 36 35 22 21 18 6}
|
sl@0
|
222 |
test cmdIL-3.19 {SortCompare procedure, -decreasing option} {
|
sl@0
|
223 |
lsort -decreasing -integer {35 21 0x20 30 023 100 8}
|
sl@0
|
224 |
} {100 35 0x20 30 21 023 8}
|
sl@0
|
225 |
|
sl@0
|
226 |
test cmdIL-4.1 {DictionaryCompare procedure, numerics, leading zeros} {
|
sl@0
|
227 |
lsort -dictionary {a003b a03b}
|
sl@0
|
228 |
} {a03b a003b}
|
sl@0
|
229 |
test cmdIL-4.2 {DictionaryCompare procedure, numerics, leading zeros} {
|
sl@0
|
230 |
lsort -dictionary {a3b a03b}
|
sl@0
|
231 |
} {a3b a03b}
|
sl@0
|
232 |
test cmdIL-4.3 {DictionaryCompare procedure, numerics, leading zeros} {
|
sl@0
|
233 |
lsort -dictionary {a3b A03b}
|
sl@0
|
234 |
} {A03b a3b}
|
sl@0
|
235 |
test cmdIL-4.4 {DictionaryCompare procedure, numerics, leading zeros} {
|
sl@0
|
236 |
lsort -dictionary {a3b a03B}
|
sl@0
|
237 |
} {a3b a03B}
|
sl@0
|
238 |
test cmdIL-4.5 {DictionaryCompare procedure, numerics, leading zeros} {
|
sl@0
|
239 |
lsort -dictionary {00000 000}
|
sl@0
|
240 |
} {000 00000}
|
sl@0
|
241 |
test cmdIL-4.6 {DictionaryCompare procedure, numerics, different lengths} {
|
sl@0
|
242 |
lsort -dictionary {a321b a03210b}
|
sl@0
|
243 |
} {a321b a03210b}
|
sl@0
|
244 |
test cmdIL-4.7 {DictionaryCompare procedure, numerics, different lengths} {
|
sl@0
|
245 |
lsort -dictionary {a03210b a321b}
|
sl@0
|
246 |
} {a321b a03210b}
|
sl@0
|
247 |
test cmdIL-4.8 {DictionaryCompare procedure, numerics} {
|
sl@0
|
248 |
lsort -dictionary {48 6a 18b 22a 21aa 35 36}
|
sl@0
|
249 |
} {6a 18b 21aa 22a 35 36 48}
|
sl@0
|
250 |
test cmdIL-4.9 {DictionaryCompare procedure, numerics} {
|
sl@0
|
251 |
lsort -dictionary {a123x a123b}
|
sl@0
|
252 |
} {a123b a123x}
|
sl@0
|
253 |
test cmdIL-4.10 {DictionaryCompare procedure, numerics} {
|
sl@0
|
254 |
lsort -dictionary {a123b a123x}
|
sl@0
|
255 |
} {a123b a123x}
|
sl@0
|
256 |
test cmdIL-4.11 {DictionaryCompare procedure, numerics} {
|
sl@0
|
257 |
lsort -dictionary {a1b aab}
|
sl@0
|
258 |
} {a1b aab}
|
sl@0
|
259 |
test cmdIL-4.12 {DictionaryCompare procedure, numerics} {
|
sl@0
|
260 |
lsort -dictionary {a1b a!b}
|
sl@0
|
261 |
} {a!b a1b}
|
sl@0
|
262 |
test cmdIL-4.13 {DictionaryCompare procedure, numerics} {
|
sl@0
|
263 |
lsort -dictionary {a1b2c a1b1c}
|
sl@0
|
264 |
} {a1b1c a1b2c}
|
sl@0
|
265 |
test cmdIL-4.14 {DictionaryCompare procedure, numerics} {
|
sl@0
|
266 |
lsort -dictionary {a1b2c a1b3c}
|
sl@0
|
267 |
} {a1b2c a1b3c}
|
sl@0
|
268 |
test cmdIL-4.15 {DictionaryCompare procedure, long numbers} {
|
sl@0
|
269 |
lsort -dictionary {a7654884321988762b a7654884321988761b}
|
sl@0
|
270 |
} {a7654884321988761b a7654884321988762b}
|
sl@0
|
271 |
test cmdIL-4.16 {DictionaryCompare procedure, long numbers} {
|
sl@0
|
272 |
lsort -dictionary {a8765488432198876b a7654884321988761b}
|
sl@0
|
273 |
} {a7654884321988761b a8765488432198876b}
|
sl@0
|
274 |
test cmdIL-4.17 {DictionaryCompare procedure, case} {
|
sl@0
|
275 |
lsort -dictionary {aBCd abcc}
|
sl@0
|
276 |
} {abcc aBCd}
|
sl@0
|
277 |
test cmdIL-4.18 {DictionaryCompare procedure, case} {
|
sl@0
|
278 |
lsort -dictionary {aBCd abce}
|
sl@0
|
279 |
} {aBCd abce}
|
sl@0
|
280 |
test cmdIL-4.19 {DictionaryCompare procedure, case} {
|
sl@0
|
281 |
lsort -dictionary {abcd ABcc}
|
sl@0
|
282 |
} {ABcc abcd}
|
sl@0
|
283 |
test cmdIL-4.20 {DictionaryCompare procedure, case} {
|
sl@0
|
284 |
lsort -dictionary {abcd ABce}
|
sl@0
|
285 |
} {abcd ABce}
|
sl@0
|
286 |
test cmdIL-4.21 {DictionaryCompare procedure, case} {
|
sl@0
|
287 |
lsort -dictionary {abCD ABcd}
|
sl@0
|
288 |
} {ABcd abCD}
|
sl@0
|
289 |
test cmdIL-4.22 {DictionaryCompare procedure, case} {
|
sl@0
|
290 |
lsort -dictionary {ABcd aBCd}
|
sl@0
|
291 |
} {ABcd aBCd}
|
sl@0
|
292 |
test cmdIL-4.23 {DictionaryCompare procedure, case} {
|
sl@0
|
293 |
lsort -dictionary {ABcd AbCd}
|
sl@0
|
294 |
} {ABcd AbCd}
|
sl@0
|
295 |
test cmdIL-4.24 {DictionaryCompare procedure, international characters} {hasIsoLocale} {
|
sl@0
|
296 |
::tcltest::set_iso8859_1_locale
|
sl@0
|
297 |
set result [lsort -dictionary "a b c A B C \xe3 \xc4"]
|
sl@0
|
298 |
::tcltest::restore_locale
|
sl@0
|
299 |
set result
|
sl@0
|
300 |
} "A a B b C c \xe3 \xc4"
|
sl@0
|
301 |
test cmdIL-4.25 {DictionaryCompare procedure, international characters} {hasIsoLocale} {
|
sl@0
|
302 |
::tcltest::set_iso8859_1_locale
|
sl@0
|
303 |
set result [lsort -dictionary "a23\xe3 a23\xc5 a23\xe4"]
|
sl@0
|
304 |
::tcltest::restore_locale
|
sl@0
|
305 |
set result
|
sl@0
|
306 |
} "a23\xe3 a23\xe4 a23\xc5"
|
sl@0
|
307 |
test cmdIL-4.26 {DefaultCompare procedure, signed characters} {
|
sl@0
|
308 |
set l [lsort [list "abc\200" "abc"]]
|
sl@0
|
309 |
set viewlist {}
|
sl@0
|
310 |
foreach s $l {
|
sl@0
|
311 |
set viewelem ""
|
sl@0
|
312 |
set len [string length $s]
|
sl@0
|
313 |
for {set i 0} {$i < $len} {incr i} {
|
sl@0
|
314 |
set c [string index $s $i]
|
sl@0
|
315 |
scan $c %c d
|
sl@0
|
316 |
if {$d > 0 && $d < 128} {
|
sl@0
|
317 |
append viewelem $c
|
sl@0
|
318 |
} else {
|
sl@0
|
319 |
append viewelem "\\[format %03o $d]"
|
sl@0
|
320 |
}
|
sl@0
|
321 |
}
|
sl@0
|
322 |
lappend viewlist $viewelem
|
sl@0
|
323 |
}
|
sl@0
|
324 |
set viewlist
|
sl@0
|
325 |
} [list "abc" "abc\\200"]
|
sl@0
|
326 |
test cmdIL-4.27 {DictionaryCompare procedure, signed characters} {
|
sl@0
|
327 |
set l [lsort -dictionary [list "abc\200" "abc"]]
|
sl@0
|
328 |
set viewlist {}
|
sl@0
|
329 |
foreach s $l {
|
sl@0
|
330 |
set viewelem ""
|
sl@0
|
331 |
set len [string length $s]
|
sl@0
|
332 |
for {set i 0} {$i < $len} {incr i} {
|
sl@0
|
333 |
set c [string index $s $i]
|
sl@0
|
334 |
scan $c %c d
|
sl@0
|
335 |
if {$d > 0 && $d < 128} {
|
sl@0
|
336 |
append viewelem $c
|
sl@0
|
337 |
} else {
|
sl@0
|
338 |
append viewelem "\\[format %03o $d]"
|
sl@0
|
339 |
}
|
sl@0
|
340 |
}
|
sl@0
|
341 |
lappend viewlist $viewelem
|
sl@0
|
342 |
}
|
sl@0
|
343 |
set viewlist
|
sl@0
|
344 |
} [list "abc" "abc\\200"]
|
sl@0
|
345 |
test cmdIL-4.28 {DictionaryCompare procedure, chars between Z and a in ASCII} {
|
sl@0
|
346 |
lsort -dictionary [list AA ` c CC]
|
sl@0
|
347 |
} [list ` AA c CC]
|
sl@0
|
348 |
test cmdIL-4.29 {DictionaryCompare procedure, chars between Z and a in ASCII} {
|
sl@0
|
349 |
lsort -dictionary [list AA ` c ^ \\ CC \[ \]]
|
sl@0
|
350 |
} [list \[ \\ \] ^ ` AA c CC]
|
sl@0
|
351 |
test cmdIL-4.30 {DictionaryCompare procedure, chars between Z and a in ASCII} {
|
sl@0
|
352 |
lsort -dictionary [list AA ` c ^ _ \\ CC \[ dude \] funky]
|
sl@0
|
353 |
} [list \[ \\ \] ^ _ ` AA c CC dude funky]
|
sl@0
|
354 |
test cmdIL-4.31 {DictionaryCompare procedure, chars between Z and a in ASCII} {
|
sl@0
|
355 |
lsort -dictionary [list AA c ` CC]
|
sl@0
|
356 |
} [list ` AA c CC]
|
sl@0
|
357 |
test cmdIL-4.32 {DictionaryCompare procedure, chars between Z and a in ASCII} {
|
sl@0
|
358 |
lsort -dictionary [list AA c CC `]
|
sl@0
|
359 |
} [list ` AA c CC]
|
sl@0
|
360 |
test cmdIL-4.33 {DictionaryCompare procedure, chars between Z and a in ASCII} {
|
sl@0
|
361 |
lsort -dictionary [list AA ! c CC `]
|
sl@0
|
362 |
} [list ! ` AA c CC]
|
sl@0
|
363 |
|
sl@0
|
364 |
# cleanup
|
sl@0
|
365 |
::tcltest::cleanupTests
|
sl@0
|
366 |
return
|