sl@0
|
1 |
# Commands covered: scan
|
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-1994 The Regents of the University of California.
|
sl@0
|
8 |
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
|
sl@0
|
9 |
# Copyright (c) 1998-1999 by Scriptics Corporation.
|
sl@0
|
10 |
#
|
sl@0
|
11 |
# See the file "license.terms" for information on usage and redistribution
|
sl@0
|
12 |
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
sl@0
|
13 |
#
|
sl@0
|
14 |
# RCS: @(#) $Id: scan.test,v 1.14.2.1 2004/08/19 21:12:04 dkf Exp $
|
sl@0
|
15 |
|
sl@0
|
16 |
if {[lsearch [namespace children] ::tcltest] == -1} {
|
sl@0
|
17 |
package require tcltest 2
|
sl@0
|
18 |
namespace import -force ::tcltest::*
|
sl@0
|
19 |
}
|
sl@0
|
20 |
|
sl@0
|
21 |
::tcltest::testConstraint 64bitInts [expr {0x80000000 > 0}]
|
sl@0
|
22 |
|
sl@0
|
23 |
test scan-1.1 {BuildCharSet, CharInSet} {
|
sl@0
|
24 |
list [scan foo {%[^o]} x] $x
|
sl@0
|
25 |
} {1 f}
|
sl@0
|
26 |
test scan-1.2 {BuildCharSet, CharInSet} {
|
sl@0
|
27 |
list [scan \]foo {%[]f]} x] $x
|
sl@0
|
28 |
} {1 \]f}
|
sl@0
|
29 |
test scan-1.3 {BuildCharSet, CharInSet} {
|
sl@0
|
30 |
list [scan abc-def {%[a-c]} x] $x
|
sl@0
|
31 |
} {1 abc}
|
sl@0
|
32 |
test scan-1.4 {BuildCharSet, CharInSet} {
|
sl@0
|
33 |
list [scan abc-def {%[a-c]} x] $x
|
sl@0
|
34 |
} {1 abc}
|
sl@0
|
35 |
test scan-1.5 {BuildCharSet, CharInSet} {
|
sl@0
|
36 |
list [scan -abc-def {%[-ac]} x] $x
|
sl@0
|
37 |
} {1 -a}
|
sl@0
|
38 |
test scan-1.6 {BuildCharSet, CharInSet} {
|
sl@0
|
39 |
list [scan -abc-def {%[ac-]} x] $x
|
sl@0
|
40 |
} {1 -a}
|
sl@0
|
41 |
test scan-1.7 {BuildCharSet, CharInSet} {
|
sl@0
|
42 |
list [scan abc-def {%[c-a]} x] $x
|
sl@0
|
43 |
} {1 abc}
|
sl@0
|
44 |
test scan-1.8 {BuildCharSet, CharInSet} {
|
sl@0
|
45 |
list [scan def-abc {%[^c-a]} x] $x
|
sl@0
|
46 |
} {1 def-}
|
sl@0
|
47 |
test scan-1.9 {BuildCharSet, CharInSet no match} {
|
sl@0
|
48 |
catch {unset x}
|
sl@0
|
49 |
list [scan {= f} {= %[TF]} x] [info exists x]
|
sl@0
|
50 |
} {0 0}
|
sl@0
|
51 |
|
sl@0
|
52 |
test scan-2.1 {ReleaseCharSet} {
|
sl@0
|
53 |
list [scan abcde {%[abc]} x] $x
|
sl@0
|
54 |
} {1 abc}
|
sl@0
|
55 |
test scan-2.2 {ReleaseCharSet} {
|
sl@0
|
56 |
list [scan abcde {%[a-c]} x] $x
|
sl@0
|
57 |
} {1 abc}
|
sl@0
|
58 |
|
sl@0
|
59 |
test scan-3.1 {ValidateFormat} {
|
sl@0
|
60 |
list [catch {scan {} {%d%1$d} x} msg] $msg
|
sl@0
|
61 |
} {1 {cannot mix "%" and "%n$" conversion specifiers}}
|
sl@0
|
62 |
test scan-3.2 {ValidateFormat} {
|
sl@0
|
63 |
list [catch {scan {} {%d%1$d} x} msg] $msg
|
sl@0
|
64 |
} {1 {cannot mix "%" and "%n$" conversion specifiers}}
|
sl@0
|
65 |
test scan-3.3 {ValidateFormat} {
|
sl@0
|
66 |
list [catch {scan {} {%2$d%d} x} msg] $msg
|
sl@0
|
67 |
} {1 {"%n$" argument index out of range}}
|
sl@0
|
68 |
test scan-3.4 {ValidateFormat} {
|
sl@0
|
69 |
# degenerate case, before changed from 8.2 to 8.3
|
sl@0
|
70 |
list [catch {scan {} %d} msg] $msg
|
sl@0
|
71 |
} {0 {}}
|
sl@0
|
72 |
test scan-3.5 {ValidateFormat} {
|
sl@0
|
73 |
list [catch {scan {} {%10c} a} msg] $msg
|
sl@0
|
74 |
} {1 {field width may not be specified in %c conversion}}
|
sl@0
|
75 |
test scan-3.6 {ValidateFormat} {
|
sl@0
|
76 |
list [catch {scan {} {%*1$d} a} msg] $msg
|
sl@0
|
77 |
} {1 {bad scan conversion character "$"}}
|
sl@0
|
78 |
test scan-3.7 {ValidateFormat} {
|
sl@0
|
79 |
list [catch {scan {} {%1$d%1$d} a} msg] $msg
|
sl@0
|
80 |
} {1 {variable is assigned by multiple "%n$" conversion specifiers}}
|
sl@0
|
81 |
test scan-3.8 {ValidateFormat} {
|
sl@0
|
82 |
list [catch {scan {} a x} msg] $msg
|
sl@0
|
83 |
} {1 {variable is not assigned by any conversion specifiers}}
|
sl@0
|
84 |
test scan-3.9 {ValidateFormat} {
|
sl@0
|
85 |
list [catch {scan {} {%2$s} x y} msg] $msg
|
sl@0
|
86 |
} {1 {variable is not assigned by any conversion specifiers}}
|
sl@0
|
87 |
test scan-3.10 {ValidateFormat} {
|
sl@0
|
88 |
list [catch {scan {} {%[a} x} msg] $msg
|
sl@0
|
89 |
} {1 {unmatched [ in format string}}
|
sl@0
|
90 |
test scan-3.11 {ValidateFormat} {
|
sl@0
|
91 |
list [catch {scan {} {%[^a} x} msg] $msg
|
sl@0
|
92 |
} {1 {unmatched [ in format string}}
|
sl@0
|
93 |
test scan-3.12 {ValidateFormat} {
|
sl@0
|
94 |
list [catch {scan {} {%[]a} x} msg] $msg
|
sl@0
|
95 |
} {1 {unmatched [ in format string}}
|
sl@0
|
96 |
test scan-3.13 {ValidateFormat} {
|
sl@0
|
97 |
list [catch {scan {} {%[^]a} x} msg] $msg
|
sl@0
|
98 |
} {1 {unmatched [ in format string}}
|
sl@0
|
99 |
|
sl@0
|
100 |
test scan-4.1 {Tcl_ScanObjCmd, argument checks} {
|
sl@0
|
101 |
list [catch {scan} msg] $msg
|
sl@0
|
102 |
} {1 {wrong # args: should be "scan string format ?varName varName ...?"}}
|
sl@0
|
103 |
test scan-4.2 {Tcl_ScanObjCmd, argument checks} {
|
sl@0
|
104 |
list [catch {scan string} msg] $msg
|
sl@0
|
105 |
} {1 {wrong # args: should be "scan string format ?varName varName ...?"}}
|
sl@0
|
106 |
test scan-4.3 {Tcl_ScanObjCmd, argument checks} {
|
sl@0
|
107 |
# degenerate case, before changed from 8.2 to 8.3
|
sl@0
|
108 |
list [catch {scan string format} msg] $msg
|
sl@0
|
109 |
} {0 {}}
|
sl@0
|
110 |
test scan-4.4 {Tcl_ScanObjCmd, whitespace} {
|
sl@0
|
111 |
list [scan { abc def } {%s%s} x y] $x $y
|
sl@0
|
112 |
} {2 abc def}
|
sl@0
|
113 |
test scan-4.5 {Tcl_ScanObjCmd, whitespace} {
|
sl@0
|
114 |
list [scan { abc def } { %s %s } x y] $x $y
|
sl@0
|
115 |
} {2 abc def}
|
sl@0
|
116 |
test scan-4.6 {Tcl_ScanObjCmd, whitespace} {
|
sl@0
|
117 |
list [scan { abc def } { %s %s } x y] $x $y
|
sl@0
|
118 |
} {2 abc def}
|
sl@0
|
119 |
test scan-4.7 {Tcl_ScanObjCmd, literals} {
|
sl@0
|
120 |
# degenerate case, before changed from 8.2 to 8.3
|
sl@0
|
121 |
scan { abc def } { abc def }
|
sl@0
|
122 |
} {}
|
sl@0
|
123 |
test scan-4.8 {Tcl_ScanObjCmd, literals} {
|
sl@0
|
124 |
set x {}
|
sl@0
|
125 |
list [scan { abcg} { abc def %1s} x] $x
|
sl@0
|
126 |
} {0 {}}
|
sl@0
|
127 |
test scan-4.9 {Tcl_ScanObjCmd, literals} {
|
sl@0
|
128 |
list [scan { abc%defghi} { abc %% def%n } x] $x
|
sl@0
|
129 |
} {1 10}
|
sl@0
|
130 |
test scan-4.10 {Tcl_ScanObjCmd, assignment suppression} {
|
sl@0
|
131 |
list [scan { abc def } { %*c%s def } x] $x
|
sl@0
|
132 |
} {1 bc}
|
sl@0
|
133 |
test scan-4.11 {Tcl_ScanObjCmd, XPG3-style} {
|
sl@0
|
134 |
list [scan { abc def } {%2$s %1$s} x y] $x $y
|
sl@0
|
135 |
} {2 def abc}
|
sl@0
|
136 |
test scan-4.12 {Tcl_ScanObjCmd, width specifiers} {
|
sl@0
|
137 |
list [scan {abc123456789012} {%3s%3d%3f%3[0-9]%s} a b c d e] $a $b $c $d $e
|
sl@0
|
138 |
} {5 abc 123 456.0 789 012}
|
sl@0
|
139 |
test scan-4.13 {Tcl_ScanObjCmd, width specifiers} {
|
sl@0
|
140 |
list [scan {abc123456789012} {%3s%3d%3f%3[0-9]%s} a b c d e] $a $b $c $d $e
|
sl@0
|
141 |
} {5 abc 123 456.0 789 012}
|
sl@0
|
142 |
test scan-4.14 {Tcl_ScanObjCmd, underflow} {
|
sl@0
|
143 |
set x {}
|
sl@0
|
144 |
list [scan {a} {a%d} x] $x
|
sl@0
|
145 |
} {-1 {}}
|
sl@0
|
146 |
test scan-4.15 {Tcl_ScanObjCmd, underflow} {
|
sl@0
|
147 |
set x {}
|
sl@0
|
148 |
list [scan {} {a%d} x] $x
|
sl@0
|
149 |
} {-1 {}}
|
sl@0
|
150 |
test scan-4.16 {Tcl_ScanObjCmd, underflow} {
|
sl@0
|
151 |
set x {}
|
sl@0
|
152 |
list [scan {ab} {a%d} x] $x
|
sl@0
|
153 |
} {0 {}}
|
sl@0
|
154 |
test scan-4.17 {Tcl_ScanObjCmd, underflow} {
|
sl@0
|
155 |
set x {}
|
sl@0
|
156 |
list [scan {a } {a%d} x] $x
|
sl@0
|
157 |
} {-1 {}}
|
sl@0
|
158 |
test scan-4.18 {Tcl_ScanObjCmd, skipping whitespace} {
|
sl@0
|
159 |
list [scan { b} {%c%s} x y] $x $y
|
sl@0
|
160 |
} {2 32 b}
|
sl@0
|
161 |
test scan-4.19 {Tcl_ScanObjCmd, skipping whitespace} {
|
sl@0
|
162 |
list [scan { b} {%[^b]%s} x y] $x $y
|
sl@0
|
163 |
} {2 { } b}
|
sl@0
|
164 |
test scan-4.20 {Tcl_ScanObjCmd, string scanning} {
|
sl@0
|
165 |
list [scan {abc def} {%s} x] $x
|
sl@0
|
166 |
} {1 abc}
|
sl@0
|
167 |
test scan-4.21 {Tcl_ScanObjCmd, string scanning} {
|
sl@0
|
168 |
list [scan {abc def} {%0s} x] $x
|
sl@0
|
169 |
} {1 abc}
|
sl@0
|
170 |
test scan-4.22 {Tcl_ScanObjCmd, string scanning} {
|
sl@0
|
171 |
list [scan {abc def} {%2s} x] $x
|
sl@0
|
172 |
} {1 ab}
|
sl@0
|
173 |
test scan-4.23 {Tcl_ScanObjCmd, string scanning} {
|
sl@0
|
174 |
list [scan {abc def} {%*s%n} x] $x
|
sl@0
|
175 |
} {1 3}
|
sl@0
|
176 |
test scan-4.24 {Tcl_ScanObjCmd, charset scanning} {
|
sl@0
|
177 |
list [scan {abcdef} {%[a-c]} x] $x
|
sl@0
|
178 |
} {1 abc}
|
sl@0
|
179 |
test scan-4.25 {Tcl_ScanObjCmd, charset scanning} {
|
sl@0
|
180 |
list [scan {abcdef} {%0[a-c]} x] $x
|
sl@0
|
181 |
} {1 abc}
|
sl@0
|
182 |
test scan-4.26 {Tcl_ScanObjCmd, charset scanning} {
|
sl@0
|
183 |
list [scan {abcdef} {%2[a-c]} x] $x
|
sl@0
|
184 |
} {1 ab}
|
sl@0
|
185 |
test scan-4.27 {Tcl_ScanObjCmd, charset scanning} {
|
sl@0
|
186 |
list [scan {abcdef} {%*[a-c]%n} x] $x
|
sl@0
|
187 |
} {1 3}
|
sl@0
|
188 |
test scan-4.28 {Tcl_ScanObjCmd, character scanning} {
|
sl@0
|
189 |
list [scan {abcdef} {%c} x] $x
|
sl@0
|
190 |
} {1 97}
|
sl@0
|
191 |
test scan-4.29 {Tcl_ScanObjCmd, character scanning} {
|
sl@0
|
192 |
list [scan {abcdef} {%*c%n} x] $x
|
sl@0
|
193 |
} {1 1}
|
sl@0
|
194 |
|
sl@0
|
195 |
test scan-4.30 {Tcl_ScanObjCmd, base-10 integer scanning} {
|
sl@0
|
196 |
set x {}
|
sl@0
|
197 |
list [scan {1234567890a} {%3d} x] $x
|
sl@0
|
198 |
} {1 123}
|
sl@0
|
199 |
test scan-4.31 {Tcl_ScanObjCmd, base-10 integer scanning} {
|
sl@0
|
200 |
set x {}
|
sl@0
|
201 |
list [scan {1234567890a} {%d} x] $x
|
sl@0
|
202 |
} {1 1234567890}
|
sl@0
|
203 |
test scan-4.32 {Tcl_ScanObjCmd, base-10 integer scanning} {
|
sl@0
|
204 |
set x {}
|
sl@0
|
205 |
list [scan {01234567890a} {%d} x] $x
|
sl@0
|
206 |
} {1 1234567890}
|
sl@0
|
207 |
test scan-4.33 {Tcl_ScanObjCmd, base-10 integer scanning} {
|
sl@0
|
208 |
set x {}
|
sl@0
|
209 |
list [scan {+01234} {%d} x] $x
|
sl@0
|
210 |
} {1 1234}
|
sl@0
|
211 |
test scan-4.34 {Tcl_ScanObjCmd, base-10 integer scanning} {
|
sl@0
|
212 |
set x {}
|
sl@0
|
213 |
list [scan {-01234} {%d} x] $x
|
sl@0
|
214 |
} {1 -1234}
|
sl@0
|
215 |
test scan-4.35 {Tcl_ScanObjCmd, base-10 integer scanning} {
|
sl@0
|
216 |
set x {}
|
sl@0
|
217 |
list [scan {a01234} {%d} x] $x
|
sl@0
|
218 |
} {0 {}}
|
sl@0
|
219 |
test scan-4.36 {Tcl_ScanObjCmd, base-10 integer scanning} {
|
sl@0
|
220 |
set x {}
|
sl@0
|
221 |
list [scan {0x10} {%d} x] $x
|
sl@0
|
222 |
} {1 0}
|
sl@0
|
223 |
test scan-4.37 {Tcl_ScanObjCmd, base-8 integer scanning} {
|
sl@0
|
224 |
set x {}
|
sl@0
|
225 |
list [scan {012345678} {%o} x] $x
|
sl@0
|
226 |
} {1 342391}
|
sl@0
|
227 |
test scan-4.38 {Tcl_ScanObjCmd, base-8 integer scanning} {
|
sl@0
|
228 |
set x {}
|
sl@0
|
229 |
list [scan {+1238 -1239 123a} {%o%*s%o%*s%o} x y z] $x $y $z
|
sl@0
|
230 |
} {3 83 -83 83}
|
sl@0
|
231 |
test scan-4.39 {Tcl_ScanObjCmd, base-16 integer scanning} {
|
sl@0
|
232 |
set x {}
|
sl@0
|
233 |
list [scan {+1238 -123a 0123} {%x%x%x} x y z] $x $y $z
|
sl@0
|
234 |
} {3 4664 -4666 291}
|
sl@0
|
235 |
test scan-4.40 {Tcl_ScanObjCmd, base-16 integer scanning} {
|
sl@0
|
236 |
# The behavior changed in 8.4a4/8.3.4cvs (6 Feb) to correctly
|
sl@0
|
237 |
# return '1' for 0x1 scanned via %x, to comply with 8.0 and C scanf.
|
sl@0
|
238 |
# Bug #495213
|
sl@0
|
239 |
set x {}
|
sl@0
|
240 |
list [scan {aBcDeF AbCdEf 0x1} {%x%x%x} x y z] $x $y $z
|
sl@0
|
241 |
} {3 11259375 11259375 1}
|
sl@0
|
242 |
test scan-4.40.1 {Tcl_ScanObjCmd, base-16 integer scanning} {
|
sl@0
|
243 |
set x {}
|
sl@0
|
244 |
list [scan {0xF 0x00A0B 0X0XF} {%x %x %x} x y z] $x $y $z
|
sl@0
|
245 |
} {3 15 2571 0}
|
sl@0
|
246 |
test scan-4.40.2 {Tcl_ScanObjCmd, base-16 integer scanning} {
|
sl@0
|
247 |
catch {unset x}
|
sl@0
|
248 |
list [scan {xF} {%x} x] [info exists x]
|
sl@0
|
249 |
} {0 0}
|
sl@0
|
250 |
test scan-4.41 {Tcl_ScanObjCmd, base-unknown integer scanning} {
|
sl@0
|
251 |
set x {}
|
sl@0
|
252 |
list [scan {10 010 0x10} {%i%i%i} x y z] $x $y $z
|
sl@0
|
253 |
} {3 10 8 16}
|
sl@0
|
254 |
test scan-4.42 {Tcl_ScanObjCmd, base-unknown integer scanning} {
|
sl@0
|
255 |
set x {}
|
sl@0
|
256 |
list [scan {10 010 0X10} {%i%i%i} x y z] $x $y $z
|
sl@0
|
257 |
} {3 10 8 16}
|
sl@0
|
258 |
test scan-4.43 {Tcl_ScanObjCmd, integer scanning, odd cases} {
|
sl@0
|
259 |
set x {}
|
sl@0
|
260 |
list [scan {+ } {%i} x] $x
|
sl@0
|
261 |
} {0 {}}
|
sl@0
|
262 |
test scan-4.44 {Tcl_ScanObjCmd, integer scanning, odd cases} {
|
sl@0
|
263 |
set x {}
|
sl@0
|
264 |
list [scan {+} {%i} x] $x
|
sl@0
|
265 |
} {-1 {}}
|
sl@0
|
266 |
test scan-4.45 {Tcl_ScanObjCmd, integer scanning, odd cases} {
|
sl@0
|
267 |
set x {}
|
sl@0
|
268 |
list [scan {0x} {%i%s} x y] $x $y
|
sl@0
|
269 |
} {2 0 x}
|
sl@0
|
270 |
test scan-4.46 {Tcl_ScanObjCmd, integer scanning, odd cases} {
|
sl@0
|
271 |
set x {}
|
sl@0
|
272 |
list [scan {0X} {%i%s} x y] $x $y
|
sl@0
|
273 |
} {2 0 X}
|
sl@0
|
274 |
test scan-4.47 {Tcl_ScanObjCmd, integer scanning, suppressed} {
|
sl@0
|
275 |
set x {}
|
sl@0
|
276 |
list [scan {123def} {%*i%s} x] $x
|
sl@0
|
277 |
} {1 def}
|
sl@0
|
278 |
test scan-4.48 {Tcl_ScanObjCmd, float scanning} {
|
sl@0
|
279 |
list [scan {1 2 3} {%e %f %g} x y z] $x $y $z
|
sl@0
|
280 |
} {3 1.0 2.0 3.0}
|
sl@0
|
281 |
test scan-4.49 {Tcl_ScanObjCmd, float scanning} {
|
sl@0
|
282 |
list [scan {.1 0.2 3.} {%e %f %g} x y z] $x $y $z
|
sl@0
|
283 |
} {3 0.1 0.2 3.0}
|
sl@0
|
284 |
test scan-4.50 {Tcl_ScanObjCmd, float scanning} {
|
sl@0
|
285 |
list [scan {1234567890a} %f x] $x
|
sl@0
|
286 |
} {1 1234567890.0}
|
sl@0
|
287 |
test scan-4.51 {Tcl_ScanObjCmd, float scanning} {
|
sl@0
|
288 |
list [scan {+123+45} %f x] $x
|
sl@0
|
289 |
} {1 123.0}
|
sl@0
|
290 |
test scan-4.52 {Tcl_ScanObjCmd, float scanning} {
|
sl@0
|
291 |
list [scan {-123+45} %f x] $x
|
sl@0
|
292 |
} {1 -123.0}
|
sl@0
|
293 |
test scan-4.53 {Tcl_ScanObjCmd, float scanning} {
|
sl@0
|
294 |
list [scan {1.0e1} %f x] $x
|
sl@0
|
295 |
} {1 10.0}
|
sl@0
|
296 |
test scan-4.54 {Tcl_ScanObjCmd, float scanning} {
|
sl@0
|
297 |
list [scan {1.0e-1} %f x] $x
|
sl@0
|
298 |
} {1 0.1}
|
sl@0
|
299 |
test scan-4.55 {Tcl_ScanObjCmd, odd cases} {
|
sl@0
|
300 |
set x {}
|
sl@0
|
301 |
list [scan {+} %f x] $x
|
sl@0
|
302 |
} {-1 {}}
|
sl@0
|
303 |
test scan-4.56 {Tcl_ScanObjCmd, odd cases} {
|
sl@0
|
304 |
set x {}
|
sl@0
|
305 |
list [scan {1.0e} %f%s x y] $x $y
|
sl@0
|
306 |
} {2 1.0 e}
|
sl@0
|
307 |
test scan-4.57 {Tcl_ScanObjCmd, odd cases} {
|
sl@0
|
308 |
set x {}
|
sl@0
|
309 |
list [scan {1.0e+} %f%s x y] $x $y
|
sl@0
|
310 |
} {2 1.0 e+}
|
sl@0
|
311 |
test scan-4.58 {Tcl_ScanObjCmd, odd cases} {
|
sl@0
|
312 |
set x {}
|
sl@0
|
313 |
set y {}
|
sl@0
|
314 |
list [scan {e1} %f%s x y] $x $y
|
sl@0
|
315 |
} {0 {} {}}
|
sl@0
|
316 |
test scan-4.59 {Tcl_ScanObjCmd, float scanning} {
|
sl@0
|
317 |
list [scan {1.0e-1x} %*f%n x] $x
|
sl@0
|
318 |
} {1 6}
|
sl@0
|
319 |
|
sl@0
|
320 |
test scan-4.60 {Tcl_ScanObjCmd, set errors} {
|
sl@0
|
321 |
set x {}
|
sl@0
|
322 |
set y {}
|
sl@0
|
323 |
catch {unset z}; array set z {}
|
sl@0
|
324 |
set result [list [catch {scan {abc def ghi} {%s%s%s} x z y} msg] \
|
sl@0
|
325 |
$msg $x $y]
|
sl@0
|
326 |
unset z
|
sl@0
|
327 |
set result
|
sl@0
|
328 |
} {1 {couldn't set variable "z"} abc ghi}
|
sl@0
|
329 |
test scan-4.61 {Tcl_ScanObjCmd, set errors} {
|
sl@0
|
330 |
set x {}
|
sl@0
|
331 |
catch {unset y}; array set y {}
|
sl@0
|
332 |
catch {unset z}; array set z {}
|
sl@0
|
333 |
set result [list [catch {scan {abc def ghi} {%s%s%s} x z y} msg] \
|
sl@0
|
334 |
$msg $x]
|
sl@0
|
335 |
unset y
|
sl@0
|
336 |
unset z
|
sl@0
|
337 |
set result
|
sl@0
|
338 |
} {1 {couldn't set variable "z"couldn't set variable "y"} abc}
|
sl@0
|
339 |
|
sl@0
|
340 |
# procedure that returns the range of integers
|
sl@0
|
341 |
|
sl@0
|
342 |
proc int_range {} {
|
sl@0
|
343 |
for { set MIN_INT 1 } { $MIN_INT > 0 } {} {
|
sl@0
|
344 |
set MIN_INT [expr { $MIN_INT << 1 }]
|
sl@0
|
345 |
}
|
sl@0
|
346 |
set MAX_INT [expr { ~ $MIN_INT }]
|
sl@0
|
347 |
return [list $MIN_INT $MAX_INT]
|
sl@0
|
348 |
}
|
sl@0
|
349 |
|
sl@0
|
350 |
test scan-4.62 {scanning of large and negative octal integers} {
|
sl@0
|
351 |
foreach { MIN_INT MAX_INT } [int_range] {}
|
sl@0
|
352 |
set scanstring [format {%o %o %o} -1 $MIN_INT $MAX_INT]
|
sl@0
|
353 |
list [scan $scanstring {%o %o %o} a b c] \
|
sl@0
|
354 |
[expr { $a == -1 }] [expr { $b == $MIN_INT }] [expr { $c == $MAX_INT }]
|
sl@0
|
355 |
} {3 1 1 1}
|
sl@0
|
356 |
test scan-4.63 {scanning of large and negative hex integers} {
|
sl@0
|
357 |
foreach { MIN_INT MAX_INT } [int_range] {}
|
sl@0
|
358 |
set scanstring [format {%x %x %x} -1 $MIN_INT $MAX_INT]
|
sl@0
|
359 |
list [scan $scanstring {%x %x %x} a b c] \
|
sl@0
|
360 |
[expr { $a == -1 }] [expr { $b == $MIN_INT }] [expr { $c == $MAX_INT }]
|
sl@0
|
361 |
} {3 1 1 1}
|
sl@0
|
362 |
|
sl@0
|
363 |
# clean up from last two tests
|
sl@0
|
364 |
|
sl@0
|
365 |
catch {
|
sl@0
|
366 |
rename int_range {}
|
sl@0
|
367 |
}
|
sl@0
|
368 |
|
sl@0
|
369 |
test scan-5.1 {integer scanning} {
|
sl@0
|
370 |
set a {}; set b {}; set c {}; set d {}
|
sl@0
|
371 |
list [scan "-20 1476 \n33 0" "%d %d %d %d" a b c d] $a $b $c $d
|
sl@0
|
372 |
} {4 -20 1476 33 0}
|
sl@0
|
373 |
test scan-5.2 {integer scanning} {
|
sl@0
|
374 |
set a {}; set b {}; set c {}
|
sl@0
|
375 |
list [scan "-45 16 7890 +10" "%2d %*d %10d %d" a b c] $a $b $c
|
sl@0
|
376 |
} {3 -4 16 7890}
|
sl@0
|
377 |
test scan-5.3 {integer scanning} {
|
sl@0
|
378 |
set a {}; set b {}; set c {}; set d {}
|
sl@0
|
379 |
list [scan "-45 16 +10 987" "%ld %d %ld %d" a b c d] $a $b $c $d
|
sl@0
|
380 |
} {4 -45 16 10 987}
|
sl@0
|
381 |
test scan-5.4 {integer scanning} {
|
sl@0
|
382 |
set a {}; set b {}; set c {}; set d {}
|
sl@0
|
383 |
list [scan "14 1ab 62 10" "%d %x %lo %x" a b c d] $a $b $c $d
|
sl@0
|
384 |
} {4 14 427 50 16}
|
sl@0
|
385 |
test scan-5.5 {integer scanning} {
|
sl@0
|
386 |
set a {}; set b {}; set c {}; set d {}
|
sl@0
|
387 |
list [scan "12345670 1234567890ab cdefg" "%o %o %x %lx" a b c d] \
|
sl@0
|
388 |
$a $b $c $d
|
sl@0
|
389 |
} {4 2739128 342391 561323 52719}
|
sl@0
|
390 |
test scan-5.6 {integer scanning} {
|
sl@0
|
391 |
set a {}; set b {}; set c {}; set d {}
|
sl@0
|
392 |
list [scan "ab123-24642" "%2x %3x %3o %2o" a b c d] $a $b $c $d
|
sl@0
|
393 |
} {4 171 291 -20 52}
|
sl@0
|
394 |
test scan-5.7 {integer scanning} {
|
sl@0
|
395 |
set a {}; set b {}
|
sl@0
|
396 |
list [scan "1234567 234 567 " "%*3x %x %*o %4o" a b] $a $b
|
sl@0
|
397 |
} {2 17767 375}
|
sl@0
|
398 |
test scan-5.8 {integer scanning} {
|
sl@0
|
399 |
set a {}; set b {}
|
sl@0
|
400 |
list [scan "a 1234" "%d %d" a b] $a $b
|
sl@0
|
401 |
} {0 {} {}}
|
sl@0
|
402 |
test scan-5.9 {integer scanning} {
|
sl@0
|
403 |
set a {}; set b {}; set c {}; set d {};
|
sl@0
|
404 |
list [scan "12345678" "%2d %2d %2ld %2d" a b c d] $a $b $c $d
|
sl@0
|
405 |
} {4 12 34 56 78}
|
sl@0
|
406 |
test scan-5.10 {integer scanning} {
|
sl@0
|
407 |
set a {}; set b {}; set c {}; set d {}
|
sl@0
|
408 |
list [scan "1 2 " "%hd %d %d %d" a b c d] $a $b $c $d
|
sl@0
|
409 |
} {2 1 2 {} {}}
|
sl@0
|
410 |
#
|
sl@0
|
411 |
# The behavior for scaning intergers larger than MAX_INT is
|
sl@0
|
412 |
# not defined by the ANSI spec. Some implementations wrap the
|
sl@0
|
413 |
# input (-16) some return MAX_INT.
|
sl@0
|
414 |
#
|
sl@0
|
415 |
test scan-5.11 {integer scanning} {nonPortable} {
|
sl@0
|
416 |
set a {}; set b {};
|
sl@0
|
417 |
list [scan "4294967280 4294967280" "%u %d" a b] $a \
|
sl@0
|
418 |
[expr {$b == -16 || $b == 0x7fffffff}]
|
sl@0
|
419 |
} {2 4294967280 1}
|
sl@0
|
420 |
test scan-5.12 {integer scanning} {64bitInts} {
|
sl@0
|
421 |
set a {}; set b {}; set c {}
|
sl@0
|
422 |
list [scan "7810179016327718216,6c63546f6c6c6548,661432506755433062510" \
|
sl@0
|
423 |
%ld,%lx,%lo a b c] $a $b $c
|
sl@0
|
424 |
} {3 7810179016327718216 7810179016327718216 7810179016327718216}
|
sl@0
|
425 |
test scan-5.13 {integer scanning and overflow} {
|
sl@0
|
426 |
# This test used to fail on some 64-bit systems. [Bug 1011860]
|
sl@0
|
427 |
scan {300000000 3000000000 30000000000} {%ld %ld %ld}
|
sl@0
|
428 |
} {300000000 3000000000 30000000000}
|
sl@0
|
429 |
|
sl@0
|
430 |
test scan-6.1 {floating-point scanning} {
|
sl@0
|
431 |
set a {}; set b {}; set c {}; set d {}
|
sl@0
|
432 |
list [scan "2.1 -3.0e8 .99962 a" "%f%g%e%f" a b c d] $a $b $c $d
|
sl@0
|
433 |
} {3 2.1 -300000000.0 0.99962 {}}
|
sl@0
|
434 |
test scan-6.2 {floating-point scanning} {
|
sl@0
|
435 |
set a {}; set b {}; set c {}; set d {}
|
sl@0
|
436 |
list [scan "-1.2345 +8.2 9" "%3e %3lf %f %f" a b c d] $a $b $c $d
|
sl@0
|
437 |
} {4 -1.0 234.0 5.0 8.2}
|
sl@0
|
438 |
test scan-6.3 {floating-point scanning} {
|
sl@0
|
439 |
set a {}; set b {}; set c {}
|
sl@0
|
440 |
list [scan "1e00004 332E-4 3e+4" "%Lf %*2e %f %f" a b c] $a $c
|
sl@0
|
441 |
} {3 10000.0 30000.0}
|
sl@0
|
442 |
#
|
sl@0
|
443 |
# Some libc implementations consider 3.e- bad input. The ANSI
|
sl@0
|
444 |
# spec states that digits must follow the - sign.
|
sl@0
|
445 |
#
|
sl@0
|
446 |
test scan-6.4 {floating-point scanning} {
|
sl@0
|
447 |
set a {}; set b {}; set c {}
|
sl@0
|
448 |
list [scan "1. 47.6 2.e2 3.e-" "%f %*f %f %f" a b c] $a $b $c
|
sl@0
|
449 |
} {3 1.0 200.0 3.0}
|
sl@0
|
450 |
test scan-6.5 {floating-point scanning} {
|
sl@0
|
451 |
set a {}; set b {}; set c {}; set d {}
|
sl@0
|
452 |
list [scan "4.6 99999.7 876.43e-1 118" "%f %f %f %e" a b c d] $a $b $c $d
|
sl@0
|
453 |
} {4 4.6 99999.7 87.643 118.0}
|
sl@0
|
454 |
test scan-6.6 {floating-point scanning} {eformat} {
|
sl@0
|
455 |
set a {}; set b {}; set c {}; set d {}
|
sl@0
|
456 |
list [scan "1.2345 697.0e-3 124 .00005" "%f %e %f %e" a b c d] $a $b $c $d
|
sl@0
|
457 |
} {4 1.2345 0.697 124.0 5e-05}
|
sl@0
|
458 |
test scan-6.7 {floating-point scanning} {
|
sl@0
|
459 |
set a {}; set b {}; set c {}; set d {}
|
sl@0
|
460 |
list [scan "4.6abc" "%f %f %f %f" a b c d] $a $b $c $d
|
sl@0
|
461 |
} {1 4.6 {} {} {}}
|
sl@0
|
462 |
test scan-6.8 {floating-point scanning} {
|
sl@0
|
463 |
set a {}; set b {}; set c {}; set d {}
|
sl@0
|
464 |
list [scan "4.6 5.2" "%f %f %f %f" a b c d] $a $b $c $d
|
sl@0
|
465 |
} {2 4.6 5.2 {} {}}
|
sl@0
|
466 |
|
sl@0
|
467 |
test scan-7.1 {string and character scanning} {
|
sl@0
|
468 |
set a {}; set b {}; set c {}; set d {}
|
sl@0
|
469 |
list [scan "abc defghijk dum " "%s %3s %20s %s" a b c d] $a $b $c $d
|
sl@0
|
470 |
} {4 abc def ghijk dum}
|
sl@0
|
471 |
test scan-7.2 {string and character scanning} {
|
sl@0
|
472 |
set a {}; set b {}; set c {}; set d {}
|
sl@0
|
473 |
list [scan "a bcdef" "%c%c%1s %s" a b c d] $a $b $c $d
|
sl@0
|
474 |
} {4 97 32 b cdef}
|
sl@0
|
475 |
test scan-7.3 {string and character scanning} {
|
sl@0
|
476 |
set a {}; set b {}; set c {}
|
sl@0
|
477 |
list [scan "123456 test " "%*c%*s %s %s %s" a b c] $a $b $c
|
sl@0
|
478 |
} {1 test {} {}}
|
sl@0
|
479 |
test scan-7.4 {string and character scanning} {
|
sl@0
|
480 |
set a {}; set b {}; set c {}; set d
|
sl@0
|
481 |
list [scan "ababcd01234 f 123450" {%4[abcd] %4[abcd] %[^abcdef] %[^0]} a b c d] $a $b $c $d
|
sl@0
|
482 |
} {4 abab cd {01234 } {f 12345}}
|
sl@0
|
483 |
test scan-7.5 {string and character scanning} {
|
sl@0
|
484 |
set a {}; set b {}; set c {}
|
sl@0
|
485 |
list [scan "aaaaaabc aaabcdefg + + XYZQR" {%*4[a] %s %*4[a]%s%*4[ +]%c} a b c] $a $b $c
|
sl@0
|
486 |
} {3 aabc bcdefg 43}
|
sl@0
|
487 |
test scan-7.6 {string and character scanning, unicode} {
|
sl@0
|
488 |
set a {}; set b {}; set c {}; set d {}
|
sl@0
|
489 |
list [scan "abc d\u00c7fghijk dum " "%s %3s %20s %s" a b c d] $a $b $c $d
|
sl@0
|
490 |
} "4 abc d\u00c7f ghijk dum"
|
sl@0
|
491 |
test scan-7.7 {string and character scanning, unicode} {
|
sl@0
|
492 |
set a {}; set b {}
|
sl@0
|
493 |
list [scan "ab\u00c7cdef" "ab%c%c" a b] $a $b
|
sl@0
|
494 |
} "2 199 99"
|
sl@0
|
495 |
test scan-7.8 {string and character scanning, unicode} {
|
sl@0
|
496 |
set a {}; set b {}
|
sl@0
|
497 |
list [scan "ab\ufeffdef" "%\[ab\ufeff\]" a] $a
|
sl@0
|
498 |
} "1 ab\ufeff"
|
sl@0
|
499 |
|
sl@0
|
500 |
test scan-8.1 {error conditions} {
|
sl@0
|
501 |
catch {scan a}
|
sl@0
|
502 |
} 1
|
sl@0
|
503 |
test scan-8.2 {error conditions} {
|
sl@0
|
504 |
catch {scan a} msg
|
sl@0
|
505 |
set msg
|
sl@0
|
506 |
} {wrong # args: should be "scan string format ?varName varName ...?"}
|
sl@0
|
507 |
test scan-8.3 {error conditions} {
|
sl@0
|
508 |
list [catch {scan a %D x} msg] $msg
|
sl@0
|
509 |
} {1 {bad scan conversion character "D"}}
|
sl@0
|
510 |
test scan-8.4 {error conditions} {
|
sl@0
|
511 |
list [catch {scan a %O x} msg] $msg
|
sl@0
|
512 |
} {1 {bad scan conversion character "O"}}
|
sl@0
|
513 |
test scan-8.5 {error conditions} {
|
sl@0
|
514 |
list [catch {scan a %X x} msg] $msg
|
sl@0
|
515 |
} {1 {bad scan conversion character "X"}}
|
sl@0
|
516 |
test scan-8.6 {error conditions} {
|
sl@0
|
517 |
list [catch {scan a %F x} msg] $msg
|
sl@0
|
518 |
} {1 {bad scan conversion character "F"}}
|
sl@0
|
519 |
test scan-8.7 {error conditions} {
|
sl@0
|
520 |
list [catch {scan a %E x} msg] $msg
|
sl@0
|
521 |
} {1 {bad scan conversion character "E"}}
|
sl@0
|
522 |
test scan-8.8 {error conditions} {
|
sl@0
|
523 |
list [catch {scan a "%d %d" a} msg] $msg
|
sl@0
|
524 |
} {1 {different numbers of variable names and field specifiers}}
|
sl@0
|
525 |
test scan-8.9 {error conditions} {
|
sl@0
|
526 |
list [catch {scan a "%d %d" a b c} msg] $msg
|
sl@0
|
527 |
} {1 {variable is not assigned by any conversion specifiers}}
|
sl@0
|
528 |
test scan-8.10 {error conditions} {
|
sl@0
|
529 |
set a {}; set b {}; set c {}; set d {}
|
sl@0
|
530 |
list [expr {[scan " a" " a %d %d %d %d" a b c d] <= 0}] $a $b $c $d
|
sl@0
|
531 |
} {1 {} {} {} {}}
|
sl@0
|
532 |
test scan-8.11 {error conditions} {
|
sl@0
|
533 |
set a {}; set b {}; set c {}; set d {}
|
sl@0
|
534 |
list [scan "1 2" "%d %d %d %d" a b c d] $a $b $c $d
|
sl@0
|
535 |
} {2 1 2 {} {}}
|
sl@0
|
536 |
test scan-8.12 {error conditions} {
|
sl@0
|
537 |
catch {unset a}
|
sl@0
|
538 |
set a(0) 44
|
sl@0
|
539 |
list [catch {scan 44 %d a} msg] $msg
|
sl@0
|
540 |
} {1 {couldn't set variable "a"}}
|
sl@0
|
541 |
test scan-8.13 {error conditions} {
|
sl@0
|
542 |
catch {unset a}
|
sl@0
|
543 |
set a(0) 44
|
sl@0
|
544 |
list [catch {scan 44 %c a} msg] $msg
|
sl@0
|
545 |
} {1 {couldn't set variable "a"}}
|
sl@0
|
546 |
test scan-8.14 {error conditions} {
|
sl@0
|
547 |
catch {unset a}
|
sl@0
|
548 |
set a(0) 44
|
sl@0
|
549 |
list [catch {scan 44 %s a} msg] $msg
|
sl@0
|
550 |
} {1 {couldn't set variable "a"}}
|
sl@0
|
551 |
test scan-8.15 {error conditions} {
|
sl@0
|
552 |
catch {unset a}
|
sl@0
|
553 |
set a(0) 44
|
sl@0
|
554 |
list [catch {scan 44 %f a} msg] $msg
|
sl@0
|
555 |
} {1 {couldn't set variable "a"}}
|
sl@0
|
556 |
test scan-8.16 {error conditions} {
|
sl@0
|
557 |
catch {unset a}
|
sl@0
|
558 |
set a(0) 44
|
sl@0
|
559 |
list [catch {scan 44 %f a} msg] $msg
|
sl@0
|
560 |
} {1 {couldn't set variable "a"}}
|
sl@0
|
561 |
catch {unset a}
|
sl@0
|
562 |
test scan-8.17 {error conditions} {
|
sl@0
|
563 |
list [catch {scan 44 %2c a} msg] $msg
|
sl@0
|
564 |
} {1 {field width may not be specified in %c conversion}}
|
sl@0
|
565 |
test scan-8.18 {error conditions} {
|
sl@0
|
566 |
list [catch {scan abc {%[} x} msg] $msg
|
sl@0
|
567 |
} {1 {unmatched [ in format string}}
|
sl@0
|
568 |
test scan-8.19 {error conditions} {
|
sl@0
|
569 |
list [catch {scan abc {%[^a} x} msg] $msg
|
sl@0
|
570 |
} {1 {unmatched [ in format string}}
|
sl@0
|
571 |
test scan-8.20 {error conditions} {
|
sl@0
|
572 |
list [catch {scan abc {%[^]a} x} msg] $msg
|
sl@0
|
573 |
} {1 {unmatched [ in format string}}
|
sl@0
|
574 |
test scan-8.21 {error conditions} {
|
sl@0
|
575 |
list [catch {scan abc {%[]a} x} msg] $msg
|
sl@0
|
576 |
} {1 {unmatched [ in format string}}
|
sl@0
|
577 |
|
sl@0
|
578 |
test scan-9.1 {lots of arguments} {
|
sl@0
|
579 |
scan "10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200" "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d" a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20
|
sl@0
|
580 |
} 20
|
sl@0
|
581 |
test scan-9.2 {lots of arguments} {
|
sl@0
|
582 |
scan "10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200" "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d" a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20
|
sl@0
|
583 |
set a20
|
sl@0
|
584 |
} 200
|
sl@0
|
585 |
|
sl@0
|
586 |
test scan-10.1 {miscellaneous tests} {
|
sl@0
|
587 |
set a {}
|
sl@0
|
588 |
list [scan ab16c ab%dc a] $a
|
sl@0
|
589 |
} {1 16}
|
sl@0
|
590 |
test scan-10.2 {miscellaneous tests} {
|
sl@0
|
591 |
set a {}
|
sl@0
|
592 |
list [scan ax16c ab%dc a] $a
|
sl@0
|
593 |
} {0 {}}
|
sl@0
|
594 |
test scan-10.3 {miscellaneous tests} {
|
sl@0
|
595 |
set a {}
|
sl@0
|
596 |
list [catch {scan ab%c114 ab%%c%d a} msg] $msg $a
|
sl@0
|
597 |
} {0 1 114}
|
sl@0
|
598 |
test scan-10.4 {miscellaneous tests} {
|
sl@0
|
599 |
set a {}
|
sl@0
|
600 |
list [catch {scan ab%c14 ab%%c%d a} msg] $msg $a
|
sl@0
|
601 |
} {0 1 14}
|
sl@0
|
602 |
test scan-10.5 {miscellaneous tests} {
|
sl@0
|
603 |
catch {unset arr}
|
sl@0
|
604 |
set arr(2) {}
|
sl@0
|
605 |
list [catch {scan ab%c14 ab%%c%d arr(2)} msg] $msg $arr(2)
|
sl@0
|
606 |
} {0 1 14}
|
sl@0
|
607 |
|
sl@0
|
608 |
test scan-11.1 {alignment in results array (TCL_ALIGN)} {
|
sl@0
|
609 |
scan "123 13.6" "%s %f" a b
|
sl@0
|
610 |
set b
|
sl@0
|
611 |
} 13.6
|
sl@0
|
612 |
test scan-11.2 {alignment in results array (TCL_ALIGN)} {
|
sl@0
|
613 |
scan "1234567 13.6" "%s %f" a b
|
sl@0
|
614 |
set b
|
sl@0
|
615 |
} 13.6
|
sl@0
|
616 |
test scan-11.3 {alignment in results array (TCL_ALIGN)} {
|
sl@0
|
617 |
scan "12345678901 13.6" "%s %f" a b
|
sl@0
|
618 |
set b
|
sl@0
|
619 |
} 13.6
|
sl@0
|
620 |
test scan-11.4 {alignment in results array (TCL_ALIGN)} {
|
sl@0
|
621 |
scan "123456789012345 13.6" "%s %f" a b
|
sl@0
|
622 |
set b
|
sl@0
|
623 |
} 13.6
|
sl@0
|
624 |
test scan-11.5 {alignment in results array (TCL_ALIGN)} {
|
sl@0
|
625 |
scan "1234567890123456789 13.6" "%s %f" a b
|
sl@0
|
626 |
set b
|
sl@0
|
627 |
} 13.6
|
sl@0
|
628 |
|
sl@0
|
629 |
test scan-12.1 {Tcl_ScanObjCmd, inline case} {
|
sl@0
|
630 |
scan a %c
|
sl@0
|
631 |
} 97
|
sl@0
|
632 |
test scan-12.2 {Tcl_ScanObjCmd, inline case} {
|
sl@0
|
633 |
scan abc %c%c%c%c
|
sl@0
|
634 |
} {97 98 99 {}}
|
sl@0
|
635 |
test scan-12.3 {Tcl_ScanObjCmd, inline case} {
|
sl@0
|
636 |
scan abc %s%c
|
sl@0
|
637 |
} {abc {}}
|
sl@0
|
638 |
test scan-12.4 {Tcl_ScanObjCmd, inline case, underflow} {
|
sl@0
|
639 |
scan abc abc%c
|
sl@0
|
640 |
} {}
|
sl@0
|
641 |
test scan-12.5 {Tcl_ScanObjCmd, inline case} {
|
sl@0
|
642 |
scan abc bogus%c%c%c
|
sl@0
|
643 |
} {{} {} {}}
|
sl@0
|
644 |
test scan-12.6 {Tcl_ScanObjCmd, inline case} {
|
sl@0
|
645 |
# degenerate case, behavior changed from 8.2 to 8.3
|
sl@0
|
646 |
list [catch {scan foo foobar} msg] $msg
|
sl@0
|
647 |
} {0 {}}
|
sl@0
|
648 |
test scan-12.7 {Tcl_ScanObjCmd, inline case lots of arguments} {
|
sl@0
|
649 |
scan "10 20 30 40 50 60 70 80 90 100 110 120 130 140\
|
sl@0
|
650 |
150 160 170 180 190 200" \
|
sl@0
|
651 |
"%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d"
|
sl@0
|
652 |
} {10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 {}}
|
sl@0
|
653 |
|
sl@0
|
654 |
test scan-13.1 {Tcl_ScanObjCmd, inline XPG case} {
|
sl@0
|
655 |
scan a {%1$c}
|
sl@0
|
656 |
} 97
|
sl@0
|
657 |
test scan-13.2 {Tcl_ScanObjCmd, inline XPG case} {
|
sl@0
|
658 |
scan abc {%1$c%2$c%3$c%4$c}
|
sl@0
|
659 |
} {97 98 99 {}}
|
sl@0
|
660 |
test scan-13.3 {Tcl_ScanObjCmd, inline XPG case} {
|
sl@0
|
661 |
list [catch {scan abc {%1$c%1$c}} msg] $msg
|
sl@0
|
662 |
} {1 {variable is assigned by multiple "%n$" conversion specifiers}}
|
sl@0
|
663 |
test scan-13.4 {Tcl_ScanObjCmd, inline XPG case} {
|
sl@0
|
664 |
scan abc {%2$s%1$c}
|
sl@0
|
665 |
} {{} abc}
|
sl@0
|
666 |
test scan-13.5 {Tcl_ScanObjCmd, inline XPG case, underflow} {
|
sl@0
|
667 |
scan abc {abc%5$c}
|
sl@0
|
668 |
} {}
|
sl@0
|
669 |
test scan-13.6 {Tcl_ScanObjCmd, inline XPG case} {
|
sl@0
|
670 |
catch {scan abc {bogus%1$c%5$c%10$c}} msg
|
sl@0
|
671 |
list [llength $msg] $msg
|
sl@0
|
672 |
} {10 {{} {} {} {} {} {} {} {} {} {}}}
|
sl@0
|
673 |
test scan-13.7 {Tcl_ScanObjCmd, inline XPG case lots of arguments} {
|
sl@0
|
674 |
scan "10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200" {%20$d %18$d %17$d %16$d %15$d %14$d %13$d %12$d %11$d %10$d %9$d %8$d %7$d %6$d %5$d %4$d %3$d %2$d %1$d}
|
sl@0
|
675 |
} {190 180 170 160 150 140 130 120 110 100 90 80 70 60 50 40 30 20 {} 10}
|
sl@0
|
676 |
test scan-13.8 {Tcl_ScanObjCmd, inline XPG case lots of arguments} {
|
sl@0
|
677 |
set msg [scan "10 20 30" {%100$d %5$d %200$d}]
|
sl@0
|
678 |
list [llength $msg] [lindex $msg 99] [lindex $msg 4] [lindex $msg 199]
|
sl@0
|
679 |
} {200 10 20 30}
|
sl@0
|
680 |
|
sl@0
|
681 |
# cleanup
|
sl@0
|
682 |
::tcltest::cleanupTests
|
sl@0
|
683 |
return
|