os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/binary.test
Update contrib.
1 # This file tests the tclBinary.c file and the "binary" Tcl command.
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.
7 # Copyright (c) 1997 by Sun Microsystems, Inc.
8 # Copyright (c) 1998-1999 by Scriptics Corporation.
10 # See the file "license.terms" for information on usage and redistribution
11 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13 # RCS: @(#) $Id: binary.test,v 1.11.2.4 2006/04/05 15:17:06 dgp Exp $
15 if {[lsearch [namespace children] ::tcltest] == -1} {
16 package require tcltest
17 namespace import -force ::tcltest::*
20 test binary-0.1 {DupByteArrayInternalRep} {
21 set hdr [binary format cc 0 0316]
30 test binary-1.1 {Tcl_BinaryObjCmd: bad args} {
31 list [catch {binary} msg] $msg
32 } {1 {wrong # args: should be "binary option ?arg arg ...?"}}
33 test binary-1.2 {Tcl_BinaryObjCmd: bad args} {
34 list [catch {binary foo} msg] $msg
35 } {1 {bad option "foo": must be format or scan}}
37 test binary-1.3 {Tcl_BinaryObjCmd: format error} {
38 list [catch {binary f} msg] $msg
39 } {1 {wrong # args: should be "binary format formatString ?arg arg ...?"}}
40 test binary-1.4 {Tcl_BinaryObjCmd: format} {
45 test binary-2.1 {Tcl_BinaryObjCmd: format} {
46 list [catch {binary format a } msg] $msg
47 } {1 {not enough arguments for all format specifiers}}
48 test binary-2.2 {Tcl_BinaryObjCmd: format} {
51 test binary-2.3 {Tcl_BinaryObjCmd: format} {
54 test binary-2.4 {Tcl_BinaryObjCmd: format} {
57 test binary-2.5 {Tcl_BinaryObjCmd: format} {
60 test binary-2.6 {Tcl_BinaryObjCmd: format} {
63 test binary-2.7 {Tcl_BinaryObjCmd: format} {
64 binary format a*a3 foobarbaz blat
66 test binary-2.8 {Tcl_BinaryObjCmd: format} {
67 binary format a*X3a2 foobar x
70 test binary-3.1 {Tcl_BinaryObjCmd: format} {
71 list [catch {binary format A} msg] $msg
72 } {1 {not enough arguments for all format specifiers}}
73 test binary-3.2 {Tcl_BinaryObjCmd: format} {
76 test binary-3.3 {Tcl_BinaryObjCmd: format} {
79 test binary-3.4 {Tcl_BinaryObjCmd: format} {
82 test binary-3.5 {Tcl_BinaryObjCmd: format} {
85 test binary-3.6 {Tcl_BinaryObjCmd: format} {
88 test binary-3.7 {Tcl_BinaryObjCmd: format} {
89 binary format A*A3 foobarbaz blat
91 test binary-3.8 {Tcl_BinaryObjCmd: format} {
92 binary format A*X3A2 foobar x
95 test binary-4.1 {Tcl_BinaryObjCmd: format} {
96 list [catch {binary format B} msg] $msg
97 } {1 {not enough arguments for all format specifiers}}
98 test binary-4.2 {Tcl_BinaryObjCmd: format} {
101 test binary-4.3 {Tcl_BinaryObjCmd: format} {
104 test binary-4.4 {Tcl_BinaryObjCmd: format} {
105 binary format B* 010011
107 test binary-4.5 {Tcl_BinaryObjCmd: format} {
108 binary format B8 01001101
110 test binary-4.6 {Tcl_BinaryObjCmd: format} {
111 binary format A2X2B9 oo 01001101
113 test binary-4.7 {Tcl_BinaryObjCmd: format} {
114 binary format B9 010011011010
116 test binary-4.8 {Tcl_BinaryObjCmd: format} {
117 binary format B2B3 10 010
119 test binary-4.9 {Tcl_BinaryObjCmd: format} {
120 list [catch {binary format B1B5 1 foo} msg] $msg
121 } {1 {expected binary string but got "foo" instead}}
123 test binary-5.1 {Tcl_BinaryObjCmd: format} {
124 list [catch {binary format b} msg] $msg
125 } {1 {not enough arguments for all format specifiers}}
126 test binary-5.2 {Tcl_BinaryObjCmd: format} {
129 test binary-5.3 {Tcl_BinaryObjCmd: format} {
132 test binary-5.4 {Tcl_BinaryObjCmd: format} {
133 binary format b* 010011
135 test binary-5.5 {Tcl_BinaryObjCmd: format} {
136 binary format b8 01001101
138 test binary-5.6 {Tcl_BinaryObjCmd: format} {
139 binary format A2X2b9 oo 01001101
141 test binary-5.7 {Tcl_BinaryObjCmd: format} {
142 binary format b9 010011011010
144 test binary-5.8 {Tcl_BinaryObjCmd: format} {
147 test binary-5.9 {Tcl_BinaryObjCmd: format} {
148 binary format b2b3 10 010
150 test binary-5.10 {Tcl_BinaryObjCmd: format} {
151 list [catch {binary format b1b5 1 foo} msg] $msg
152 } {1 {expected binary string but got "foo" instead}}
154 test binary-6.1 {Tcl_BinaryObjCmd: format} {
155 list [catch {binary format h} msg] $msg
156 } {1 {not enough arguments for all format specifiers}}
157 test binary-6.2 {Tcl_BinaryObjCmd: format} {
160 test binary-6.3 {Tcl_BinaryObjCmd: format} {
163 test binary-6.4 {Tcl_BinaryObjCmd: format} {
166 test binary-6.5 {Tcl_BinaryObjCmd: format} {
167 binary format h* baadf00d
169 test binary-6.6 {Tcl_BinaryObjCmd: format} {
170 binary format h4 c410
172 test binary-6.7 {Tcl_BinaryObjCmd: format} {
173 binary format h6 c4102
175 test binary-6.8 {Tcl_BinaryObjCmd: format} {
176 binary format h5 c41020304
178 test binary-6.9 {Tcl_BinaryObjCmd: format} {
179 binary format a3X3h5 foo 2
181 test binary-6.10 {Tcl_BinaryObjCmd: format} {
182 binary format h2h3 23 456
184 test binary-6.11 {Tcl_BinaryObjCmd: format} {
185 list [catch {binary format h2 foo} msg] $msg
186 } {1 {expected hexadecimal string but got "foo" instead}}
188 test binary-7.1 {Tcl_BinaryObjCmd: format} {
189 list [catch {binary format H} msg] $msg
190 } {1 {not enough arguments for all format specifiers}}
191 test binary-7.2 {Tcl_BinaryObjCmd: format} {
194 test binary-7.3 {Tcl_BinaryObjCmd: format} {
197 test binary-7.4 {Tcl_BinaryObjCmd: format} {
200 test binary-7.5 {Tcl_BinaryObjCmd: format} {
201 binary format H* baadf00d
203 test binary-7.6 {Tcl_BinaryObjCmd: format} {
204 binary format H4 c410
206 test binary-7.7 {Tcl_BinaryObjCmd: format} {
207 binary format H6 c4102
209 test binary-7.8 {Tcl_BinaryObjCmd: format} {
210 binary format H5 c41023304
212 test binary-7.9 {Tcl_BinaryObjCmd: format} {
213 binary format a3X3H5 foo 2
215 test binary-7.10 {Tcl_BinaryObjCmd: format} {
216 binary format H2H3 23 456
218 test binary-7.11 {Tcl_BinaryObjCmd: format} {
219 list [catch {binary format H2 foo} msg] $msg
220 } {1 {expected hexadecimal string but got "foo" instead}}
222 test binary-8.1 {Tcl_BinaryObjCmd: format} {
223 list [catch {binary format c} msg] $msg
224 } {1 {not enough arguments for all format specifiers}}
225 test binary-8.2 {Tcl_BinaryObjCmd: format} {
226 list [catch {binary format c blat} msg] $msg
227 } {1 {expected integer but got "blat"}}
228 test binary-8.3 {Tcl_BinaryObjCmd: format} {
229 binary format c0 0x50
231 test binary-8.4 {Tcl_BinaryObjCmd: format} {
234 test binary-8.5 {Tcl_BinaryObjCmd: format} {
235 binary format c 0x5052
237 test binary-8.6 {Tcl_BinaryObjCmd: format} {
238 binary format c2 {0x50 0x52}
240 test binary-8.7 {Tcl_BinaryObjCmd: format} {
241 binary format c2 {0x50 0x52 0x53}
243 test binary-8.8 {Tcl_BinaryObjCmd: format} {
244 binary format c* {0x50 0x52}
246 test binary-8.9 {Tcl_BinaryObjCmd: format} {
247 list [catch {binary format c2 {0x50}} msg] $msg
248 } {1 {number of elements in list does not match count}}
249 test binary-8.10 {Tcl_BinaryObjCmd: format} {
251 list [catch {binary format c $a} msg] $msg
252 } [list 1 "expected integer but got \"0x50 0x51\""]
253 test binary-8.11 {Tcl_BinaryObjCmd: format} {
258 test binary-9.1 {Tcl_BinaryObjCmd: format} {
259 list [catch {binary format s} msg] $msg
260 } {1 {not enough arguments for all format specifiers}}
261 test binary-9.2 {Tcl_BinaryObjCmd: format} {
262 list [catch {binary format s blat} msg] $msg
263 } {1 {expected integer but got "blat"}}
264 test binary-9.3 {Tcl_BinaryObjCmd: format} {
265 binary format s0 0x50
267 test binary-9.4 {Tcl_BinaryObjCmd: format} {
270 test binary-9.5 {Tcl_BinaryObjCmd: format} {
271 binary format s 0x5052
273 test binary-9.6 {Tcl_BinaryObjCmd: format} {
274 binary format s 0x505251 0x53
276 test binary-9.7 {Tcl_BinaryObjCmd: format} {
277 binary format s2 {0x50 0x52}
279 test binary-9.8 {Tcl_BinaryObjCmd: format} {
280 binary format s* {0x5051 0x52}
282 test binary-9.9 {Tcl_BinaryObjCmd: format} {
283 binary format s2 {0x50 0x52 0x53} 0x54
285 test binary-9.10 {Tcl_BinaryObjCmd: format} {
286 list [catch {binary format s2 {0x50}} msg] $msg
287 } {1 {number of elements in list does not match count}}
288 test binary-9.11 {Tcl_BinaryObjCmd: format} {
290 list [catch {binary format s $a} msg] $msg
291 } [list 1 "expected integer but got \"0x50 0x51\""]
292 test binary-9.12 {Tcl_BinaryObjCmd: format} {
297 test binary-10.1 {Tcl_BinaryObjCmd: format} {
298 list [catch {binary format S} msg] $msg
299 } {1 {not enough arguments for all format specifiers}}
300 test binary-10.2 {Tcl_BinaryObjCmd: format} {
301 list [catch {binary format S blat} msg] $msg
302 } {1 {expected integer but got "blat"}}
303 test binary-10.3 {Tcl_BinaryObjCmd: format} {
304 binary format S0 0x50
306 test binary-10.4 {Tcl_BinaryObjCmd: format} {
309 test binary-10.5 {Tcl_BinaryObjCmd: format} {
310 binary format S 0x5052
312 test binary-10.6 {Tcl_BinaryObjCmd: format} {
313 binary format S 0x505251 0x53
315 test binary-10.7 {Tcl_BinaryObjCmd: format} {
316 binary format S2 {0x50 0x52}
318 test binary-10.8 {Tcl_BinaryObjCmd: format} {
319 binary format S* {0x5051 0x52}
321 test binary-10.9 {Tcl_BinaryObjCmd: format} {
322 binary format S2 {0x50 0x52 0x53} 0x54
324 test binary-10.10 {Tcl_BinaryObjCmd: format} {
325 list [catch {binary format S2 {0x50}} msg] $msg
326 } {1 {number of elements in list does not match count}}
327 test binary-10.11 {Tcl_BinaryObjCmd: format} {
329 list [catch {binary format S $a} msg] $msg
330 } [list 1 "expected integer but got \"0x50 0x51\""]
331 test binary-10.12 {Tcl_BinaryObjCmd: format} {
336 test binary-11.1 {Tcl_BinaryObjCmd: format} {
337 list [catch {binary format i} msg] $msg
338 } {1 {not enough arguments for all format specifiers}}
339 test binary-11.2 {Tcl_BinaryObjCmd: format} {
340 list [catch {binary format i blat} msg] $msg
341 } {1 {expected integer but got "blat"}}
342 test binary-11.3 {Tcl_BinaryObjCmd: format} {
343 binary format i0 0x50
345 test binary-11.4 {Tcl_BinaryObjCmd: format} {
348 test binary-11.5 {Tcl_BinaryObjCmd: format} {
349 binary format i 0x5052
351 test binary-11.6 {Tcl_BinaryObjCmd: format} {
352 binary format i 0x505251 0x53
354 test binary-11.7 {Tcl_BinaryObjCmd: format} {
355 binary format i1 {0x505251 0x53}
357 test binary-11.8 {Tcl_BinaryObjCmd: format} {
358 binary format i 0x53525150
360 test binary-11.9 {Tcl_BinaryObjCmd: format} {
361 binary format i2 {0x50 0x52}
362 } P\x00\x00\x00R\x00\x00\x00
363 test binary-11.10 {Tcl_BinaryObjCmd: format} {
364 binary format i* {0x50515253 0x52}
366 test binary-11.11 {Tcl_BinaryObjCmd: format} {
367 list [catch {binary format i2 {0x50}} msg] $msg
368 } {1 {number of elements in list does not match count}}
369 test binary-11.12 {Tcl_BinaryObjCmd: format} {
371 list [catch {binary format i $a} msg] $msg
372 } [list 1 "expected integer but got \"0x50 0x51\""]
373 test binary-11.13 {Tcl_BinaryObjCmd: format} {
378 test binary-12.1 {Tcl_BinaryObjCmd: format} {
379 list [catch {binary format I} msg] $msg
380 } {1 {not enough arguments for all format specifiers}}
381 test binary-12.2 {Tcl_BinaryObjCmd: format} {
382 list [catch {binary format I blat} msg] $msg
383 } {1 {expected integer but got "blat"}}
384 test binary-12.3 {Tcl_BinaryObjCmd: format} {
385 binary format I0 0x50
387 test binary-12.4 {Tcl_BinaryObjCmd: format} {
390 test binary-12.5 {Tcl_BinaryObjCmd: format} {
391 binary format I 0x5052
393 test binary-12.6 {Tcl_BinaryObjCmd: format} {
394 binary format I 0x505251 0x53
396 test binary-12.7 {Tcl_BinaryObjCmd: format} {
397 binary format I1 {0x505251 0x53}
399 test binary-12.8 {Tcl_BinaryObjCmd: format} {
400 binary format I 0x53525150
402 test binary-12.9 {Tcl_BinaryObjCmd: format} {
403 binary format I2 {0x50 0x52}
404 } \x00\x00\x00P\x00\x00\x00R
405 test binary-12.10 {Tcl_BinaryObjCmd: format} {
406 binary format I* {0x50515253 0x52}
408 test binary-12.11 {Tcl_BinaryObjCmd: format} {
409 list [catch {binary format i2 {0x50}} msg] $msg
410 } {1 {number of elements in list does not match count}}
411 test binary-12.12 {Tcl_BinaryObjCmd: format} {
413 list [catch {binary format I $a} msg] $msg
414 } [list 1 "expected integer but got \"0x50 0x51\""]
415 test binary-12.13 {Tcl_BinaryObjCmd: format} {
420 test binary-13.1 {Tcl_BinaryObjCmd: format} {
421 list [catch {binary format f} msg] $msg
422 } {1 {not enough arguments for all format specifiers}}
423 test binary-13.2 {Tcl_BinaryObjCmd: format} {
424 list [catch {binary format f blat} msg] $msg
425 } {1 {expected floating-point number but got "blat"}}
426 test binary-13.3 {Tcl_BinaryObjCmd: format} {
429 test binary-13.4 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
432 test binary-13.5 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
435 test binary-13.6 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
436 binary format f* {1.6 3.4}
437 } \x3f\xcc\xcc\xcd\x40\x59\x99\x9a
438 test binary-13.7 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
439 binary format f* {1.6 3.4}
440 } \xcd\xcc\xcc\x3f\x9a\x99\x59\x40
441 test binary-13.8 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
442 binary format f2 {1.6 3.4}
443 } \x3f\xcc\xcc\xcd\x40\x59\x99\x9a
444 test binary-13.9 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
445 binary format f2 {1.6 3.4}
446 } \xcd\xcc\xcc\x3f\x9a\x99\x59\x40
447 test binary-13.10 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
448 binary format f2 {1.6 3.4 5.6}
449 } \x3f\xcc\xcc\xcd\x40\x59\x99\x9a
450 test binary-13.11 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
451 binary format f2 {1.6 3.4 5.6}
452 } \xcd\xcc\xcc\x3f\x9a\x99\x59\x40
453 test binary-13.12 {Tcl_BinaryObjCmd: float overflow} {nonPortable macOrUnix} {
454 binary format f -3.402825e+38
456 test binary-13.13 {Tcl_BinaryObjCmd: float overflow} {nonPortable pcOnly} {
457 binary format f -3.402825e+38
459 test binary-13.14 {Tcl_BinaryObjCmd: float underflow} {nonPortable macOrUnix} {
460 binary format f -3.402825e-100
462 test binary-13.15 {Tcl_BinaryObjCmd: float underflow} {nonPortable pcOnly} {
463 binary format f -3.402825e-100
465 test binary-13.16 {Tcl_BinaryObjCmd: format} {
466 list [catch {binary format f2 {1.6}} msg] $msg
467 } {1 {number of elements in list does not match count}}
468 test binary-13.17 {Tcl_BinaryObjCmd: format} {
470 list [catch {binary format f $a} msg] $msg
471 } [list 1 "expected floating-point number but got \"1.6 3.4\""]
472 test binary-13.18 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
476 test binary-13.19 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
481 test binary-14.1 {Tcl_BinaryObjCmd: format} {
482 list [catch {binary format d} msg] $msg
483 } {1 {not enough arguments for all format specifiers}}
484 test binary-14.2 {Tcl_BinaryObjCmd: format} {
485 list [catch {binary format d blat} msg] $msg
486 } {1 {expected floating-point number but got "blat"}}
487 test binary-14.3 {Tcl_BinaryObjCmd: format} {
490 test binary-14.4 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
492 } \x3f\xf9\x99\x99\x99\x99\x99\x9a
493 test binary-14.5 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
495 } \x9a\x99\x99\x99\x99\x99\xf9\x3f
496 test binary-14.6 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
497 binary format d* {1.6 3.4}
498 } \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33
499 test binary-14.7 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
500 binary format d* {1.6 3.4}
501 } \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40
502 test binary-14.8 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
503 binary format d2 {1.6 3.4}
504 } \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33
505 test binary-14.9 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
506 binary format d2 {1.6 3.4}
507 } \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40
508 test binary-14.10 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
509 binary format d2 {1.6 3.4 5.6}
510 } \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33
511 test binary-14.11 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
512 binary format d2 {1.6 3.4 5.6}
513 } \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40
514 test binary-14.12 {Tcl_BinaryObjCmd: float overflow} {nonPortable unixOnly} {
516 } \x7f\xff\xff\xff\xff\xff\xff\xff
517 test binary-14.13 {Tcl_BinaryObjCmd: float overflow} {nonPortable macOnly} {
519 } \x7f\xf8\x02\xa0\x00\x00\x00\x00
520 test binary-14.14 {Tcl_BinaryObjCmd: format} {
521 list [catch {binary format d2 {1.6}} msg] $msg
522 } {1 {number of elements in list does not match count}}
523 test binary-14.15 {Tcl_BinaryObjCmd: format} {
525 list [catch {binary format d $a} msg] $msg
526 } [list 1 "expected floating-point number but got \"1.6 3.4\""]
527 test binary-14.16 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
530 } \x3f\xf9\x99\x99\x99\x99\x99\x9a
531 test binary-14.17 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
534 } \x9a\x99\x99\x99\x99\x99\xf9\x3f
535 test binary-14.18 {FormatNumber: Bug 1116542} {
536 binary scan [binary format d 1.25] d w
540 test binary-15.1 {Tcl_BinaryObjCmd: format} {
541 list [catch {binary format ax*a "y" "z"} msg] $msg
542 } {1 {cannot use "*" in format string with "x"}}
543 test binary-15.2 {Tcl_BinaryObjCmd: format} {
544 binary format axa "y" "z"
546 test binary-15.3 {Tcl_BinaryObjCmd: format} {
547 binary format ax3a "y" "z"
549 test binary-15.4 {Tcl_BinaryObjCmd: format} {
550 binary format a*X3x3a* "foo" "z"
553 test binary-16.1 {Tcl_BinaryObjCmd: format} {
554 binary format a*X*a "foo" "z"
556 test binary-16.2 {Tcl_BinaryObjCmd: format} {
557 binary format aX3a "y" "z"
559 test binary-16.3 {Tcl_BinaryObjCmd: format} {
560 binary format a*Xa* "foo" "zy"
562 test binary-16.4 {Tcl_BinaryObjCmd: format} {
563 binary format a*X3a "foobar" "z"
565 test binary-16.5 {Tcl_BinaryObjCmd: format} {
566 binary format a*X3aX2a "foobar" "z" "b"
569 test binary-17.1 {Tcl_BinaryObjCmd: format} {
572 test binary-17.2 {Tcl_BinaryObjCmd: format} {
573 binary format @5a2 "ab"
574 } \x00\x00\x00\x00\x00\x61\x62
575 test binary-17.3 {Tcl_BinaryObjCmd: format} {
576 binary format {a* @0 a2 @* a*} "foobar" "ab" "blat"
579 test binary-18.1 {Tcl_BinaryObjCmd: format} {
580 list [catch {binary format u0a3 abc abd} msg] $msg
581 } {1 {bad field specifier "u"}}
584 test binary-19.1 {Tcl_BinaryObjCmd: errors} {
585 list [catch {binary s} msg] $msg
586 } {1 {wrong # args: should be "binary scan value formatString ?varName varName ...?"}}
587 test binary-19.2 {Tcl_BinaryObjCmd: errors} {
588 list [catch {binary scan foo} msg] $msg
589 } {1 {wrong # args: should be "binary scan value formatString ?varName varName ...?"}}
590 test binary-19.3 {Tcl_BinaryObjCmd: scan} {
594 test binary-20.1 {Tcl_BinaryObjCmd: scan} {
595 list [catch {binary scan abc a} msg] $msg
596 } {1 {not enough arguments for all format specifiers}}
597 test binary-20.2 {Tcl_BinaryObjCmd: scan} {
600 list [catch {binary scan abc a arg1(a)} msg] $msg
601 } {1 {can't set "arg1(a)": variable isn't array}}
602 test binary-20.3 {Tcl_BinaryObjCmd: scan} {
605 list [binary scan abc a0 arg1] $arg1
607 test binary-20.4 {Tcl_BinaryObjCmd: scan} {
609 list [binary scan abc a* arg1] $arg1
611 test binary-20.5 {Tcl_BinaryObjCmd: scan} {
613 list [binary scan abc a5 arg1] [info exists arg1]
615 test binary-20.6 {Tcl_BinaryObjCmd: scan} {
617 list [binary scan abc a2 arg1] $arg1
619 test binary-20.7 {Tcl_BinaryObjCmd: scan} {
622 list [binary scan abcdef a2a2 arg1 arg2] $arg1 $arg2
624 test binary-20.8 {Tcl_BinaryObjCmd: scan} {
626 list [binary scan abc a2 arg1(a)] $arg1(a)
628 test binary-20.9 {Tcl_BinaryObjCmd: scan} {
630 list [binary scan abc a arg1(a)] $arg1(a)
633 test binary-21.1 {Tcl_BinaryObjCmd: scan} {
634 list [catch {binary scan abc A} msg] $msg
635 } {1 {not enough arguments for all format specifiers}}
636 test binary-21.2 {Tcl_BinaryObjCmd: scan} {
639 list [catch {binary scan abc A arg1(a)} msg] $msg
640 } {1 {can't set "arg1(a)": variable isn't array}}
641 test binary-21.3 {Tcl_BinaryObjCmd: scan} {
644 list [binary scan abc A0 arg1] $arg1
646 test binary-21.4 {Tcl_BinaryObjCmd: scan} {
648 list [binary scan abc A* arg1] $arg1
650 test binary-21.5 {Tcl_BinaryObjCmd: scan} {
652 list [binary scan abc A5 arg1] [info exists arg1]
654 test binary-21.6 {Tcl_BinaryObjCmd: scan} {
656 list [binary scan abc A2 arg1] $arg1
658 test binary-21.7 {Tcl_BinaryObjCmd: scan} {
661 list [binary scan abcdef A2A2 arg1 arg2] $arg1 $arg2
663 test binary-21.8 {Tcl_BinaryObjCmd: scan} {
665 list [binary scan abc A2 arg1(a)] $arg1(a)
667 test binary-21.9 {Tcl_BinaryObjCmd: scan} {
669 list [binary scan abc A2 arg1(a)] $arg1(a)
671 test binary-21.10 {Tcl_BinaryObjCmd: scan} {
673 list [binary scan abc A arg1(a)] $arg1(a)
675 test binary-21.11 {Tcl_BinaryObjCmd: scan} {
677 list [binary scan "abc def \x00 " A* arg1] $arg1
679 test binary-21.12 {Tcl_BinaryObjCmd: scan} {
681 list [binary scan "abc def \x00ghi " A* arg1] $arg1
682 } [list 1 "abc def \x00ghi"]
684 test binary-22.1 {Tcl_BinaryObjCmd: scan} {
685 list [catch {binary scan abc b} msg] $msg
686 } {1 {not enough arguments for all format specifiers}}
687 test binary-22.2 {Tcl_BinaryObjCmd: scan} {
689 list [binary scan \x52\x53 b* arg1] $arg1
690 } {1 0100101011001010}
691 test binary-22.3 {Tcl_BinaryObjCmd: scan} {
693 list [binary scan \x82\x53 b arg1] $arg1
695 test binary-22.4 {Tcl_BinaryObjCmd: scan} {
697 list [binary scan \x82\x53 b1 arg1] $arg1
699 test binary-22.5 {Tcl_BinaryObjCmd: scan} {
701 list [binary scan \x82\x53 b0 arg1] $arg1
703 test binary-22.6 {Tcl_BinaryObjCmd: scan} {
705 list [binary scan \x52\x53 b5 arg1] $arg1
707 test binary-22.7 {Tcl_BinaryObjCmd: scan} {
709 list [binary scan \x52\x53 b8 arg1] $arg1
711 test binary-22.8 {Tcl_BinaryObjCmd: scan} {
713 list [binary scan \x52\x53 b14 arg1] $arg1
715 test binary-22.9 {Tcl_BinaryObjCmd: scan} {
718 list [binary scan \x52 b14 arg1] $arg1
720 test binary-22.10 {Tcl_BinaryObjCmd: scan} {
723 list [catch {binary scan \x52\x53 b1 arg1(a)} msg] $msg
724 } {1 {can't set "arg1(a)": variable isn't array}}
725 test binary-22.11 {Tcl_BinaryObjCmd: scan} {
726 catch {unset arg1 arg2}
729 list [binary scan \x07\x87\x05 b5b* arg1 arg2] $arg1 $arg2
730 } {2 11100 1110000110100000}
733 test binary-23.1 {Tcl_BinaryObjCmd: scan} {
734 list [catch {binary scan abc B} msg] $msg
735 } {1 {not enough arguments for all format specifiers}}
736 test binary-23.2 {Tcl_BinaryObjCmd: scan} {
738 list [binary scan \x52\x53 B* arg1] $arg1
739 } {1 0101001001010011}
740 test binary-23.3 {Tcl_BinaryObjCmd: scan} {
742 list [binary scan \x82\x53 B arg1] $arg1
744 test binary-23.4 {Tcl_BinaryObjCmd: scan} {
746 list [binary scan \x82\x53 B1 arg1] $arg1
748 test binary-23.5 {Tcl_BinaryObjCmd: scan} {
750 list [binary scan \x52\x53 B0 arg1] $arg1
752 test binary-23.6 {Tcl_BinaryObjCmd: scan} {
754 list [binary scan \x52\x53 B5 arg1] $arg1
756 test binary-23.7 {Tcl_BinaryObjCmd: scan} {
758 list [binary scan \x52\x53 B8 arg1] $arg1
760 test binary-23.8 {Tcl_BinaryObjCmd: scan} {
762 list [binary scan \x52\x53 B14 arg1] $arg1
764 test binary-23.9 {Tcl_BinaryObjCmd: scan} {
767 list [binary scan \x52 B14 arg1] $arg1
769 test binary-23.10 {Tcl_BinaryObjCmd: scan} {
772 list [catch {binary scan \x52\x53 B1 arg1(a)} msg] $msg
773 } {1 {can't set "arg1(a)": variable isn't array}}
774 test binary-23.11 {Tcl_BinaryObjCmd: scan} {
775 catch {unset arg1 arg2}
778 list [binary scan \x70\x87\x05 B5B* arg1 arg2] $arg1 $arg2
779 } {2 01110 1000011100000101}
781 test binary-24.1 {Tcl_BinaryObjCmd: scan} {
782 list [catch {binary scan abc h} msg] $msg
783 } {1 {not enough arguments for all format specifiers}}
784 test binary-24.2 {Tcl_BinaryObjCmd: scan} {
786 list [binary scan \x52\xa3 h* arg1] $arg1
788 test binary-24.3 {Tcl_BinaryObjCmd: scan} {
790 list [binary scan \xc2\xa3 h arg1] $arg1
792 test binary-24.4 {Tcl_BinaryObjCmd: scan} {
794 list [binary scan \x82\x53 h1 arg1] $arg1
796 test binary-24.5 {Tcl_BinaryObjCmd: scan} {
798 list [binary scan \x52\x53 h0 arg1] $arg1
800 test binary-24.6 {Tcl_BinaryObjCmd: scan} {
802 list [binary scan \xf2\x53 h2 arg1] $arg1
804 test binary-24.7 {Tcl_BinaryObjCmd: scan} {
806 list [binary scan \x52\x53 h3 arg1] $arg1
808 test binary-24.8 {Tcl_BinaryObjCmd: scan} {
811 list [binary scan \x52 h3 arg1] $arg1
813 test binary-24.9 {Tcl_BinaryObjCmd: scan} {
816 list [catch {binary scan \x52\x53 h1 arg1(a)} msg] $msg
817 } {1 {can't set "arg1(a)": variable isn't array}}
818 test binary-24.10 {Tcl_BinaryObjCmd: scan} {
819 catch {unset arg1 arg2}
822 list [binary scan \x70\x87\x05 h2h* arg1 arg2] $arg1 $arg2
825 test binary-25.1 {Tcl_BinaryObjCmd: scan} {
826 list [catch {binary scan abc H} msg] $msg
827 } {1 {not enough arguments for all format specifiers}}
828 test binary-25.2 {Tcl_BinaryObjCmd: scan} {
830 list [binary scan \x52\xa3 H* arg1] $arg1
832 test binary-25.3 {Tcl_BinaryObjCmd: scan} {
834 list [binary scan \xc2\xa3 H arg1] $arg1
836 test binary-25.4 {Tcl_BinaryObjCmd: scan} {
838 list [binary scan \x82\x53 H1 arg1] $arg1
840 test binary-25.5 {Tcl_BinaryObjCmd: scan} {
842 list [binary scan \x52\x53 H0 arg1] $arg1
844 test binary-25.6 {Tcl_BinaryObjCmd: scan} {
846 list [binary scan \xf2\x53 H2 arg1] $arg1
848 test binary-25.7 {Tcl_BinaryObjCmd: scan} {
850 list [binary scan \x52\x53 H3 arg1] $arg1
852 test binary-25.8 {Tcl_BinaryObjCmd: scan} {
855 list [binary scan \x52 H3 arg1] $arg1
857 test binary-25.9 {Tcl_BinaryObjCmd: scan} {
860 list [catch {binary scan \x52\x53 H1 arg1(a)} msg] $msg
861 } {1 {can't set "arg1(a)": variable isn't array}}
862 test binary-25.10 {Tcl_BinaryObjCmd: scan} {
863 catch {unset arg1 arg2}
866 list [binary scan \x70\x87\x05 H2H* arg1 arg2] $arg1 $arg2
869 test binary-26.1 {Tcl_BinaryObjCmd: scan} {
870 list [catch {binary scan abc c} msg] $msg
871 } {1 {not enough arguments for all format specifiers}}
872 test binary-26.2 {Tcl_BinaryObjCmd: scan} {
874 list [binary scan \x52\xa3 c* arg1] $arg1
876 test binary-26.3 {Tcl_BinaryObjCmd: scan} {
878 list [binary scan \x52\xa3 c arg1] $arg1
880 test binary-26.4 {Tcl_BinaryObjCmd: scan} {
882 list [binary scan \x52\xa3 c1 arg1] $arg1
884 test binary-26.5 {Tcl_BinaryObjCmd: scan} {
886 list [binary scan \x52\xa3 c0 arg1] $arg1
888 test binary-26.6 {Tcl_BinaryObjCmd: scan} {
890 list [binary scan \x52\xa3 c2 arg1] $arg1
892 test binary-26.7 {Tcl_BinaryObjCmd: scan} {
894 list [binary scan \xff c arg1] $arg1
896 test binary-26.8 {Tcl_BinaryObjCmd: scan} {
899 list [binary scan \x52 c3 arg1] $arg1
901 test binary-26.9 {Tcl_BinaryObjCmd: scan} {
904 list [catch {binary scan \x52\x53 c1 arg1(a)} msg] $msg
905 } {1 {can't set "arg1(a)": variable isn't array}}
906 test binary-26.10 {Tcl_BinaryObjCmd: scan} {
907 catch {unset arg1 arg2}
910 list [binary scan \x70\x87\x05 c2c* arg1 arg2] $arg1 $arg2
913 test binary-27.1 {Tcl_BinaryObjCmd: scan} {
914 list [catch {binary scan abc s} msg] $msg
915 } {1 {not enough arguments for all format specifiers}}
916 test binary-27.2 {Tcl_BinaryObjCmd: scan} {
918 list [binary scan \x52\xa3\x53\x54 s* arg1] $arg1
920 test binary-27.3 {Tcl_BinaryObjCmd: scan} {
922 list [binary scan \x52\xa3\x53\x54 s arg1] $arg1
924 test binary-27.4 {Tcl_BinaryObjCmd: scan} {
926 list [binary scan \x52\xa3 s1 arg1] $arg1
928 test binary-27.5 {Tcl_BinaryObjCmd: scan} {
930 list [binary scan \x52\xa3 s0 arg1] $arg1
932 test binary-27.6 {Tcl_BinaryObjCmd: scan} {
934 list [binary scan \x52\xa3\x53\x54 s2 arg1] $arg1
936 test binary-27.7 {Tcl_BinaryObjCmd: scan} {
939 list [binary scan \x52 s1 arg1] $arg1
941 test binary-27.8 {Tcl_BinaryObjCmd: scan} {
944 list [catch {binary scan \x52\x53 s1 arg1(a)} msg] $msg
945 } {1 {can't set "arg1(a)": variable isn't array}}
946 test binary-27.9 {Tcl_BinaryObjCmd: scan} {
947 catch {unset arg1 arg2}
950 list [binary scan \x52\xa3\x53\x54\x05 s2c* arg1 arg2] $arg1 $arg2
951 } {2 {-23726 21587} 5}
953 test binary-28.1 {Tcl_BinaryObjCmd: scan} {
954 list [catch {binary scan abc S} msg] $msg
955 } {1 {not enough arguments for all format specifiers}}
956 test binary-28.2 {Tcl_BinaryObjCmd: scan} {
958 list [binary scan \x52\xa3\x53\x54 S* arg1] $arg1
960 test binary-28.3 {Tcl_BinaryObjCmd: scan} {
962 list [binary scan \x52\xa3\x53\x54 S arg1] $arg1
964 test binary-28.4 {Tcl_BinaryObjCmd: scan} {
966 list [binary scan \x52\xa3 S1 arg1] $arg1
968 test binary-28.5 {Tcl_BinaryObjCmd: scan} {
970 list [binary scan \x52\xa3 S0 arg1] $arg1
972 test binary-28.6 {Tcl_BinaryObjCmd: scan} {
974 list [binary scan \x52\xa3\x53\x54 S2 arg1] $arg1
976 test binary-28.7 {Tcl_BinaryObjCmd: scan} {
979 list [binary scan \x52 S1 arg1] $arg1
981 test binary-28.8 {Tcl_BinaryObjCmd: scan} {
984 list [catch {binary scan \x52\x53 S1 arg1(a)} msg] $msg
985 } {1 {can't set "arg1(a)": variable isn't array}}
986 test binary-28.9 {Tcl_BinaryObjCmd: scan} {
987 catch {unset arg1 arg2}
990 list [binary scan \x52\xa3\x53\x54\x05 S2c* arg1 arg2] $arg1 $arg2
991 } {2 {21155 21332} 5}
993 test binary-29.1 {Tcl_BinaryObjCmd: scan} {
994 list [catch {binary scan abc i} msg] $msg
995 } {1 {not enough arguments for all format specifiers}}
996 test binary-29.2 {Tcl_BinaryObjCmd: scan} {
998 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 i* arg1] $arg1
999 } {1 {1414767442 67305985}}
1000 test binary-29.3 {Tcl_BinaryObjCmd: scan} {
1002 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 i arg1] $arg1
1004 test binary-29.4 {Tcl_BinaryObjCmd: scan} {
1006 list [binary scan \x52\xa3\x53\x54 i1 arg1] $arg1
1008 test binary-29.5 {Tcl_BinaryObjCmd: scan} {
1010 list [binary scan \x52\xa3\x53 i0 arg1] $arg1
1012 test binary-29.6 {Tcl_BinaryObjCmd: scan} {
1014 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 i2 arg1] $arg1
1015 } {1 {1414767442 67305985}}
1016 test binary-29.7 {Tcl_BinaryObjCmd: scan} {
1019 list [binary scan \x52 i1 arg1] $arg1
1021 test binary-29.8 {Tcl_BinaryObjCmd: scan} {
1024 list [catch {binary scan \x52\x53\x53\x54 i1 arg1(a)} msg] $msg
1025 } {1 {can't set "arg1(a)": variable isn't array}}
1026 test binary-29.9 {Tcl_BinaryObjCmd: scan} {
1027 catch {unset arg1 arg2}
1030 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04\x05 i2c* arg1 arg2] $arg1 $arg2
1031 } {2 {1414767442 67305985} 5}
1033 test binary-30.1 {Tcl_BinaryObjCmd: scan} {
1034 list [catch {binary scan abc I} msg] $msg
1035 } {1 {not enough arguments for all format specifiers}}
1036 test binary-30.2 {Tcl_BinaryObjCmd: scan} {
1038 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 I* arg1] $arg1
1039 } {1 {1386435412 16909060}}
1040 test binary-30.3 {Tcl_BinaryObjCmd: scan} {
1042 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 I arg1] $arg1
1044 test binary-30.4 {Tcl_BinaryObjCmd: scan} {
1046 list [binary scan \x52\xa3\x53\x54 I1 arg1] $arg1
1048 test binary-30.5 {Tcl_BinaryObjCmd: scan} {
1050 list [binary scan \x52\xa3\x53 I0 arg1] $arg1
1052 test binary-30.6 {Tcl_BinaryObjCmd: scan} {
1054 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 I2 arg1] $arg1
1055 } {1 {1386435412 16909060}}
1056 test binary-30.7 {Tcl_BinaryObjCmd: scan} {
1059 list [binary scan \x52 I1 arg1] $arg1
1061 test binary-30.8 {Tcl_BinaryObjCmd: scan} {
1064 list [catch {binary scan \x52\x53\x53\x54 I1 arg1(a)} msg] $msg
1065 } {1 {can't set "arg1(a)": variable isn't array}}
1066 test binary-30.9 {Tcl_BinaryObjCmd: scan} {
1067 catch {unset arg1 arg2}
1070 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04\x05 I2c* arg1 arg2] $arg1 $arg2
1071 } {2 {1386435412 16909060} 5}
1073 test binary-31.1 {Tcl_BinaryObjCmd: scan} {
1074 list [catch {binary scan abc f} msg] $msg
1075 } {1 {not enough arguments for all format specifiers}}
1076 test binary-31.2 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
1078 list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a f* arg1] $arg1
1079 } {1 {1.60000002384 3.40000009537}}
1080 test binary-31.3 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
1082 list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 f* arg1] $arg1
1083 } {1 {1.60000002384 3.40000009537}}
1084 test binary-31.4 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
1086 list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a f arg1] $arg1
1088 test binary-31.5 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
1090 list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 f arg1] $arg1
1092 test binary-31.6 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
1094 list [binary scan \x3f\xcc\xcc\xcd f1 arg1] $arg1
1096 test binary-31.7 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
1098 list [binary scan \xcd\xcc\xcc\x3f f1 arg1] $arg1
1100 test binary-31.8 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
1102 list [binary scan \x3f\xcc\xcc\xcd f0 arg1] $arg1
1104 test binary-31.9 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
1106 list [binary scan \xcd\xcc\xcc\x3f f0 arg1] $arg1
1108 test binary-31.10 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
1110 list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a f2 arg1] $arg1
1111 } {1 {1.60000002384 3.40000009537}}
1112 test binary-31.11 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
1114 list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 f2 arg1] $arg1
1115 } {1 {1.60000002384 3.40000009537}}
1116 test binary-31.12 {Tcl_BinaryObjCmd: scan} {
1119 list [binary scan \x52 f1 arg1] $arg1
1121 test binary-31.13 {Tcl_BinaryObjCmd: scan} {
1124 list [catch {binary scan \x3f\xcc\xcc\xcd f1 arg1(a)} msg] $msg
1125 } {1 {can't set "arg1(a)": variable isn't array}}
1126 test binary-31.14 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
1127 catch {unset arg1 arg2}
1130 list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a\x05 f2c* arg1 arg2] $arg1 $arg2
1131 } {2 {1.60000002384 3.40000009537} 5}
1132 test binary-31.15 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
1133 catch {unset arg1 arg2}
1136 list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40\x05 f2c* arg1 arg2] $arg1 $arg2
1137 } {2 {1.60000002384 3.40000009537} 5}
1139 test binary-32.1 {Tcl_BinaryObjCmd: scan} {
1140 list [catch {binary scan abc d} msg] $msg
1141 } {1 {not enough arguments for all format specifiers}}
1142 test binary-32.2 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
1144 list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 d* arg1] $arg1
1146 test binary-32.3 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
1148 list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 d* arg1] $arg1
1150 test binary-32.4 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
1152 list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 d arg1] $arg1
1154 test binary-32.5 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
1156 list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 d arg1] $arg1
1158 test binary-32.6 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
1160 list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a d1 arg1] $arg1
1162 test binary-32.7 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
1164 list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f d1 arg1] $arg1
1166 test binary-32.8 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
1168 list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a d0 arg1] $arg1
1170 test binary-32.9 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
1172 list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f d0 arg1] $arg1
1174 test binary-32.10 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
1176 list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 d2 arg1] $arg1
1178 test binary-32.11 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
1180 list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 d2 arg1] $arg1
1182 test binary-32.12 {Tcl_BinaryObjCmd: scan} {
1185 list [binary scan \x52 d1 arg1] $arg1
1187 test binary-32.13 {Tcl_BinaryObjCmd: scan} {
1190 list [catch {binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a d1 arg1(a)} msg] $msg
1191 } {1 {can't set "arg1(a)": variable isn't array}}
1192 test binary-32.14 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
1193 catch {unset arg1 arg2}
1196 list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33\x05 d2c* arg1 arg2] $arg1 $arg2
1198 test binary-32.15 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
1199 catch {unset arg1 arg2}
1202 list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40\x05 d2c* arg1 arg2] $arg1 $arg2
1205 test binary-33.1 {Tcl_BinaryObjCmd: scan} {
1208 list [binary scan abcdefg a2xa3 arg1 arg2] $arg1 $arg2
1210 test binary-33.2 {Tcl_BinaryObjCmd: scan} {
1214 list [binary scan abcdefg a3x*a3 arg1 arg2] $arg1 $arg2
1216 test binary-33.3 {Tcl_BinaryObjCmd: scan} {
1220 list [binary scan abcdefg a3x20a3 arg1 arg2] $arg1 $arg2
1222 test binary-33.4 {Tcl_BinaryObjCmd: scan} {
1226 list [binary scan abc a3x20a3 arg1 arg2] $arg1 $arg2
1228 test binary-33.5 {Tcl_BinaryObjCmd: scan} {
1230 list [binary scan abcdef x1a1 arg1] $arg1
1232 test binary-33.6 {Tcl_BinaryObjCmd: scan} {
1234 list [binary scan abcdef x5a1 arg1] $arg1
1236 test binary-33.7 {Tcl_BinaryObjCmd: scan} {
1238 list [binary scan abcdef x0a1 arg1] $arg1
1241 test binary-34.1 {Tcl_BinaryObjCmd: scan} {
1244 list [binary scan abcdefg a2Xa3 arg1 arg2] $arg1 $arg2
1246 test binary-34.2 {Tcl_BinaryObjCmd: scan} {
1250 list [binary scan abcdefg a3X*a3 arg1 arg2] $arg1 $arg2
1252 test binary-34.3 {Tcl_BinaryObjCmd: scan} {
1256 list [binary scan abcdefg a3X20a3 arg1 arg2] $arg1 $arg2
1258 test binary-34.4 {Tcl_BinaryObjCmd: scan} {
1260 list [binary scan abc X20a3 arg1] $arg1
1262 test binary-34.5 {Tcl_BinaryObjCmd: scan} {
1264 list [binary scan abcdef x*X1a1 arg1] $arg1
1266 test binary-34.6 {Tcl_BinaryObjCmd: scan} {
1268 list [binary scan abcdef x*X5a1 arg1] $arg1
1270 test binary-34.7 {Tcl_BinaryObjCmd: scan} {
1272 list [binary scan abcdef x3X0a1 arg1] $arg1
1275 test binary-35.1 {Tcl_BinaryObjCmd: scan} {
1278 list [catch {binary scan abcdefg a2@a3 arg1 arg2} msg] $msg
1279 } {1 {missing count for "@" field specifier}}
1280 test binary-35.2 {Tcl_BinaryObjCmd: scan} {
1284 list [binary scan abcdefg a3@*a3 arg1 arg2] $arg1 $arg2
1286 test binary-35.3 {Tcl_BinaryObjCmd: scan} {
1290 list [binary scan abcdefg a3@20a3 arg1 arg2] $arg1 $arg2
1292 test binary-35.4 {Tcl_BinaryObjCmd: scan} {
1294 list [binary scan abcdef @2a3 arg1] $arg1
1296 test binary-35.5 {Tcl_BinaryObjCmd: scan} {
1298 list [binary scan abcdef x*@1a1 arg1] $arg1
1300 test binary-35.6 {Tcl_BinaryObjCmd: scan} {
1302 list [binary scan abcdef x*@0a1 arg1] $arg1
1305 test binary-36.1 {Tcl_BinaryObjCmd: scan} {
1306 list [catch {binary scan abcdef u0a3} msg] $msg
1307 } {1 {bad field specifier "u"}}
1309 # GetFormatSpec is pretty thoroughly tested above, but there are a few
1310 # cases we should text explicitly
1312 test binary-37.1 {GetFormatSpec: whitespace} {
1313 binary format "a3 a5 a3" foo barblat baz
1315 test binary-37.2 {GetFormatSpec: whitespace} {
1316 binary format " " foo
1318 test binary-37.3 {GetFormatSpec: whitespace} {
1319 binary format " a3" foo
1321 test binary-37.4 {GetFormatSpec: whitespace} {
1322 binary format "" foo
1324 test binary-37.5 {GetFormatSpec: whitespace} {
1325 binary format "" foo
1327 test binary-37.6 {GetFormatSpec: whitespace} {
1328 binary format " a3 " foo
1330 test binary-37.7 {GetFormatSpec: numbers} {
1331 list [catch {binary scan abcdef "x-1" foo} msg] $msg
1332 } {1 {bad field specifier "-"}}
1333 test binary-37.8 {GetFormatSpec: numbers} {
1336 list [binary scan abcdef "a0x3" arg1] $arg1
1338 test binary-37.9 {GetFormatSpec: numbers} {
1339 # test format of neg numbers
1340 # bug report/fix provided by Harald Kirsch
1341 set x [binary format f* {1 -1 2 -2 0}]
1342 binary scan $x f* bla
1344 } {1.0 -1.0 2.0 -2.0 0.0}
1346 test binary-38.1 {FormatNumber: word alignment} {
1347 set x [binary format c1s1 1 1]
1349 test binary-38.2 {FormatNumber: word alignment} {
1350 set x [binary format c1S1 1 1]
1352 test binary-38.3 {FormatNumber: word alignment} {
1353 set x [binary format c1i1 1 1]
1354 } \x01\x01\x00\x00\x00
1355 test binary-38.4 {FormatNumber: word alignment} {
1356 set x [binary format c1I1 1 1]
1357 } \x01\x00\x00\x00\x01
1358 test binary-38.5 {FormatNumber: word alignment} {nonPortable macOrUnix} {
1359 set x [binary format c1d1 1 1.6]
1360 } \x01\x3f\xf9\x99\x99\x99\x99\x99\x9a
1361 test binary-38.6 {FormatNumber: word alignment} {nonPortable pcOnly} {
1362 set x [binary format c1d1 1 1.6]
1363 } \x01\x9a\x99\x99\x99\x99\x99\xf9\x3f
1364 test binary-38.7 {FormatNumber: word alignment} {nonPortable macOrUnix} {
1365 set x [binary format c1f1 1 1.6]
1366 } \x01\x3f\xcc\xcc\xcd
1367 test binary-38.8 {FormatNumber: word alignment} {nonPortable pcOnly} {
1368 set x [binary format c1f1 1 1.6]
1369 } \x01\xcd\xcc\xcc\x3f
1371 test binary-39.1 {ScanNumber: sign extension} {
1373 list [binary scan \x52\xa3 c2 arg1] $arg1
1375 test binary-39.2 {ScanNumber: sign extension} {
1377 list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 s4 arg1] $arg1
1378 } {1 {513 -32511 386 -32127}}
1379 test binary-39.3 {ScanNumber: sign extension} {
1381 list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 S4 arg1] $arg1
1382 } {1 {258 385 -32255 -32382}}
1383 test binary-39.4 {ScanNumber: sign extension} {
1385 list [binary scan \x01\x01\x01\x02\x81\x01\x01\x01\x01\x82\x01\x01\x01\x01\x82\x01\x01\x01\x01\x81 i5 arg1] $arg1
1386 } {1 {33620225 16843137 16876033 25297153 -2130640639}}
1387 test binary-39.5 {ScanNumber: sign extension} {
1389 list [binary scan \x01\x01\x01\x02\x81\x01\x01\x01\x01\x82\x01\x01\x01\x01\x82\x01\x01\x01\x01\x81 I5 arg1] $arg1
1390 } {1 {16843010 -2130640639 25297153 16876033 16843137}}
1392 test binary-40.1 {ScanNumber: floating point overflow} {nonPortable unixOnly} {
1394 list [binary scan \xff\xff\xff\xff f1 arg1] $arg1
1396 test binary-40.2 {ScanNumber: floating point overflow} {nonPortable macOnly} {
1398 list [binary scan \xff\xff\xff\xff f1 arg1] $arg1
1400 test binary-40.3 {ScanNumber: floating point overflow} {nonPortable pcOnly} {
1402 set result [binary scan \xff\xff\xff\xff f1 arg1]
1403 if {([string compare $arg1 -1.\#QNAN] == 0)
1404 || ([string compare $arg1 -NAN] == 0)} {
1405 lappend result success
1407 lappend result failure
1410 test binary-40.4 {ScanNumber: floating point overflow} {nonPortable unixOnly} {
1412 list [binary scan \xff\xff\xff\xff\xff\xff\xff\xff d1 arg1] $arg1
1414 test binary-40.5 {ScanNumber: floating point overflow} {nonPortable macOnly} {
1416 list [binary scan \xff\xff\xff\xff\xff\xff\xff\xff d1 arg1] $arg1
1418 test binary-40.6 {ScanNumber: floating point overflow} {nonPortable pcOnly} {
1420 set result [binary scan \xff\xff\xff\xff\xff\xff\xff\xff d1 arg1]
1421 if {([string compare $arg1 -1.\#QNAN] == 0)
1422 || ([string compare $arg1 -NAN] == 0)} {
1423 lappend result success
1425 lappend result failure
1429 test binary-41.1 {ScanNumber: word alignment} {
1430 catch {unset arg1; unset arg2}
1431 list [binary scan \x01\x01\x00 c1s1 arg1 arg2] $arg1 $arg2
1433 test binary-41.2 {ScanNumber: word alignment} {
1434 catch {unset arg1; unset arg2}
1435 list [binary scan \x01\x00\x01 c1S1 arg1 arg2] $arg1 $arg2
1437 test binary-41.3 {ScanNumber: word alignment} {
1438 catch {unset arg1; unset arg2}
1439 list [binary scan \x01\x01\x00\x00\x00 c1i1 arg1 arg2] $arg1 $arg2
1441 test binary-41.4 {ScanNumber: word alignment} {
1442 catch {unset arg1; unset arg2}
1443 list [binary scan \x01\x00\x00\x00\x01 c1I1 arg1 arg2] $arg1 $arg2
1445 test binary-41.5 {ScanNumber: word alignment} {nonPortable macOrUnix} {
1446 catch {unset arg1; unset arg2}
1447 list [binary scan \x01\x3f\xcc\xcc\xcd c1f1 arg1 arg2] $arg1 $arg2
1448 } {2 1 1.60000002384}
1449 test binary-41.6 {ScanNumber: word alignment} {nonPortable pcOnly} {
1450 catch {unset arg1; unset arg2}
1451 list [binary scan \x01\xcd\xcc\xcc\x3f c1f1 arg1 arg2] $arg1 $arg2
1452 } {2 1 1.60000002384}
1453 test binary-41.7 {ScanNumber: word alignment} {nonPortable macOrUnix} {
1454 catch {unset arg1; unset arg2}
1455 list [binary scan \x01\x3f\xf9\x99\x99\x99\x99\x99\x9a c1d1 arg1 arg2] $arg1 $arg2
1457 test binary-41.8 {ScanNumber: word alignment} {nonPortable pcOnly} {
1458 catch {unset arg1; unset arg2}
1459 list [binary scan \x01\x9a\x99\x99\x99\x99\x99\xf9\x3f c1d1 arg1 arg2] $arg1 $arg2
1462 test binary-42.1 {Tcl_BinaryObjCmd: bad arguments} {} {
1463 catch {binary ?} result
1465 } {bad option "?": must be format or scan}
1467 # Wide int (guaranteed at least 64-bit) handling
1468 test binary-43.1 {Tcl_BinaryObjCmd: format wide int} {} {
1469 binary format w 7810179016327718216
1471 test binary-43.2 {Tcl_BinaryObjCmd: format wide int} {} {
1472 binary format W 7810179016327718216
1475 test binary-44.1 {Tcl_BinaryObjCmd: scan wide int} {} {
1476 binary scan HelloTcl W x
1478 } 5216694956358656876
1479 test binary-44.2 {Tcl_BinaryObjCmd: scan wide int} {} {
1480 binary scan lcTolleH w x
1482 } 5216694956358656876
1483 test binary-44.3 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} {} {
1484 binary scan [binary format w [expr {wide(3) << 31}]] w x
1487 test binary-44.4 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} {} {
1488 binary scan [binary format W [expr {wide(3) << 31}]] W x
1492 test binary-45.1 {Tcl_BinaryObjCmd: combined wide int handling} {
1493 binary scan [binary format sws 16450 -1 19521] c* x
1495 } {66 64 -1 -1 -1 -1 -1 -1 -1 -1 65 76}
1496 test binary-45.2 {Tcl_BinaryObjCmd: combined wide int handling} {
1497 binary scan [binary format sWs 16450 0x7fffffff 19521] c* x
1499 } {66 64 0 0 0 0 127 -1 -1 -1 65 76}
1501 test binary-46.1 {Tcl_BinaryObjCmd: handling of non-ISO8859-1 chars} {
1502 binary format a* \u20ac
1504 test binary-46.2 {Tcl_BinaryObjCmd: handling of non-ISO8859-1 chars} {
1505 list [binary scan [binary format a* \u20ac\u20bd] s x] $x
1507 test binary-46.3 {Tcl_BinaryObjCmd: handling of non-ISO8859-1 chars} {
1511 list [binary scan [binary format a* \u20ac\u20bd] aaa x y z] $x $y $z
1512 } "2 \u00ac \u00bd {}"
1513 test binary-46.4 {Tcl_BinaryObjCmd: handling of non-ISO8859-1 chars} {
1514 set x [encoding convertto iso8859-15 \u20ac]
1515 set y [binary format a* $x]
1518 test binary-46.5 {Tcl_BinaryObjCmd: handling of non-ISO8859-1 chars} {
1519 set x [binary scan \u00a4 a* y]
1520 list $x $y [encoding convertfrom iso8859-15 $y]
1523 test binary-47.1 {Tcl_BinaryObjCmd: number cache reference count handling} {
1524 # This test is only reliable when memory debugging is turned on,
1525 # but without even memory debugging it should still generate the
1526 # expected answers and might therefore still pick up memory corruption
1527 # caused by [Bug 851747].
1528 list [binary scan aba ccc x x x] $x
1532 ::tcltest::cleanupTests