1 # This file tests the "binary" Tcl command.
3 # This file contains a collection of tests for one or more of the Tcl built-in
4 # commands. Sourcing this file into Tcl runs the tests and generates output
5 # 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 of
11 # this file, and for a DISCLAIMER OF ALL WARRANTIES.
13 source [file dirname [info script]]/testing.tcl
16 if {[testConstraint jim]} {
19 testConstraint bigEndian [expr {$tcl_platform(byteOrder) eq "bigEndian"}]
20 testConstraint littleEndian [expr {$tcl_platform(byteOrder) eq "littleEndian"}]
21 testConstraint maxCompatibility 0
22 testConstraint notImplemented 0
24 # ----------------------------------------------------------------------
26 test binary-0.1 {DupByteArrayInternalRep} {
27 set hdr [binary format cc 0 0316]
34 test binary-1.1 {Tcl_BinaryObjCmd: bad args} -body {
36 } -returnCodes error -match glob -result {wrong # args: *}
37 test binary-1.2 {Tcl_BinaryObjCmd: bad args} -returnCodes error -body {
39 } -match glob -result {*}
40 test binary-1.3 {Tcl_BinaryObjCmd: format error} -returnCodes error -body {
42 } -match glob -result {*}
43 test binary-1.4 {Tcl_BinaryObjCmd: format} -body {
47 test binary-2.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
49 } -result {not enough arguments for all format specifiers}
50 test binary-2.2 {Tcl_BinaryObjCmd: format} {
53 test binary-2.3 {Tcl_BinaryObjCmd: format} {
56 test binary-2.4 {Tcl_BinaryObjCmd: format} {
59 test binary-2.5 {Tcl_BinaryObjCmd: format} {
62 test binary-2.6 {Tcl_BinaryObjCmd: format} {
65 test binary-2.7 {Tcl_BinaryObjCmd: format} {
66 binary format a*a3 foobarbaz blat
68 test binary-2.8 {Tcl_BinaryObjCmd: format} {
69 binary format a*X3a2 foobar x
72 test binary-3.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
74 } -result {not enough arguments for all format specifiers}
75 test binary-3.2 {Tcl_BinaryObjCmd: format} {
78 test binary-3.3 {Tcl_BinaryObjCmd: format} {
81 test binary-3.4 {Tcl_BinaryObjCmd: format} {
84 test binary-3.5 {Tcl_BinaryObjCmd: format} {
87 test binary-3.6 {Tcl_BinaryObjCmd: format} {
90 test binary-3.7 {Tcl_BinaryObjCmd: format} {
91 binary format A*A3 foobarbaz blat
93 test binary-3.8 {Tcl_BinaryObjCmd: format} {
94 binary format A*X3A2 foobar x
97 test binary-4.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
99 } -result {not enough arguments for all format specifiers}
100 test binary-4.2 {Tcl_BinaryObjCmd: format} {
103 test binary-4.3 {Tcl_BinaryObjCmd: format} {
106 test binary-4.4 {Tcl_BinaryObjCmd: format} {
107 binary format B* 010011
109 test binary-4.5 {Tcl_BinaryObjCmd: format} {
110 binary format B8 01001101
112 test binary-4.6 {Tcl_BinaryObjCmd: format} {
113 binary format A2X2B9 oo 01001101
115 test binary-4.7 {Tcl_BinaryObjCmd: format} {
116 binary format B9 010011011010
118 test binary-4.8 {Tcl_BinaryObjCmd: format} {
119 binary format B2B3 10 010
121 test binary-4.9 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
122 binary format B1B5 1 foo
123 } -match glob -result {expected *}
125 test binary-5.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
127 } -result {not enough arguments for all format specifiers}
128 test binary-5.2 {Tcl_BinaryObjCmd: format} {
131 test binary-5.3 {Tcl_BinaryObjCmd: format} {
134 test binary-5.4 {Tcl_BinaryObjCmd: format} {
135 binary format b* 010011
137 test binary-5.5 {Tcl_BinaryObjCmd: format} {
138 binary format b8 01001101
140 test binary-5.6 {Tcl_BinaryObjCmd: format} {
141 binary format A2X2b9 oo 01001101
143 test binary-5.7 {Tcl_BinaryObjCmd: format} {
144 binary format b9 010011011010
146 test binary-5.8 {Tcl_BinaryObjCmd: format} {
149 test binary-5.9 {Tcl_BinaryObjCmd: format} {
150 binary format b2b3 10 010
152 test binary-5.10 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
153 binary format b1b5 1 foo
154 } -match glob -result {expected *}
156 test binary-6.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
158 } -result {not enough arguments for all format specifiers}
159 test binary-6.2 {Tcl_BinaryObjCmd: format} {
162 test binary-6.3 {Tcl_BinaryObjCmd: format} {
165 test binary-6.4 {Tcl_BinaryObjCmd: format} {
168 test binary-6.5 {Tcl_BinaryObjCmd: format} {
169 binary format h* baadf00d
171 test binary-6.6 {Tcl_BinaryObjCmd: format} {
172 binary format h4 c410
174 test binary-6.7 {Tcl_BinaryObjCmd: format} {
175 binary format h6 c4102
177 test binary-6.8 {Tcl_BinaryObjCmd: format} {
178 binary format h5 c41020304
180 test binary-6.9 {Tcl_BinaryObjCmd: format} {
181 binary format a3X3h5 foo 2
183 test binary-6.10 {Tcl_BinaryObjCmd: format} {
184 binary format h2h3 23 456
186 test binary-6.11 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
188 } -match glob -result {expected *}
190 test binary-7.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
192 } -result {not enough arguments for all format specifiers}
193 test binary-7.2 {Tcl_BinaryObjCmd: format} {
196 test binary-7.3 {Tcl_BinaryObjCmd: format} {
199 test binary-7.4 {Tcl_BinaryObjCmd: format} {
202 test binary-7.5 {Tcl_BinaryObjCmd: format} {
203 binary format H* baadf00d
205 test binary-7.6 {Tcl_BinaryObjCmd: format} {
206 binary format H4 c410
208 test binary-7.7 {Tcl_BinaryObjCmd: format} {
209 binary format H6 c4102
211 test binary-7.8 {Tcl_BinaryObjCmd: format} {
212 binary format H5 c41023304
214 test binary-7.9 {Tcl_BinaryObjCmd: format} {
215 binary format a3X3H5 foo 2
217 test binary-7.10 {Tcl_BinaryObjCmd: format} {
218 binary format H2H3 23 456
220 test binary-7.11 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
222 } -match glob -result {expected *}
224 test binary-8.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
226 } -result {not enough arguments for all format specifiers}
227 test binary-8.2 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
229 } -match glob -result {expected *}
230 test binary-8.3 {Tcl_BinaryObjCmd: format} {
231 binary format c0 0x50
233 test binary-8.4 {Tcl_BinaryObjCmd: format} {
236 test binary-8.5 {Tcl_BinaryObjCmd: format} {
237 binary format c 0x5052
239 test binary-8.6 {Tcl_BinaryObjCmd: format} {
240 binary format c2 {0x50 0x52}
242 test binary-8.7 {Tcl_BinaryObjCmd: format} {
243 binary format c2 {0x50 0x52 0x53}
245 test binary-8.8 {Tcl_BinaryObjCmd: format} {
246 binary format c* {0x50 0x52}
248 test binary-8.9 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
249 binary format c2 {0x50}
250 } -result {number of elements in list does not match count}
251 test binary-8.10 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
254 } -result "expected integer but got \"0x50 0x51\""
255 test binary-8.11 {Tcl_BinaryObjCmd: format} {
260 test binary-9.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
262 } -result {not enough arguments for all format specifiers}
263 test binary-9.2 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
265 } -result {expected integer but got "blat"}
266 test binary-9.3 {Tcl_BinaryObjCmd: format} {
267 binary format s0 0x50
269 test binary-9.4 {Tcl_BinaryObjCmd: format} {
272 test binary-9.5 {Tcl_BinaryObjCmd: format} {
273 binary format s 0x5052
275 test binary-9.6 {Tcl_BinaryObjCmd: format} {
276 binary format s 0x505251 0x53
278 test binary-9.7 {Tcl_BinaryObjCmd: format} {
279 binary format s2 {0x50 0x52}
281 test binary-9.8 {Tcl_BinaryObjCmd: format} {
282 binary format s* {0x5051 0x52}
284 test binary-9.9 {Tcl_BinaryObjCmd: format} {
285 binary format s2 {0x50 0x52 0x53} 0x54
287 test binary-9.10 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
288 binary format s2 {0x50}
289 } -result {number of elements in list does not match count}
290 test binary-9.11 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
293 } -result "expected integer but got \"0x50 0x51\""
294 test binary-9.12 {Tcl_BinaryObjCmd: format} {
299 test binary-10.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
301 } -result {not enough arguments for all format specifiers}
302 test binary-10.2 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
304 } -result {expected integer but got "blat"}
305 test binary-10.3 {Tcl_BinaryObjCmd: format} {
306 binary format S0 0x50
308 test binary-10.4 {Tcl_BinaryObjCmd: format} {
311 test binary-10.5 {Tcl_BinaryObjCmd: format} {
312 binary format S 0x5052
314 test binary-10.6 {Tcl_BinaryObjCmd: format} {
315 binary format S 0x505251 0x53
317 test binary-10.7 {Tcl_BinaryObjCmd: format} {
318 binary format S2 {0x50 0x52}
320 test binary-10.8 {Tcl_BinaryObjCmd: format} {
321 binary format S* {0x5051 0x52}
323 test binary-10.9 {Tcl_BinaryObjCmd: format} {
324 binary format S2 {0x50 0x52 0x53} 0x54
326 test binary-10.10 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
327 binary format S2 {0x50}
328 } -result {number of elements in list does not match count}
329 test binary-10.11 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
332 } -result "expected integer but got \"0x50 0x51\""
333 test binary-10.12 {Tcl_BinaryObjCmd: format} {
338 test binary-11.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
340 } -result {not enough arguments for all format specifiers}
341 test binary-11.2 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
343 } -result {expected integer but got "blat"}
344 test binary-11.3 {Tcl_BinaryObjCmd: format} {
345 binary format i0 0x50
347 test binary-11.4 {Tcl_BinaryObjCmd: format} {
350 test binary-11.5 {Tcl_BinaryObjCmd: format} {
351 binary format i 0x5052
353 test binary-11.6 {Tcl_BinaryObjCmd: format} {
354 binary format i 0x505251 0x53
356 test binary-11.7 {Tcl_BinaryObjCmd: format} {
357 binary format i1 {0x505251 0x53}
359 test binary-11.8 {Tcl_BinaryObjCmd: format} {
360 binary format i 0x53525150
362 test binary-11.9 {Tcl_BinaryObjCmd: format} {
363 binary format i2 {0x50 0x52}
364 } P\x00\x00\x00R\x00\x00\x00
365 test binary-11.10 {Tcl_BinaryObjCmd: format} {
366 binary format i* {0x50515253 0x52}
368 test binary-11.11 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
369 binary format i2 {0x50}
370 } -result {number of elements in list does not match count}
371 test binary-11.12 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
374 } -result "expected integer but got \"0x50 0x51\""
375 test binary-11.13 {Tcl_BinaryObjCmd: format} {
380 test binary-12.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
382 } -result {not enough arguments for all format specifiers}
383 test binary-12.2 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
385 } -result {expected integer but got "blat"}
386 test binary-12.3 {Tcl_BinaryObjCmd: format} {
387 binary format I0 0x50
389 test binary-12.4 {Tcl_BinaryObjCmd: format} {
392 test binary-12.5 {Tcl_BinaryObjCmd: format} {
393 binary format I 0x5052
395 test binary-12.6 {Tcl_BinaryObjCmd: format} {
396 binary format I 0x505251 0x53
398 test binary-12.7 {Tcl_BinaryObjCmd: format} {
399 binary format I1 {0x505251 0x53}
401 test binary-12.8 {Tcl_BinaryObjCmd: format} {
402 binary format I 0x53525150
404 test binary-12.9 {Tcl_BinaryObjCmd: format} {
405 binary format I2 {0x50 0x52}
406 } \x00\x00\x00P\x00\x00\x00R
407 test binary-12.10 {Tcl_BinaryObjCmd: format} {
408 binary format I* {0x50515253 0x52}
410 test binary-12.11 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
411 binary format i2 {0x50}
412 } -result {number of elements in list does not match count}
413 test binary-12.12 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
416 } -result "expected integer but got \"0x50 0x51\""
417 test binary-12.13 {Tcl_BinaryObjCmd: format} {
422 test binary-13.1 {Tcl_BinaryObjCmd: format} {
423 list [catch {binary format f} msg] $msg
424 } {1 {not enough arguments for all format specifiers}}
425 test binary-13.2 {Tcl_BinaryObjCmd: format} {
426 list [catch {binary format f blat} msg] $msg
427 } {1 {expected floating-point number but got "blat"}}
428 test binary-13.3 {Tcl_BinaryObjCmd: format} {
431 test binary-13.4 {Tcl_BinaryObjCmd: format} bigEndian {
434 test binary-13.5 {Tcl_BinaryObjCmd: format} littleEndian {
437 test binary-13.6 {Tcl_BinaryObjCmd: format} bigEndian {
438 binary format f* {1.6 3.4}
439 } \x3f\xcc\xcc\xcd\x40\x59\x99\x9a
440 test binary-13.7 {Tcl_BinaryObjCmd: format} littleEndian {
441 binary format f* {1.6 3.4}
442 } \xcd\xcc\xcc\x3f\x9a\x99\x59\x40
443 test binary-13.8 {Tcl_BinaryObjCmd: format} bigEndian {
444 binary format f2 {1.6 3.4}
445 } \x3f\xcc\xcc\xcd\x40\x59\x99\x9a
446 test binary-13.9 {Tcl_BinaryObjCmd: format} littleEndian {
447 binary format f2 {1.6 3.4}
448 } \xcd\xcc\xcc\x3f\x9a\x99\x59\x40
449 test binary-13.10 {Tcl_BinaryObjCmd: format} bigEndian {
450 binary format f2 {1.6 3.4 5.6}
451 } \x3f\xcc\xcc\xcd\x40\x59\x99\x9a
452 test binary-13.11 {Tcl_BinaryObjCmd: format} littleEndian {
453 binary format f2 {1.6 3.4 5.6}
454 } \xcd\xcc\xcc\x3f\x9a\x99\x59\x40
455 test binary-13.12 {Tcl_BinaryObjCmd: float overflow} {bigEndian maxCompatibility} {
456 binary format f -3.402825e+38
458 test binary-13.13 {Tcl_BinaryObjCmd: float overflow} {littleEndian maxCompatibility} {
459 binary format f -3.402825e+38
461 test binary-13.14 {Tcl_BinaryObjCmd: float underflow} bigEndian {
462 binary format f -3.402825e-100
464 test binary-13.15 {Tcl_BinaryObjCmd: float underflow} littleEndian {
465 binary format f -3.402825e-100
467 test binary-13.16 {Tcl_BinaryObjCmd: format} {
468 list [catch {binary format f2 {1.6}} msg] $msg
469 } {1 {number of elements in list does not match count}}
470 test binary-13.17 {Tcl_BinaryObjCmd: format} {
472 list [catch {binary format f $a} msg] $msg
473 } [list 1 "expected floating-point number but got \"1.6 3.4\""]
474 test binary-13.18 {Tcl_BinaryObjCmd: format} bigEndian {
478 test binary-13.19 {Tcl_BinaryObjCmd: format} littleEndian {
483 test binary-14.1 {Tcl_BinaryObjCmd: format} {
484 list [catch {binary format d} msg] $msg
485 } {1 {not enough arguments for all format specifiers}}
486 test binary-14.2 {Tcl_BinaryObjCmd: format} {
487 list [catch {binary format d blat} msg] $msg
488 } {1 {expected floating-point number but got "blat"}}
489 test binary-14.3 {Tcl_BinaryObjCmd: format} {
492 test binary-14.4 {Tcl_BinaryObjCmd: format} bigEndian {
494 } \x3f\xf9\x99\x99\x99\x99\x99\x9a
495 test binary-14.5 {Tcl_BinaryObjCmd: format} littleEndian {
497 } \x9a\x99\x99\x99\x99\x99\xf9\x3f
498 test binary-14.6 {Tcl_BinaryObjCmd: format} bigEndian {
499 binary format d* {1.6 3.4}
500 } \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33
501 test binary-14.7 {Tcl_BinaryObjCmd: format} littleEndian {
502 binary format d* {1.6 3.4}
503 } \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40
504 test binary-14.8 {Tcl_BinaryObjCmd: format} bigEndian {
505 binary format d2 {1.6 3.4}
506 } \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33
507 test binary-14.9 {Tcl_BinaryObjCmd: format} littleEndian {
508 binary format d2 {1.6 3.4}
509 } \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40
510 test binary-14.10 {Tcl_BinaryObjCmd: format} bigEndian {
511 binary format d2 {1.6 3.4 5.6}
512 } \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33
513 test binary-14.11 {Tcl_BinaryObjCmd: format} littleEndian {
514 binary format d2 {1.6 3.4 5.6}
515 } \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40
516 test binary-14.14 {Tcl_BinaryObjCmd: format} {
517 list [catch {binary format d2 {1.6}} msg] $msg
518 } {1 {number of elements in list does not match count}}
519 test binary-14.15 {Tcl_BinaryObjCmd: format} {
521 list [catch {binary format d $a} msg] $msg
522 } [list 1 "expected floating-point number but got \"1.6 3.4\""]
523 test binary-14.16 {Tcl_BinaryObjCmd: format} bigEndian {
526 } \x3f\xf9\x99\x99\x99\x99\x99\x9a
527 test binary-14.17 {Tcl_BinaryObjCmd: format} littleEndian {
530 } \x9a\x99\x99\x99\x99\x99\xf9\x3f
531 test binary-14.18 {FormatNumber: Bug 1116542} {
532 binary scan [binary format d 1.25] d w
536 test binary-15.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
537 binary format ax*a "y" "z"
538 } -result {cannot use "*" in format string with "x"}
539 test binary-15.2 {Tcl_BinaryObjCmd: format} {
540 binary format axa "y" "z"
542 test binary-15.3 {Tcl_BinaryObjCmd: format} {
543 binary format ax3a "y" "z"
545 test binary-15.4 {Tcl_BinaryObjCmd: format} {
546 binary format a*X3x3a* "foo" "z"
548 test binary-15.5 {Tcl_BinaryObjCmd: format - bug #1923966} {
551 test binary-15.6 {Tcl_BinaryObjCmd: format - bug #1923966} {
552 binary format x0ss 1 1
554 test binary-15.7 {Tcl_BinaryObjCmd: format - bug #1923966} {
557 test binary-15.8 {Tcl_BinaryObjCmd: format - bug #1923966} {
558 binary format x1ss 1 1
559 } \x00\x01\x00\x01\x00
561 test binary-16.1 {Tcl_BinaryObjCmd: format} {
562 binary format a*X*a "foo" "z"
564 test binary-16.2 {Tcl_BinaryObjCmd: format} {
565 binary format aX3a "y" "z"
567 test binary-16.3 {Tcl_BinaryObjCmd: format} {
568 binary format a*Xa* "foo" "zy"
570 test binary-16.4 {Tcl_BinaryObjCmd: format} {
571 binary format a*X3a "foobar" "z"
573 test binary-16.5 {Tcl_BinaryObjCmd: format} {
574 binary format a*X3aX2a "foobar" "z" "b"
577 test binary-17.1 {Tcl_BinaryObjCmd: format} {
580 test binary-17.2 {Tcl_BinaryObjCmd: format} {
581 binary format @5a2 "ab"
582 } \x00\x00\x00\x00\x00\x61\x62
583 test binary-17.3 {Tcl_BinaryObjCmd: format} {
584 binary format {a* @0 a2 @* a*} "foobar" "ab" "blat"
587 test binary-18.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
588 binary format u0a3 abc abd
589 } -result {bad field specifier "u"}
591 test binary-19.1 {Tcl_BinaryObjCmd: errors} -returnCodes error -body {
593 } -match glob -result {*}
594 test binary-19.2 {Tcl_BinaryObjCmd: errors} -returnCodes error -body {
596 } -result {wrong # args: should be "binary scan value formatString ?varName ...?"}
597 test binary-19.3 {Tcl_BinaryObjCmd: scan} {
601 test binary-20.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
603 } -result {not enough arguments for all format specifiers}
604 test binary-20.2 {Tcl_BinaryObjCmd: scan} -setup {
605 unset -nocomplain arg1
606 } -returnCodes error -body {
608 binary scan abc a arg1(a)
609 } -result {can't set "arg1(a)": variable isn't array}
610 test binary-20.3 {Tcl_BinaryObjCmd: scan} -setup {
611 unset -nocomplain arg1
614 list [binary scan abc a0 arg1] $arg1
616 test binary-20.4 {Tcl_BinaryObjCmd: scan} -setup {
617 unset -nocomplain arg1
619 list [binary scan abc a* arg1] $arg1
621 test binary-20.5 {Tcl_BinaryObjCmd: scan} -setup {
622 unset -nocomplain arg1
624 list [binary scan abc a5 arg1] [info exists arg1]
626 test binary-20.6 {Tcl_BinaryObjCmd: scan} {
628 list [binary scan abc a2 arg1] $arg1
630 test binary-20.7 {Tcl_BinaryObjCmd: scan} -setup {
631 unset -nocomplain arg1
632 unset -nocomplain arg2
634 list [binary scan abcdef a2a2 arg1 arg2] $arg1 $arg2
636 test binary-20.8 {Tcl_BinaryObjCmd: scan} -setup {
637 unset -nocomplain arg1
639 list [binary scan abc a2 arg1(a)] $arg1(a)
641 test binary-20.9 {Tcl_BinaryObjCmd: scan} -setup {
642 unset -nocomplain arg1
644 list [binary scan abc a arg1(a)] $arg1(a)
647 # As soon as a conversion runs out of bytes, scan should stop
648 test binary-20.10 {Tcl_BinaryObjCmd: scan, too few bytes} -setup {
649 unset -nocomplain arg1 arg2
651 list [binary scan abc a5a2 arg1 arg2] [info exists arg1] [info exists arg2]
654 test binary-21.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
656 } -result {not enough arguments for all format specifiers}
657 test binary-21.2 {Tcl_BinaryObjCmd: scan} -setup {
658 unset -nocomplain arg1
659 } -returnCodes error -body {
661 binary scan abc A arg1(a)
662 } -result {can't set "arg1(a)": variable isn't array}
663 test binary-21.3 {Tcl_BinaryObjCmd: scan} -setup {
664 unset -nocomplain arg1
667 list [binary scan abc A0 arg1] $arg1
669 test binary-21.4 {Tcl_BinaryObjCmd: scan} -setup {
670 unset -nocomplain arg1
672 list [binary scan abc A* arg1] $arg1
674 test binary-21.5 {Tcl_BinaryObjCmd: scan} -setup {
675 unset -nocomplain arg1
677 list [binary scan abc A5 arg1] [info exists arg1]
679 test binary-21.6 {Tcl_BinaryObjCmd: scan} {
681 list [binary scan abc A2 arg1] $arg1
683 test binary-21.7 {Tcl_BinaryObjCmd: scan} -setup {
684 unset -nocomplain arg1
685 unset -nocomplain arg2
687 list [binary scan abcdef A2A2 arg1 arg2] $arg1 $arg2
689 test binary-21.8 {Tcl_BinaryObjCmd: scan} -setup {
690 unset -nocomplain arg1
692 list [binary scan abc A2 arg1(a)] $arg1(a)
694 test binary-21.9 {Tcl_BinaryObjCmd: scan} -setup {
695 unset -nocomplain arg1
697 list [binary scan abc A2 arg1(a)] $arg1(a)
699 test binary-21.10 {Tcl_BinaryObjCmd: scan} -setup {
700 unset -nocomplain arg1
702 list [binary scan abc A arg1(a)] $arg1(a)
704 test binary-21.11 {Tcl_BinaryObjCmd: scan} -setup {
705 unset -nocomplain arg1
707 list [binary scan "abc def \x00 " A* arg1] $arg1
708 } -result {1 {abc def}}
709 test binary-21.12 {Tcl_BinaryObjCmd: scan} -setup {
710 unset -nocomplain arg1
712 list [binary scan "abc def \x00ghi " A* arg1] $arg1
713 } -result [list 1 "abc def \x00ghi"]
715 test binary-22.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
717 } -result {not enough arguments for all format specifiers}
718 test binary-22.2 {Tcl_BinaryObjCmd: scan} {
719 unset -nocomplain arg1
720 list [binary scan \x52\x53 b* arg1] $arg1
721 } {1 0100101011001010}
722 test binary-22.3 {Tcl_BinaryObjCmd: scan} {
723 unset -nocomplain arg1
724 list [binary scan \x82\x53 b arg1] $arg1
726 test binary-22.4 {Tcl_BinaryObjCmd: scan} {
727 unset -nocomplain arg1
728 list [binary scan \x82\x53 b1 arg1] $arg1
730 test binary-22.5 {Tcl_BinaryObjCmd: scan} {
731 unset -nocomplain arg1
732 list [binary scan \x82\x53 b0 arg1] $arg1
734 test binary-22.6 {Tcl_BinaryObjCmd: scan} {
735 unset -nocomplain arg1
736 list [binary scan \x52\x53 b5 arg1] $arg1
738 test binary-22.7 {Tcl_BinaryObjCmd: scan} {
739 unset -nocomplain arg1
740 list [binary scan \x52\x53 b8 arg1] $arg1
742 test binary-22.8 {Tcl_BinaryObjCmd: scan} {
743 unset -nocomplain arg1
744 list [binary scan \x52\x53 b14 arg1] $arg1
746 test binary-22.9 {Tcl_BinaryObjCmd: scan} {
747 unset -nocomplain arg1
749 list [binary scan \x52 b14 arg1] $arg1
751 test binary-22.10 {Tcl_BinaryObjCmd: scan} -setup {
752 unset -nocomplain arg1
753 } -returnCodes error -body {
755 binary scan \x52\x53 b1 arg1(a)
756 } -result {can't set "arg1(a)": variable isn't array}
757 test binary-22.11 {Tcl_BinaryObjCmd: scan} -setup {
758 unset -nocomplain arg1 arg2
762 list [binary scan \x07\x87\x05 b5b* arg1 arg2] $arg1 $arg2
763 } -result {2 11100 1110000110100000}
765 # As soon as a conversion runs out of bytes, scan should stop
766 test binary-20.12 {Tcl_BinaryObjCmd: scan, too few bytes} {
767 unset -nocomplain arg1 arg2
770 list [binary scan \x52 b14b8 arg1 arg2] $arg1 $arg2
773 test binary-23.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
775 } -result {not enough arguments for all format specifiers}
776 test binary-23.2 {Tcl_BinaryObjCmd: scan} {
777 unset -nocomplain arg1
778 list [binary scan \x52\x53 B* arg1] $arg1
779 } {1 0101001001010011}
780 test binary-23.3 {Tcl_BinaryObjCmd: scan} {
781 unset -nocomplain arg1
782 list [binary scan \x82\x53 B arg1] $arg1
784 test binary-23.4 {Tcl_BinaryObjCmd: scan} {
785 unset -nocomplain arg1
786 list [binary scan \x82\x53 B1 arg1] $arg1
788 test binary-23.5 {Tcl_BinaryObjCmd: scan} {
789 unset -nocomplain arg1
790 list [binary scan \x52\x53 B0 arg1] $arg1
792 test binary-23.6 {Tcl_BinaryObjCmd: scan} {
793 unset -nocomplain arg1
794 list [binary scan \x52\x53 B5 arg1] $arg1
796 test binary-23.7 {Tcl_BinaryObjCmd: scan} {
797 unset -nocomplain arg1
798 list [binary scan \x52\x53 B8 arg1] $arg1
800 test binary-23.8 {Tcl_BinaryObjCmd: scan} {
801 unset -nocomplain arg1
802 list [binary scan \x52\x53 B14 arg1] $arg1
804 test binary-23.9 {Tcl_BinaryObjCmd: scan} {
805 unset -nocomplain arg1
807 list [binary scan \x52 B14 arg1] $arg1
809 test binary-23.10 {Tcl_BinaryObjCmd: scan} -setup {
810 unset -nocomplain arg1
811 } -returnCodes error -body {
813 binary scan \x52\x53 B1 arg1(a)
814 } -result {can't set "arg1(a)": variable isn't array}
815 test binary-23.11 {Tcl_BinaryObjCmd: scan} -setup {
816 unset -nocomplain arg1 arg2
820 list [binary scan \x70\x87\x05 B5B* arg1 arg2] $arg1 $arg2
821 } -result {2 01110 1000011100000101}
823 test binary-24.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
825 } -result {not enough arguments for all format specifiers}
826 test binary-24.2 {Tcl_BinaryObjCmd: scan} {
827 unset -nocomplain arg1
828 list [binary scan \x52\xa3 h* arg1] $arg1
830 test binary-24.3 {Tcl_BinaryObjCmd: scan} {
831 unset -nocomplain arg1
832 list [binary scan \xc2\xa3 h arg1] $arg1
834 test binary-24.4 {Tcl_BinaryObjCmd: scan} {
835 unset -nocomplain arg1
836 list [binary scan \x82\x53 h1 arg1] $arg1
838 test binary-24.5 {Tcl_BinaryObjCmd: scan} {
839 unset -nocomplain arg1
840 list [binary scan \x52\x53 h0 arg1] $arg1
842 test binary-24.6 {Tcl_BinaryObjCmd: scan} {
843 unset -nocomplain arg1
844 list [binary scan \xf2\x53 h2 arg1] $arg1
846 test binary-24.7 {Tcl_BinaryObjCmd: scan} {
847 unset -nocomplain arg1
848 list [binary scan \x52\x53 h3 arg1] $arg1
850 test binary-24.8 {Tcl_BinaryObjCmd: scan} {
851 unset -nocomplain arg1
853 list [binary scan \x52 h3 arg1] $arg1
855 test binary-24.9 {Tcl_BinaryObjCmd: scan} -setup {
856 unset -nocomplain arg1
857 } -returnCodes error -body {
859 binary scan \x52\x53 h1 arg1(a)
860 } -result {can't set "arg1(a)": variable isn't array}
861 test binary-24.10 {Tcl_BinaryObjCmd: scan} -setup {
862 unset -nocomplain arg1 arg2
866 list [binary scan \x70\x87\x05 h2h* arg1 arg2] $arg1 $arg2
867 } -result {2 07 7850}
869 test binary-25.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
871 } -result {not enough arguments for all format specifiers}
872 test binary-25.2 {Tcl_BinaryObjCmd: scan} {
873 unset -nocomplain arg1
874 list [binary scan \x52\xa3 H* arg1] $arg1
876 test binary-25.3 {Tcl_BinaryObjCmd: scan} {
877 unset -nocomplain arg1
878 list [binary scan \xc2\xa3 H arg1] $arg1
880 test binary-25.4 {Tcl_BinaryObjCmd: scan} {
881 unset -nocomplain arg1
882 list [binary scan \x82\x53 H1 arg1] $arg1
884 test binary-25.5 {Tcl_BinaryObjCmd: scan} {
885 unset -nocomplain arg1
886 list [binary scan \x52\x53 H0 arg1] $arg1
888 test binary-25.6 {Tcl_BinaryObjCmd: scan} {
889 unset -nocomplain arg1
890 list [binary scan \xf2\x53 H2 arg1] $arg1
892 test binary-25.7 {Tcl_BinaryObjCmd: scan} {
893 unset -nocomplain arg1
894 list [binary scan \x52\x53 H3 arg1] $arg1
896 test binary-25.8 {Tcl_BinaryObjCmd: scan} {
897 unset -nocomplain arg1
899 list [binary scan \x52 H3 arg1] $arg1
901 test binary-25.9 {Tcl_BinaryObjCmd: scan} -setup {
902 unset -nocomplain arg1
903 } -returnCodes error -body {
905 binary scan \x52\x53 H1 arg1(a)
906 } -result {can't set "arg1(a)": variable isn't array}
907 test binary-25.10 {Tcl_BinaryObjCmd: scan} {
908 unset -nocomplain arg1 arg2
911 list [binary scan \x70\x87\x05 H2H* arg1 arg2] $arg1 $arg2
914 test binary-26.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
916 } -result {not enough arguments for all format specifiers}
917 test binary-26.2 {Tcl_BinaryObjCmd: scan} {
918 unset -nocomplain arg1
919 list [binary scan \x52\xa3 c* arg1] $arg1
921 test binary-26.3 {Tcl_BinaryObjCmd: scan} {
922 unset -nocomplain arg1
923 list [binary scan \x52\xa3 c arg1] $arg1
925 test binary-26.4 {Tcl_BinaryObjCmd: scan} {
926 unset -nocomplain arg1
927 list [binary scan \x52\xa3 c1 arg1] $arg1
929 test binary-26.5 {Tcl_BinaryObjCmd: scan} {
930 unset -nocomplain arg1
931 list [binary scan \x52\xa3 c0 arg1] $arg1
933 test binary-26.6 {Tcl_BinaryObjCmd: scan} {
934 unset -nocomplain arg1
935 list [binary scan \x52\xa3 c2 arg1] $arg1
937 test binary-26.7 {Tcl_BinaryObjCmd: scan} {
938 unset -nocomplain arg1
939 list [binary scan \xff c arg1] $arg1
941 test binary-26.8 {Tcl_BinaryObjCmd: scan} {
942 unset -nocomplain arg1
944 list [binary scan \x52 c3 arg1] $arg1
946 test binary-26.9 {Tcl_BinaryObjCmd: scan} -setup {
947 unset -nocomplain arg1
948 } -returnCodes error -body {
950 binary scan \x52\x53 c1 arg1(a)
951 } -result {can't set "arg1(a)": variable isn't array}
952 test binary-26.10 {Tcl_BinaryObjCmd: scan} {
953 unset -nocomplain arg1 arg2
956 list [binary scan \x70\x87\x05 c2c* arg1 arg2] $arg1 $arg2
958 test binary-26.11 {Tcl_BinaryObjCmd: scan} {
959 unset -nocomplain arg1
960 list [binary scan \x52\xa3 cu* arg1] $arg1
962 test binary-26.12 {Tcl_BinaryObjCmd: scan} {
963 unset -nocomplain arg1
964 list [binary scan \x52\xa3 cu arg1] $arg1
966 test binary-26.13 {Tcl_BinaryObjCmd: scan} {
967 unset -nocomplain arg1
968 list [binary scan \xff cu arg1] $arg1
970 test binary-26.14 {Tcl_BinaryObjCmd: scan} {
971 unset -nocomplain arg1 arg2
974 list [binary scan \x80\x80 cuc arg1 arg2] $arg1 $arg2
976 test binary-26.15 {Tcl_BinaryObjCmd: scan} {
977 unset -nocomplain arg1 arg2
980 list [binary scan \x80\x80 ccu arg1 arg2] $arg1 $arg2
983 test binary-27.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
985 } -result {not enough arguments for all format specifiers}
986 test binary-27.2 {Tcl_BinaryObjCmd: scan} {
987 unset -nocomplain arg1
988 list [binary scan \x52\xa3\x53\x54 s* arg1] $arg1
990 test binary-27.3 {Tcl_BinaryObjCmd: scan} {
991 unset -nocomplain arg1
992 list [binary scan \x52\xa3\x53\x54 s arg1] $arg1
994 test binary-27.4 {Tcl_BinaryObjCmd: scan} {
995 unset -nocomplain arg1
996 list [binary scan \x52\xa3 s1 arg1] $arg1
998 test binary-27.5 {Tcl_BinaryObjCmd: scan} {
999 unset -nocomplain arg1
1000 list [binary scan \x52\xa3 s0 arg1] $arg1
1002 test binary-27.6 {Tcl_BinaryObjCmd: scan} {
1003 unset -nocomplain arg1
1004 list [binary scan \x52\xa3\x53\x54 s2 arg1] $arg1
1005 } {1 {-23726 21587}}
1006 test binary-27.7 {Tcl_BinaryObjCmd: scan} {
1007 unset -nocomplain arg1
1009 list [binary scan \x52 s1 arg1] $arg1
1011 test binary-27.8 {Tcl_BinaryObjCmd: scan} -setup {
1012 unset -nocomplain arg1
1013 } -returnCodes error -body {
1015 binary scan \x52\x53 s1 arg1(a)
1016 } -result {can't set "arg1(a)": variable isn't array}
1017 test binary-27.9 {Tcl_BinaryObjCmd: scan} {
1018 unset -nocomplain arg1 arg2
1021 list [binary scan \x52\xa3\x53\x54\x05 s2c* arg1 arg2] $arg1 $arg2
1022 } {2 {-23726 21587} 5}
1023 test binary-27.10 {Tcl_BinaryObjCmd: scan} {
1024 unset -nocomplain arg1
1025 list [binary scan \x52\xa3\x53\x54 su* arg1] $arg1
1027 test binary-27.11 {Tcl_BinaryObjCmd: scan} {
1028 unset -nocomplain arg1 arg2
1031 list [binary scan \xff\xff\xff\xff sus arg1 arg2] $arg1 $arg2
1033 test binary-27.12 {Tcl_BinaryObjCmd: scan} {
1034 unset -nocomplain arg1 arg2
1037 list [binary scan \xff\xff\xff\xff ssu arg1 arg2] $arg1 $arg2
1040 test binary-28.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
1042 } -result {not enough arguments for all format specifiers}
1043 test binary-28.2 {Tcl_BinaryObjCmd: scan} {
1044 unset -nocomplain arg1
1045 list [binary scan \x52\xa3\x53\x54 S* arg1] $arg1
1047 test binary-28.3 {Tcl_BinaryObjCmd: scan} {
1048 unset -nocomplain arg1
1049 list [binary scan \x52\xa3\x53\x54 S arg1] $arg1
1051 test binary-28.4 {Tcl_BinaryObjCmd: scan} {
1052 unset -nocomplain arg1
1053 list [binary scan \x52\xa3 S1 arg1] $arg1
1055 test binary-28.5 {Tcl_BinaryObjCmd: scan} {
1056 unset -nocomplain arg1
1057 list [binary scan \x52\xa3 S0 arg1] $arg1
1059 test binary-28.6 {Tcl_BinaryObjCmd: scan} {
1060 unset -nocomplain arg1
1061 list [binary scan \x52\xa3\x53\x54 S2 arg1] $arg1
1063 test binary-28.7 {Tcl_BinaryObjCmd: scan} {
1064 unset -nocomplain arg1
1066 list [binary scan \x52 S1 arg1] $arg1
1068 test binary-28.8 {Tcl_BinaryObjCmd: scan} -setup {
1069 unset -nocomplain arg1
1070 } -returnCodes error -body {
1072 binary scan \x52\x53 S1 arg1(a)
1073 } -result {can't set "arg1(a)": variable isn't array}
1074 test binary-28.9 {Tcl_BinaryObjCmd: scan} {
1075 unset -nocomplain arg1 arg2
1078 list [binary scan \x52\xa3\x53\x54\x05 S2c* arg1 arg2] $arg1 $arg2
1079 } {2 {21155 21332} 5}
1080 test binary-28.10 {Tcl_BinaryObjCmd: scan} {
1081 unset -nocomplain arg1
1082 list [binary scan \x52\xa3\x53\x54 Su* arg1] $arg1
1084 test binary-28.11 {Tcl_BinaryObjCmd: scan} {
1085 unset -nocomplain arg1
1086 list [binary scan \xa3\x52\x54\x53 Su* arg1] $arg1
1089 test binary-29.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
1091 } -result {not enough arguments for all format specifiers}
1092 test binary-29.2 {Tcl_BinaryObjCmd: scan} {
1093 unset -nocomplain arg1
1094 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 i* arg1] $arg1
1095 } {1 {1414767442 67305985}}
1096 test binary-29.3 {Tcl_BinaryObjCmd: scan} {
1097 unset -nocomplain arg1
1098 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 i arg1] $arg1
1100 test binary-29.4 {Tcl_BinaryObjCmd: scan} {
1101 unset -nocomplain arg1
1102 list [binary scan \x52\xa3\x53\x54 i1 arg1] $arg1
1104 test binary-29.5 {Tcl_BinaryObjCmd: scan} {
1105 unset -nocomplain arg1
1106 list [binary scan \x52\xa3\x53 i0 arg1] $arg1
1108 test binary-29.6 {Tcl_BinaryObjCmd: scan} {
1109 unset -nocomplain arg1
1110 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 i2 arg1] $arg1
1111 } {1 {1414767442 67305985}}
1112 test binary-29.7 {Tcl_BinaryObjCmd: scan} {
1113 unset -nocomplain arg1
1115 list [binary scan \x52 i1 arg1] $arg1
1117 test binary-29.8 {Tcl_BinaryObjCmd: scan} -setup {
1118 unset -nocomplain arg1
1119 } -returnCodes error -body {
1121 binary scan \x52\x53\x53\x54 i1 arg1(a)
1122 } -result {can't set "arg1(a)": variable isn't array}
1123 test binary-29.9 {Tcl_BinaryObjCmd: scan} {
1124 unset -nocomplain arg1 arg2
1127 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04\x05 i2c* arg1 arg2] $arg1 $arg2
1128 } {2 {1414767442 67305985} 5}
1129 test binary-29.10 {Tcl_BinaryObjCmd: scan} {
1130 unset -nocomplain arg1 arg2
1131 list [binary scan \xff\xff\xff\xff\xff\xff\xff\xff iui arg1 arg2] $arg1 $arg2
1133 test binary-29.11 {Tcl_BinaryObjCmd: scan} {
1134 unset -nocomplain arg1 arg2
1135 list [binary scan \xff\xff\xff\xff\xff\xff\xff\xff iiu arg1 arg2] $arg1 $arg2
1137 test binary-29.12 {Tcl_BinaryObjCmd: scan} {
1138 unset -nocomplain arg1 arg2
1139 list [binary scan \x80\x00\x00\x00\x00\x00\x00\x80 iuiu arg1 arg2] $arg1 $arg2
1140 } {2 128 2147483648}
1142 test binary-30.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
1144 } -result {not enough arguments for all format specifiers}
1145 test binary-30.2 {Tcl_BinaryObjCmd: scan} {
1146 unset -nocomplain arg1
1147 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 I* arg1] $arg1
1148 } {1 {1386435412 16909060}}
1149 test binary-30.3 {Tcl_BinaryObjCmd: scan} {
1150 unset -nocomplain arg1
1151 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 I arg1] $arg1
1153 test binary-30.4 {Tcl_BinaryObjCmd: scan} {
1154 unset -nocomplain arg1
1155 list [binary scan \x52\xa3\x53\x54 I1 arg1] $arg1
1157 test binary-30.5 {Tcl_BinaryObjCmd: scan} {
1158 unset -nocomplain arg1
1159 list [binary scan \x52\xa3\x53 I0 arg1] $arg1
1161 test binary-30.6 {Tcl_BinaryObjCmd: scan} {
1162 unset -nocomplain arg1
1163 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 I2 arg1] $arg1
1164 } {1 {1386435412 16909060}}
1165 test binary-30.7 {Tcl_BinaryObjCmd: scan} {
1166 unset -nocomplain arg1
1168 list [binary scan \x52 I1 arg1] $arg1
1170 test binary-30.8 {Tcl_BinaryObjCmd: scan} -setup {
1171 unset -nocomplain arg1
1172 } -returnCodes error -body {
1174 binary scan \x52\x53\x53\x54 I1 arg1(a)
1175 } -result {can't set "arg1(a)": variable isn't array}
1176 test binary-30.9 {Tcl_BinaryObjCmd: scan} {
1177 unset -nocomplain arg1 arg2
1180 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04\x05 I2c* arg1 arg2] $arg1 $arg2
1181 } {2 {1386435412 16909060} 5}
1182 test binary-30.10 {Tcl_BinaryObjCmd: scan} {
1183 unset -nocomplain arg1 arg2
1184 list [binary scan \xff\xff\xff\xff\xff\xff\xff\xff IuI arg1 arg2] $arg1 $arg2
1186 test binary-30.11 {Tcl_BinaryObjCmd: scan} {
1187 unset -nocomplain arg1 arg2
1188 list [binary scan \xff\xff\xff\xff\xff\xff\xff\xff IIu arg1 arg2] $arg1 $arg2
1190 test binary-30.12 {Tcl_BinaryObjCmd: scan} {
1191 unset -nocomplain arg1 arg2
1192 list [binary scan \x80\x00\x00\x00\x00\x00\x00\x80 IuIu arg1 arg2] $arg1 $arg2
1193 } {2 2147483648 128}
1195 test binary-31.1 {Tcl_BinaryObjCmd: scan} {
1196 list [catch {binary scan abc f} msg] $msg
1197 } {1 {not enough arguments for all format specifiers}}
1198 # NB: format %.12g in Jim_DoubleToString
1199 # tests fixed: 31.2/3, 31.4/5, 31.6/7, 31.10/11, 31.14/15, 41.5/6, 59.2-7, 59.11-15
1200 test binary-31.2 {Tcl_BinaryObjCmd: scan} bigEndian {
1202 list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a f* arg1] $arg1
1203 } {1 {1.60000002384 3.40000009537}}
1204 test binary-31.3 {Tcl_BinaryObjCmd: scan} littleEndian {
1206 list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 f* arg1] $arg1
1207 } {1 {1.60000002384 3.40000009537}}
1208 test binary-31.4 {Tcl_BinaryObjCmd: scan} bigEndian {
1210 list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a f arg1] $arg1
1212 test binary-31.5 {Tcl_BinaryObjCmd: scan} littleEndian {
1214 list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 f arg1] $arg1
1216 test binary-31.6 {Tcl_BinaryObjCmd: scan} bigEndian {
1218 list [binary scan \x3f\xcc\xcc\xcd f1 arg1] $arg1
1220 test binary-31.7 {Tcl_BinaryObjCmd: scan} littleEndian {
1222 list [binary scan \xcd\xcc\xcc\x3f f1 arg1] $arg1
1224 test binary-31.8 {Tcl_BinaryObjCmd: scan} bigEndian {
1226 list [binary scan \x3f\xcc\xcc\xcd f0 arg1] $arg1
1228 test binary-31.9 {Tcl_BinaryObjCmd: scan} littleEndian {
1230 list [binary scan \xcd\xcc\xcc\x3f f0 arg1] $arg1
1232 test binary-31.10 {Tcl_BinaryObjCmd: scan} bigEndian {
1234 list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a f2 arg1] $arg1
1235 } {1 {1.60000002384 3.40000009537}}
1236 test binary-31.11 {Tcl_BinaryObjCmd: scan} littleEndian {
1238 list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 f2 arg1] $arg1
1239 } {1 {1.60000002384 3.40000009537}}
1240 test binary-31.12 {Tcl_BinaryObjCmd: scan} {
1243 list [binary scan \x52 f1 arg1] $arg1
1245 test binary-31.13 {Tcl_BinaryObjCmd: scan} {
1248 list [catch {binary scan \x3f\xcc\xcc\xcd f1 arg1(a)} msg] $msg
1249 } {1 {can't set "arg1(a)": variable isn't array}}
1250 test binary-31.14 {Tcl_BinaryObjCmd: scan} bigEndian {
1251 catch {unset arg1 arg2}
1254 list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a\x05 f2c* arg1 arg2] $arg1 $arg2
1255 } {2 {1.60000002384 3.40000009537} 5}
1256 test binary-31.15 {Tcl_BinaryObjCmd: scan} littleEndian {
1257 catch {unset arg1 arg2}
1260 list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40\x05 f2c* arg1 arg2] $arg1 $arg2
1261 } {2 {1.60000002384 3.40000009537} 5}
1263 test binary-32.1 {Tcl_BinaryObjCmd: scan} {
1264 list [catch {binary scan abc d} msg] $msg
1265 } {1 {not enough arguments for all format specifiers}}
1266 test binary-32.2 {Tcl_BinaryObjCmd: scan} bigEndian {
1268 list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 d* arg1] $arg1
1270 test binary-32.3 {Tcl_BinaryObjCmd: scan} littleEndian {
1272 list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 d* arg1] $arg1
1274 test binary-32.4 {Tcl_BinaryObjCmd: scan} bigEndian {
1276 list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 d arg1] $arg1
1278 test binary-32.5 {Tcl_BinaryObjCmd: scan} littleEndian {
1280 list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 d arg1] $arg1
1282 test binary-32.6 {Tcl_BinaryObjCmd: scan} bigEndian {
1284 list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a d1 arg1] $arg1
1286 test binary-32.7 {Tcl_BinaryObjCmd: scan} littleEndian {
1288 list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f d1 arg1] $arg1
1290 test binary-32.8 {Tcl_BinaryObjCmd: scan} bigEndian {
1292 list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a d0 arg1] $arg1
1294 test binary-32.9 {Tcl_BinaryObjCmd: scan} littleEndian {
1296 list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f d0 arg1] $arg1
1298 test binary-32.10 {Tcl_BinaryObjCmd: scan} bigEndian {
1300 list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 d2 arg1] $arg1
1302 test binary-32.11 {Tcl_BinaryObjCmd: scan} littleEndian {
1304 list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 d2 arg1] $arg1
1306 test binary-32.12 {Tcl_BinaryObjCmd: scan} {
1309 list [binary scan \x52 d1 arg1] $arg1
1311 test binary-32.13 {Tcl_BinaryObjCmd: scan} {
1314 list [catch {binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a d1 arg1(a)} msg] $msg
1315 } {1 {can't set "arg1(a)": variable isn't array}}
1316 test binary-32.14 {Tcl_BinaryObjCmd: scan} bigEndian {
1317 catch {unset arg1 arg2}
1320 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
1322 test binary-32.15 {Tcl_BinaryObjCmd: scan} littleEndian {
1323 catch {unset arg1 arg2}
1326 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
1329 test binary-33.1 {Tcl_BinaryObjCmd: scan} {
1330 unset -nocomplain arg1
1331 unset -nocomplain arg2
1332 list [binary scan abcdefg a2xa3 arg1 arg2] $arg1 $arg2
1334 test binary-33.2 {Tcl_BinaryObjCmd: scan} {
1335 unset -nocomplain arg1
1336 unset -nocomplain arg2
1338 list [binary scan abcdefg a3x*a3 arg1 arg2] $arg1 $arg2
1340 test binary-33.3 {Tcl_BinaryObjCmd: scan} {
1341 unset -nocomplain arg1
1342 unset -nocomplain arg2
1344 list [binary scan abcdefg a3x20a3 arg1 arg2] $arg1 $arg2
1346 test binary-33.4 {Tcl_BinaryObjCmd: scan} {
1347 unset -nocomplain arg1
1348 unset -nocomplain arg2
1350 list [binary scan abc a3x20a3 arg1 arg2] $arg1 $arg2
1352 test binary-33.5 {Tcl_BinaryObjCmd: scan} {
1353 unset -nocomplain arg1
1354 list [binary scan abcdef x1a1 arg1] $arg1
1356 test binary-33.6 {Tcl_BinaryObjCmd: scan} {
1357 unset -nocomplain arg1
1358 list [binary scan abcdef x5a1 arg1] $arg1
1360 test binary-33.7 {Tcl_BinaryObjCmd: scan} {
1361 unset -nocomplain arg1
1362 list [binary scan abcdef x0a1 arg1] $arg1
1365 test binary-34.1 {Tcl_BinaryObjCmd: scan} {
1366 unset -nocomplain arg1
1367 unset -nocomplain arg2
1368 list [binary scan abcdefg a2Xa3 arg1 arg2] $arg1 $arg2
1370 test binary-34.2 {Tcl_BinaryObjCmd: scan} {
1371 unset -nocomplain arg1
1372 unset -nocomplain arg2
1374 list [binary scan abcdefg a3X*a3 arg1 arg2] $arg1 $arg2
1376 test binary-34.3 {Tcl_BinaryObjCmd: scan} {
1377 unset -nocomplain arg1
1378 unset -nocomplain arg2
1380 list [binary scan abcdefg a3X20a3 arg1 arg2] $arg1 $arg2
1382 test binary-34.4 {Tcl_BinaryObjCmd: scan} {
1383 unset -nocomplain arg1
1384 list [binary scan abc X20a3 arg1] $arg1
1386 test binary-34.5 {Tcl_BinaryObjCmd: scan} {
1387 unset -nocomplain arg1
1388 list [binary scan abcdef x*X1a1 arg1] $arg1
1390 test binary-34.6 {Tcl_BinaryObjCmd: scan} {
1391 unset -nocomplain arg1
1392 list [binary scan abcdef x*X5a1 arg1] $arg1
1394 test binary-34.7 {Tcl_BinaryObjCmd: scan} {
1395 unset -nocomplain arg1
1396 list [binary scan abcdef x3X0a1 arg1] $arg1
1399 test binary-35.1 {Tcl_BinaryObjCmd: scan} -setup {
1400 unset -nocomplain arg1
1401 unset -nocomplain arg2
1402 } -returnCodes error -body {
1403 binary scan abcdefg a2@a3 arg1 arg2
1404 } -result {missing count for "@" field specifier}
1405 test binary-35.2 {Tcl_BinaryObjCmd: scan} {
1406 unset -nocomplain arg1
1407 unset -nocomplain arg2
1409 list [binary scan abcdefg a3@*a3 arg1 arg2] $arg1 $arg2
1411 test binary-35.3 {Tcl_BinaryObjCmd: scan} {
1412 unset -nocomplain arg1
1413 unset -nocomplain arg2
1415 list [binary scan abcdefg a3@20a3 arg1 arg2] $arg1 $arg2
1417 test binary-35.4 {Tcl_BinaryObjCmd: scan} {
1418 unset -nocomplain arg1
1419 list [binary scan abcdef @2a3 arg1] $arg1
1421 test binary-35.5 {Tcl_BinaryObjCmd: scan} {
1422 unset -nocomplain arg1
1423 list [binary scan abcdef x*@1a1 arg1] $arg1
1425 test binary-35.6 {Tcl_BinaryObjCmd: scan} {
1426 unset -nocomplain arg1
1427 list [binary scan abcdef x*@0a1 arg1] $arg1
1430 test binary-36.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
1431 binary scan abcdef u0a3
1432 } -result {bad field specifier "u"}
1435 # GetFormatSpec is pretty thoroughly tested above, but there are a few cases
1436 # we should text explicitly
1438 test binary-37.1 {GetFormatSpec: whitespace} {
1439 binary format "a3 a5 a3" foo barblat baz
1441 test binary-37.2 {GetFormatSpec: whitespace} {
1442 binary format " " foo
1444 test binary-37.3 {GetFormatSpec: whitespace} {
1445 binary format " a3" foo
1447 test binary-37.4 {GetFormatSpec: whitespace} {
1448 binary format "" foo
1450 test binary-37.5 {GetFormatSpec: whitespace} {
1451 binary format "" foo
1453 test binary-37.6 {GetFormatSpec: whitespace} {
1454 binary format " a3 " foo
1456 test binary-37.7 {GetFormatSpec: numbers} {
1457 list [catch {binary scan abcdef "x-1" foo} msg] $msg
1458 } {1 {bad field specifier "-"}}
1459 test binary-37.8 {GetFormatSpec: numbers} {
1462 list [binary scan abcdef "a0x3" arg1] $arg1
1464 test binary-37.9 {GetFormatSpec: numbers} {
1465 # test format of neg numbers
1466 # bug report/fix provided by Harald Kirsch
1467 set x [binary format f* {1 -1 2 -2 0}]
1468 binary scan $x f* bla
1470 } {1.0 -1.0 2.0 -2.0 0.0}
1472 test binary-38.1 {FormatNumber: word alignment} {
1473 set x [binary format c1s1 1 1]
1475 test binary-38.2 {FormatNumber: word alignment} {
1476 set x [binary format c1S1 1 1]
1478 test binary-38.3 {FormatNumber: word alignment} {
1479 set x [binary format c1i1 1 1]
1480 } \x01\x01\x00\x00\x00
1481 test binary-38.4 {FormatNumber: word alignment} {
1482 set x [binary format c1I1 1 1]
1483 } \x01\x00\x00\x00\x01
1484 test binary-38.5 {FormatNumber: word alignment} bigEndian {
1485 set x [binary format c1d1 1 1.6]
1486 } \x01\x3f\xf9\x99\x99\x99\x99\x99\x9a
1487 test binary-38.6 {FormatNumber: word alignment} littleEndian {
1488 set x [binary format c1d1 1 1.6]
1489 } \x01\x9a\x99\x99\x99\x99\x99\xf9\x3f
1490 test binary-38.7 {FormatNumber: word alignment} bigEndian {
1491 set x [binary format c1f1 1 1.6]
1492 } \x01\x3f\xcc\xcc\xcd
1493 test binary-38.8 {FormatNumber: word alignment} littleEndian {
1494 set x [binary format c1f1 1 1.6]
1495 } \x01\xcd\xcc\xcc\x3f
1497 test binary-39.1 {ScanNumber: sign extension} {
1499 list [binary scan \x52\xa3 c2 arg1] $arg1
1501 test binary-39.2 {ScanNumber: sign extension} {
1503 list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 s4 arg1] $arg1
1504 } {1 {513 -32511 386 -32127}}
1505 test binary-39.3 {ScanNumber: sign extension} {
1507 list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 S4 arg1] $arg1
1508 } {1 {258 385 -32255 -32382}}
1509 test binary-39.4 {ScanNumber: sign extension} {
1511 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
1512 } {1 {33620225 16843137 16876033 25297153 -2130640639}}
1513 test binary-39.5 {ScanNumber: sign extension} {
1515 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
1516 } {1 {16843010 -2130640639 25297153 16876033 16843137}}
1517 test binary-39.6 {ScanNumber: no sign extension} {
1519 list [binary scan \x52\xa3 cu2 arg1] $arg1
1521 test binary-39.7 {ScanNumber: no sign extension} {
1523 list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 su4 arg1] $arg1
1524 } {1 {513 33025 386 33409}}
1525 test binary-39.8 {ScanNumber: no sign extension} {
1527 list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 Su4 arg1] $arg1
1528 } {1 {258 385 33281 33154}}
1529 test binary-39.9 {ScanNumber: no sign extension} {
1531 list [binary scan \x01\x01\x01\x02\x81\x01\x01\x01\x01\x82\x01\x01\x01\x01\x82\x01\x01\x01\x01\x81 iu5 arg1] $arg1
1532 } {1 {33620225 16843137 16876033 25297153 2164326657}}
1533 test binary-39.10 {ScanNumber: no sign extension} {
1535 list [binary scan \x01\x01\x01\x02\x81\x01\x01\x01\x01\x82\x01\x01\x01\x01\x82\x01\x01\x01\x01\x81 Iu5 arg1] $arg1
1536 } {1 {16843010 2164326657 25297153 16876033 16843137}}
1538 test binary-40.3 {ScanNumber: NaN} -constraints {maxCompatibility} \
1541 list [binary scan \xff\xff\xff\xff f1 arg1] $arg1
1546 test binary-40.4 {ScanNumber: NaN} -constraints {maxCompatibility} \
1549 list [binary scan \xff\xff\xff\xff\xff\xff\xff\xff d arg1] $arg1
1554 test binary-41.1 {ScanNumber: word alignment} {
1555 catch {unset arg1; unset arg2}
1556 list [binary scan \x01\x01\x00 c1s1 arg1 arg2] $arg1 $arg2
1558 test binary-41.2 {ScanNumber: word alignment} {
1559 catch {unset arg1; unset arg2}
1560 list [binary scan \x01\x00\x01 c1S1 arg1 arg2] $arg1 $arg2
1562 test binary-41.3 {ScanNumber: word alignment} {
1563 catch {unset arg1; unset arg2}
1564 list [binary scan \x01\x01\x00\x00\x00 c1i1 arg1 arg2] $arg1 $arg2
1566 test binary-41.4 {ScanNumber: word alignment} {
1567 catch {unset arg1; unset arg2}
1568 list [binary scan \x01\x00\x00\x00\x01 c1I1 arg1 arg2] $arg1 $arg2
1570 test binary-41.5 {ScanNumber: word alignment} bigEndian {
1571 catch {unset arg1; unset arg2}
1572 list [binary scan \x01\x3f\xcc\xcc\xcd c1f1 arg1 arg2] $arg1 $arg2
1573 } {2 1 1.60000002384}
1574 test binary-41.6 {ScanNumber: word alignment} littleEndian {
1575 catch {unset arg1; unset arg2}
1576 list [binary scan \x01\xcd\xcc\xcc\x3f c1f1 arg1 arg2] $arg1 $arg2
1577 } {2 1 1.60000002384}
1578 test binary-41.7 {ScanNumber: word alignment} bigEndian {
1579 catch {unset arg1; unset arg2}
1580 list [binary scan \x01\x3f\xf9\x99\x99\x99\x99\x99\x9a c1d1 arg1 arg2] $arg1 $arg2
1582 test binary-41.8 {ScanNumber: word alignment} littleEndian {
1583 catch {unset arg1; unset arg2}
1584 list [binary scan \x01\x9a\x99\x99\x99\x99\x99\xf9\x3f c1d1 arg1 arg2] $arg1 $arg2
1587 # Test changed in Jim's fashion
1588 test binary-42.1 {Tcl_BinaryObjCmd: bad arguments} -returnCodes error -body {
1590 } -match glob -result {*}
1592 # Wide int (guaranteed at least 64-bit) handling
1593 test binary-43.1 {Tcl_BinaryObjCmd: format wide int} {} {
1594 binary format w 7810179016327718216
1596 test binary-43.2 {Tcl_BinaryObjCmd: format wide int} {} {
1597 binary format W 7810179016327718216
1600 test binary-44.1 {Tcl_BinaryObjCmd: scan wide int} {} {
1601 binary scan HelloTcl W x
1603 } 5216694956358656876
1604 test binary-44.2 {Tcl_BinaryObjCmd: scan wide int} {} {
1605 binary scan lcTolleH w x
1607 } 5216694956358656876
1608 # Changed 44.3, 44.4 as Jim doesn't have 'wide' function
1609 test binary-44.3 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} {} {
1610 binary scan [binary format w [expr {int(3) << 31}]] w x
1613 test binary-44.4 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} {} {
1614 binary scan [binary format W [expr {int(3) << 31}]] W x
1617 test binary-43.5 {Tcl_BinaryObjCmd: scan wide int} {} {
1619 list [binary scan \x80[string repeat \x00 7] W arg1] $arg1
1620 } {1 -9223372036854775808}
1621 # Tests binary-43.6-9 excluded as they transcend Jim's integer range.
1622 test binary-43.6 {Tcl_BinaryObjCmd: scan unsigned wide int} {notImplemented} {
1624 list [binary scan \x80[string repeat \x00 7] Wu arg1] $arg1
1625 } {1 9223372036854775808}
1626 test binary-43.7 {Tcl_BinaryObjCmd: scan unsigned wide int} {notImplemented} {
1628 list [binary scan [string repeat \x00 7]\x80 wu arg1] $arg1
1629 } {1 9223372036854775808}
1630 test binary-43.8 {Tcl_BinaryObjCmd: scan unsigned wide int} {notImplemented} {
1631 catch {unset arg1 arg2}
1632 list [binary scan \x80[string repeat \x00 7]\x80[string repeat \x00 7] WuW arg1 arg2] $arg1 $arg2
1633 } {2 9223372036854775808 -9223372036854775808}
1634 test binary-43.9 {Tcl_BinaryObjCmd: scan unsigned wide int} {notImplemented} {
1635 catch {unset arg1 arg2}
1636 list [binary scan [string repeat \x00 7]\x80[string repeat \x00 7]\x80 wuw arg1 arg2] $arg1 $arg2
1637 } {2 9223372036854775808 -9223372036854775808}
1639 test binary-45.1 {Tcl_BinaryObjCmd: combined wide int handling} {
1640 binary scan [binary format sws 16450 -1 19521] c* x
1642 } {66 64 -1 -1 -1 -1 -1 -1 -1 -1 65 76}
1643 test binary-45.2 {Tcl_BinaryObjCmd: combined wide int handling} {
1644 binary scan [binary format sWs 16450 0x7fffffff 19521] c* x
1646 } {66 64 0 0 0 0 127 -1 -1 -1 65 76}
1648 # NB: tests binary-46.* fail as Jim Tcl doesn't truncate Unicode chars to ISO-8859-1.
1650 test binary-47.1 {Tcl_BinaryObjCmd: number cache reference count handling} {
1651 # This test is only reliable when memory debugging is turned on,
1652 # but without even memory debugging it should still generate the
1653 # expected answers and might therefore still pick up memory corruption
1654 # caused by [Bug 851747].
1655 list [binary scan aba ccc x x x] $x
1659 ### TIP#129: endian specifiers ----
1662 test binary-48.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
1664 } -result {not enough arguments for all format specifiers}
1665 test binary-48.2 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
1666 binary format t blat
1667 } -result {expected integer but got "blat"}
1668 test binary-48.3 {Tcl_BinaryObjCmd: format} {
1669 binary format S0 0x50
1671 test binary-48.4 {Tcl_BinaryObjCmd: format} bigEndian {
1672 binary format t 0x50
1674 test binary-48.5 {Tcl_BinaryObjCmd: format} littleEndian {
1675 binary format t 0x50
1677 test binary-48.6 {Tcl_BinaryObjCmd: format} bigEndian {
1678 binary format t 0x5052
1680 test binary-48.7 {Tcl_BinaryObjCmd: format} littleEndian {
1681 binary format t 0x5052
1683 test binary-48.8 {Tcl_BinaryObjCmd: format} bigEndian {
1684 binary format t 0x505251 0x53
1686 test binary-48.9 {Tcl_BinaryObjCmd: format} littleEndian {
1687 binary format t 0x505251 0x53
1689 test binary-48.10 {Tcl_BinaryObjCmd: format} bigEndian {
1690 binary format t2 {0x50 0x52}
1692 test binary-48.11 {Tcl_BinaryObjCmd: format} littleEndian {
1693 binary format t2 {0x50 0x52}
1695 test binary-48.12 {Tcl_BinaryObjCmd: format} bigEndian {
1696 binary format t* {0x5051 0x52}
1698 test binary-48.13 {Tcl_BinaryObjCmd: format} littleEndian {
1699 binary format t* {0x5051 0x52}
1701 test binary-48.14 {Tcl_BinaryObjCmd: format} bigEndian {
1702 binary format t2 {0x50 0x52 0x53} 0x54
1704 test binary-48.15 {Tcl_BinaryObjCmd: format} littleEndian {
1705 binary format t2 {0x50 0x52 0x53} 0x54
1707 test binary-48.16 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
1708 binary format t2 {0x50}
1709 } -result {number of elements in list does not match count}
1710 test binary-48.17 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
1713 } -result "expected integer but got \"0x50 0x51\""
1714 test binary-48.18 {Tcl_BinaryObjCmd: format} bigEndian {
1718 test binary-48.19 {Tcl_BinaryObjCmd: format} littleEndian {
1724 test binary-49.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
1726 } -result {not enough arguments for all format specifiers}
1727 test binary-49.2 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
1728 binary format n blat
1729 } -result {expected integer but got "blat"}
1730 test binary-49.3 {Tcl_BinaryObjCmd: format} {
1731 binary format n0 0x50
1733 test binary-49.4 {Tcl_BinaryObjCmd: format} littleEndian {
1734 binary format n 0x50
1736 test binary-49.5 {Tcl_BinaryObjCmd: format} littleEndian {
1737 binary format n 0x5052
1739 test binary-49.6 {Tcl_BinaryObjCmd: format} littleEndian {
1740 binary format n 0x505251 0x53
1742 test binary-49.7 {Tcl_BinaryObjCmd: format} littleEndian {
1743 binary format i1 {0x505251 0x53}
1745 test binary-49.8 {Tcl_BinaryObjCmd: format} littleEndian {
1746 binary format n 0x53525150
1748 test binary-49.9 {Tcl_BinaryObjCmd: format} littleEndian {
1749 binary format n2 {0x50 0x52}
1750 } P\x00\x00\x00R\x00\x00\x00
1751 test binary-49.10 {Tcl_BinaryObjCmd: format} littleEndian {
1752 binary format n* {0x50515253 0x52}
1754 test binary-49.11 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
1755 binary format n2 {0x50}
1756 } -result {number of elements in list does not match count}
1757 test binary-49.12 {Tcl_BinaryObjCmd: format} -returnCodes error -body {
1760 } -result "expected integer but got \"0x50 0x51\""
1761 test binary-49.13 {Tcl_BinaryObjCmd: format} littleEndian {
1765 test binary-49.14 {Tcl_BinaryObjCmd: format} bigEndian {
1766 binary format n 0x50
1768 test binary-49.15 {Tcl_BinaryObjCmd: format} bigEndian {
1769 binary format n 0x5052
1771 test binary-49.16 {Tcl_BinaryObjCmd: format} bigEndian {
1772 binary format n 0x505251 0x53
1774 test binary-49.17 {Tcl_BinaryObjCmd: format} bigEndian {
1775 binary format i1 {0x505251 0x53}
1777 test binary-49.18 {Tcl_BinaryObjCmd: format} bigEndian {
1778 binary format n 0x53525150
1780 test binary-49.19 {Tcl_BinaryObjCmd: format} bigEndian {
1781 binary format n2 {0x50 0x52}
1782 } \x00\x00\x00P\x00\x00\x00R
1783 test binary-49.20 {Tcl_BinaryObjCmd: format} bigEndian {
1784 binary format n* {0x50515253 0x52}
1788 test binary-50.1 {Tcl_BinaryObjCmd: format wide int} littleEndian {
1789 binary format m 7810179016327718216
1791 test binary-50.2 {Tcl_BinaryObjCmd: format wide int} bigEndian {
1792 binary format m 7810179016327718216
1795 # Changed 50.3, 50.4 as Jim doesn't have 'wide' function
1796 test binary-50.3 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} littleEndian {
1797 binary scan [binary format m [expr {int(3) << 31}]] w x
1800 test binary-50.4 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} bigEndian {
1801 binary scan [binary format m [expr {int(3) << 31}]] W x
1807 test binary-51.1 {Tcl_BinaryObjCmd: format} {
1808 list [catch {binary format Q} msg] $msg
1809 } {1 {not enough arguments for all format specifiers}}
1810 test binary-51.2 {Tcl_BinaryObjCmd: format} {
1811 list [catch {binary format q blat} msg] $msg
1812 } {1 {expected floating-point number but got "blat"}}
1813 test binary-51.3 {Tcl_BinaryObjCmd: format} {
1814 binary format q0 1.6
1816 test binary-51.4 {Tcl_BinaryObjCmd: format} {} {
1818 } \x3f\xf9\x99\x99\x99\x99\x99\x9a
1819 test binary-51.5 {Tcl_BinaryObjCmd: format} {} {
1821 } \x9a\x99\x99\x99\x99\x99\xf9\x3f
1822 test binary-51.6 {Tcl_BinaryObjCmd: format} {} {
1823 binary format Q* {1.6 3.4}
1824 } \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33
1825 test binary-51.7 {Tcl_BinaryObjCmd: format} {} {
1826 binary format q* {1.6 3.4}
1827 } \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40
1828 test binary-51.8 {Tcl_BinaryObjCmd: format} {} {
1829 binary format Q2 {1.6 3.4}
1830 } \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33
1831 test binary-51.9 {Tcl_BinaryObjCmd: format} {} {
1832 binary format q2 {1.6 3.4}
1833 } \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40
1834 test binary-51.10 {Tcl_BinaryObjCmd: format} {} {
1835 binary format Q2 {1.6 3.4 5.6}
1836 } \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33
1837 test binary-51.11 {Tcl_BinaryObjCmd: format} {} {
1838 binary format q2 {1.6 3.4 5.6}
1839 } \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40
1840 test binary-51.14 {Tcl_BinaryObjCmd: format} {
1841 list [catch {binary format q2 {1.6}} msg] $msg
1842 } {1 {number of elements in list does not match count}}
1843 test binary-51.15 {Tcl_BinaryObjCmd: format} {
1845 list [catch {binary format q $a} msg] $msg
1846 } [list 1 "expected floating-point number but got \"1.6 3.4\""]
1847 test binary-51.16 {Tcl_BinaryObjCmd: format} {} {
1850 } \x3f\xf9\x99\x99\x99\x99\x99\x9a
1851 test binary-51.17 {Tcl_BinaryObjCmd: format} {} {
1854 } \x9a\x99\x99\x99\x99\x99\xf9\x3f
1857 test binary-53.1 {Tcl_BinaryObjCmd: format} {
1858 list [catch {binary format r} msg] $msg
1859 } {1 {not enough arguments for all format specifiers}}
1860 test binary-53.2 {Tcl_BinaryObjCmd: format} {
1861 list [catch {binary format r blat} msg] $msg
1862 } {1 {expected floating-point number but got "blat"}}
1863 test binary-53.3 {Tcl_BinaryObjCmd: format} {
1864 binary format f0 1.6
1866 test binary-53.4 {Tcl_BinaryObjCmd: format} {} {
1869 test binary-53.5 {Tcl_BinaryObjCmd: format} {} {
1872 test binary-53.6 {Tcl_BinaryObjCmd: format} {} {
1873 binary format R* {1.6 3.4}
1874 } \x3f\xcc\xcc\xcd\x40\x59\x99\x9a
1875 test binary-53.7 {Tcl_BinaryObjCmd: format} {} {
1876 binary format r* {1.6 3.4}
1877 } \xcd\xcc\xcc\x3f\x9a\x99\x59\x40
1878 test binary-53.8 {Tcl_BinaryObjCmd: format} {} {
1879 binary format R2 {1.6 3.4}
1880 } \x3f\xcc\xcc\xcd\x40\x59\x99\x9a
1881 test binary-53.9 {Tcl_BinaryObjCmd: format} {} {
1882 binary format r2 {1.6 3.4}
1883 } \xcd\xcc\xcc\x3f\x9a\x99\x59\x40
1884 test binary-53.10 {Tcl_BinaryObjCmd: format} {} {
1885 binary format R2 {1.6 3.4 5.6}
1886 } \x3f\xcc\xcc\xcd\x40\x59\x99\x9a
1887 test binary-53.11 {Tcl_BinaryObjCmd: format} {} {
1888 binary format r2 {1.6 3.4 5.6}
1889 } \xcd\xcc\xcc\x3f\x9a\x99\x59\x40
1890 test binary-53.12 {Tcl_BinaryObjCmd: float overflow} {maxCompatibility} {
1891 binary format R -3.402825e+38
1893 test binary-53.13 {Tcl_BinaryObjCmd: float overflow} {maxCompatibility} {
1894 binary format r -3.402825e+38
1896 test binary-53.14 {Tcl_BinaryObjCmd: float underflow} {} {
1897 binary format R -3.402825e-100
1899 test binary-53.15 {Tcl_BinaryObjCmd: float underflow} {} {
1900 binary format r -3.402825e-100
1902 test binary-53.16 {Tcl_BinaryObjCmd: format} {
1903 list [catch {binary format r2 {1.6}} msg] $msg
1904 } {1 {number of elements in list does not match count}}
1905 test binary-53.17 {Tcl_BinaryObjCmd: format} {
1907 list [catch {binary format r $a} msg] $msg
1908 } [list 1 "expected floating-point number but got \"1.6 3.4\""]
1909 test binary-53.18 {Tcl_BinaryObjCmd: format} {} {
1913 test binary-53.19 {Tcl_BinaryObjCmd: format} {} {
1919 test binary-54.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
1921 } -result {not enough arguments for all format specifiers}
1922 test binary-54.2 {Tcl_BinaryObjCmd: scan} littleEndian {
1923 unset -nocomplain arg1
1924 list [binary scan \x52\xa3\x53\x54 t* arg1] $arg1
1925 } {1 {-23726 21587}}
1926 test binary-54.3 {Tcl_BinaryObjCmd: scan} littleEndian {
1927 unset -nocomplain arg1
1928 list [binary scan \x52\xa3\x53\x54 t arg1] $arg1
1930 test binary-54.4 {Tcl_BinaryObjCmd: scan} littleEndian {
1931 unset -nocomplain arg1
1932 list [binary scan \x52\xa3 t1 arg1] $arg1
1934 test binary-54.5 {Tcl_BinaryObjCmd: scan} littleEndian {
1935 unset -nocomplain arg1
1936 list [binary scan \x52\xa3 t0 arg1] $arg1
1938 test binary-54.6 {Tcl_BinaryObjCmd: scan} littleEndian {
1939 unset -nocomplain arg1
1940 list [binary scan \x52\xa3\x53\x54 t2 arg1] $arg1
1941 } {1 {-23726 21587}}
1942 test binary-54.7 {Tcl_BinaryObjCmd: scan} littleEndian {
1943 unset -nocomplain arg1
1945 list [binary scan \x52 t1 arg1] $arg1
1947 test binary-54.8 {Tcl_BinaryObjCmd: scan} -setup {
1948 unset -nocomplain arg1
1949 } -returnCodes error -body {
1951 binary scan \x52\x53 t1 arg1(a)
1952 } -result {can't set "arg1(a)": variable isn't array}
1953 test binary-54.9 {Tcl_BinaryObjCmd: scan} littleEndian {
1954 unset -nocomplain arg1 arg2
1957 list [binary scan \x52\xa3\x53\x54\x05 t2c* arg1 arg2] $arg1 $arg2
1958 } {2 {-23726 21587} 5}
1959 test binary-54.10 {Tcl_BinaryObjCmd: scan} littleEndian {
1960 unset -nocomplain arg1 arg2
1963 list [binary scan \x00\x80\x00\x80 tut arg1 arg2] $arg1 $arg2
1965 test binary-54.11 {Tcl_BinaryObjCmd: scan} littleEndian {
1966 unset -nocomplain arg1 arg2
1969 list [binary scan \x00\x80\x00\x80 ttu arg1 arg2] $arg1 $arg2
1973 test binary-55.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
1975 } -result {not enough arguments for all format specifiers}
1976 test binary-55.2 {Tcl_BinaryObjCmd: scan} bigEndian {
1977 unset -nocomplain arg1
1978 list [binary scan \x52\xa3\x53\x54 t* arg1] $arg1
1980 test binary-55.3 {Tcl_BinaryObjCmd: scan} bigEndian {
1981 unset -nocomplain arg1
1982 list [binary scan \x52\xa3\x53\x54 t arg1] $arg1
1984 test binary-55.4 {Tcl_BinaryObjCmd: scan} bigEndian {
1985 unset -nocomplain arg1
1986 list [binary scan \x52\xa3 t1 arg1] $arg1
1988 test binary-55.5 {Tcl_BinaryObjCmd: scan} bigEndian {
1989 unset -nocomplain arg1
1990 list [binary scan \x52\xa3 t0 arg1] $arg1
1992 test binary-55.6 {Tcl_BinaryObjCmd: scan} bigEndian {
1993 unset -nocomplain arg1
1994 list [binary scan \x52\xa3\x53\x54 t2 arg1] $arg1
1996 test binary-55.7 {Tcl_BinaryObjCmd: scan} bigEndian {
1997 unset -nocomplain arg1
1999 list [binary scan \x52 t1 arg1] $arg1
2001 test binary-55.8 {Tcl_BinaryObjCmd: scan} -setup {
2002 unset -nocomplain arg1
2003 } -returnCodes error -body {
2005 binary scan \x52\x53 t1 arg1(a)
2006 } -result {can't set "arg1(a)": variable isn't array}
2007 test binary-55.9 {Tcl_BinaryObjCmd: scan} bigEndian {
2008 unset -nocomplain arg1 arg2
2011 list [binary scan \x52\xa3\x53\x54\x05 t2c* arg1 arg2] $arg1 $arg2
2012 } {2 {21155 21332} 5}
2013 test binary-55.10 {Tcl_BinaryObjCmd: scan} bigEndian {
2014 unset -nocomplain arg1 arg2
2017 list [binary scan \x80\x00\x80\x00 tut arg1 arg2] $arg1 $arg2
2019 test binary-55.11 {Tcl_BinaryObjCmd: scan} bigEndian {
2020 unset -nocomplain arg1 arg2
2023 list [binary scan \x80\x00\x80\x00 ttu arg1 arg2] $arg1 $arg2
2027 test binary-56.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
2029 } -result {not enough arguments for all format specifiers}
2030 test binary-56.2 {Tcl_BinaryObjCmd: scan} littleEndian {
2031 unset -nocomplain arg1
2032 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 n* arg1] $arg1
2033 } {1 {1414767442 67305985}}
2034 test binary-56.3 {Tcl_BinaryObjCmd: scan} littleEndian {
2035 unset -nocomplain arg1
2036 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 n arg1] $arg1
2038 test binary-56.4 {Tcl_BinaryObjCmd: scan} littleEndian {
2039 unset -nocomplain arg1
2040 list [binary scan \x52\xa3\x53\x54 n1 arg1] $arg1
2042 test binary-56.5 {Tcl_BinaryObjCmd: scan} littleEndian {
2043 unset -nocomplain arg1
2044 list [binary scan \x52\xa3\x53 n0 arg1] $arg1
2046 test binary-56.6 {Tcl_BinaryObjCmd: scan} littleEndian {
2047 unset -nocomplain arg1
2048 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 n2 arg1] $arg1
2049 } {1 {1414767442 67305985}}
2050 test binary-56.7 {Tcl_BinaryObjCmd: scan} littleEndian {
2051 unset -nocomplain arg1
2053 list [binary scan \x52 n1 arg1] $arg1
2055 test binary-56.8 {Tcl_BinaryObjCmd: scan} -setup {
2056 unset -nocomplain arg1
2057 } -returnCodes error -body {
2059 binary scan \x52\x53\x53\x54 n1 arg1(a)
2060 } -result {can't set "arg1(a)": variable isn't array}
2061 test binary-56.9 {Tcl_BinaryObjCmd: scan} littleEndian {
2062 unset -nocomplain arg1 arg2
2065 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04\x05 n2c* arg1 arg2] $arg1 $arg2
2066 } {2 {1414767442 67305985} 5}
2067 test binary-56.10 {Tcl_BinaryObjCmd: scan} littleEndian {
2068 unset -nocomplain arg1 arg2
2071 list [binary scan \x80\x00\x00\x00\x80\x00\x00\x00 nun arg1 arg2] $arg1 $arg2
2073 test binary-56.11 {Tcl_BinaryObjCmd: scan} littleEndian {
2074 unset -nocomplain arg1 arg2
2077 list [binary scan \x00\x00\x00\x80\x00\x00\x00\x80 nun arg1 arg2] $arg1 $arg2
2078 } {2 2147483648 -2147483648}
2081 test binary-57.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
2083 } -result {not enough arguments for all format specifiers}
2084 test binary-57.2 {Tcl_BinaryObjCmd: scan} bigEndian {
2085 unset -nocomplain arg1
2086 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 n* arg1] $arg1
2087 } {1 {1386435412 16909060}}
2088 test binary-57.3 {Tcl_BinaryObjCmd: scan} bigEndian {
2089 unset -nocomplain arg1
2090 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 n arg1] $arg1
2092 test binary-57.4 {Tcl_BinaryObjCmd: scan} bigEndian {
2093 unset -nocomplain arg1
2094 list [binary scan \x52\xa3\x53\x54 n1 arg1] $arg1
2096 test binary-57.5 {Tcl_BinaryObjCmd: scan} bigEndian {
2097 unset -nocomplain arg1
2098 list [binary scan \x52\xa3\x53 n0 arg1] $arg1
2100 test binary-57.6 {Tcl_BinaryObjCmd: scan} bigEndian {
2101 unset -nocomplain arg1
2102 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 n2 arg1] $arg1
2103 } {1 {1386435412 16909060}}
2104 test binary-57.7 {Tcl_BinaryObjCmd: scan} bigEndian {
2105 unset -nocomplain arg1
2107 list [binary scan \x52 n1 arg1] $arg1
2109 test binary-57.8 {Tcl_BinaryObjCmd: scan} -setup {
2110 unset -nocomplain arg1
2111 } -returnCodes error -body {
2113 binary scan \x52\x53\x53\x54 n1 arg1(a)
2114 } -result {can't set "arg1(a)": variable isn't array}
2115 test binary-57.9 {Tcl_BinaryObjCmd: scan} bigEndian {
2116 unset -nocomplain arg1 arg2
2119 list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04\x05 n2c* arg1 arg2] $arg1 $arg2
2120 } {2 {1386435412 16909060} 5}
2121 test binary-57.10 {Tcl_BinaryObjCmd: scan} bigEndian {
2122 unset -nocomplain arg1 arg2
2125 list [binary scan \x80\x00\x00\x00\x80\x00\x00\x00 nun arg1 arg2] $arg1 $arg2
2126 } {2 2147483648 -2147483648}
2127 test binary-57.11 {Tcl_BinaryObjCmd: scan} bigEndian {
2128 unset -nocomplain arg1 arg2
2131 list [binary scan \x00\x00\x00\x80\x00\x00\x00\x80 nun arg1 arg2] $arg1 $arg2
2135 test binary-58.1 {Tcl_BinaryObjCmd: scan} {
2136 list [catch {binary scan abc q} msg] $msg
2137 } {1 {not enough arguments for all format specifiers}}
2138 test binary-58.2 {Tcl_BinaryObjCmd: scan} bigEndian {
2140 list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 Q* arg1] $arg1
2142 test binary-58.3 {Tcl_BinaryObjCmd: scan} littleEndian {
2144 list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 q* arg1] $arg1
2146 test binary-58.4 {Tcl_BinaryObjCmd: scan} bigEndian {
2148 list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 Q arg1] $arg1
2150 test binary-58.5 {Tcl_BinaryObjCmd: scan} littleEndian {
2152 list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 q arg1] $arg1
2154 test binary-58.6 {Tcl_BinaryObjCmd: scan} bigEndian {
2156 list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a Q1 arg1] $arg1
2158 test binary-58.7 {Tcl_BinaryObjCmd: scan} littleEndian {
2160 list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f q1 arg1] $arg1
2162 test binary-58.8 {Tcl_BinaryObjCmd: scan} bigEndian {
2164 list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a Q0 arg1] $arg1
2166 test binary-58.9 {Tcl_BinaryObjCmd: scan} littleEndian {
2168 list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f q0 arg1] $arg1
2170 test binary-58.10 {Tcl_BinaryObjCmd: scan} bigEndian {
2172 list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 Q2 arg1] $arg1
2174 test binary-58.11 {Tcl_BinaryObjCmd: scan} littleEndian {
2176 list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 q2 arg1] $arg1
2178 test binary-58.12 {Tcl_BinaryObjCmd: scan} {
2181 list [binary scan \x52 q1 arg1] $arg1
2183 test binary-58.13 {Tcl_BinaryObjCmd: scan} {
2186 list [catch {binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a q1 arg1(a)} msg] $msg
2187 } {1 {can't set "arg1(a)": variable isn't array}}
2188 test binary-58.14 {Tcl_BinaryObjCmd: scan} bigEndian {
2189 catch {unset arg1 arg2}
2192 list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33\x05 Q2c* arg1 arg2] $arg1 $arg2
2194 test binary-58.15 {Tcl_BinaryObjCmd: scan} littleEndian {
2195 catch {unset arg1 arg2}
2198 list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40\x05 q2c* arg1 arg2] $arg1 $arg2
2202 test binary-59.1 {Tcl_BinaryObjCmd: scan} {
2203 list [catch {binary scan abc r} msg] $msg
2204 } {1 {not enough arguments for all format specifiers}}
2205 test binary-59.2 {Tcl_BinaryObjCmd: scan} bigEndian {
2207 list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a R* arg1] $arg1
2208 } {1 {1.60000002384 3.40000009537}}
2209 test binary-59.3 {Tcl_BinaryObjCmd: scan} littleEndian {
2211 list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 r* arg1] $arg1
2212 } {1 {1.60000002384 3.40000009537}}
2213 test binary-59.4 {Tcl_BinaryObjCmd: scan} bigEndian {
2215 list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a R arg1] $arg1
2217 test binary-59.5 {Tcl_BinaryObjCmd: scan} littleEndian {
2219 list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 r arg1] $arg1
2221 test binary-59.6 {Tcl_BinaryObjCmd: scan} bigEndian {
2223 list [binary scan \x3f\xcc\xcc\xcd R1 arg1] $arg1
2225 test binary-59.7 {Tcl_BinaryObjCmd: scan} littleEndian {
2227 list [binary scan \xcd\xcc\xcc\x3f r1 arg1] $arg1
2229 test binary-59.8 {Tcl_BinaryObjCmd: scan} bigEndian {
2231 list [binary scan \x3f\xcc\xcc\xcd R0 arg1] $arg1
2233 test binary-59.9 {Tcl_BinaryObjCmd: scan} littleEndian {
2235 list [binary scan \xcd\xcc\xcc\x3f r0 arg1] $arg1
2237 test binary-59.10 {Tcl_BinaryObjCmd: scan} bigEndian {
2239 list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a R2 arg1] $arg1
2240 } {1 {1.60000002384 3.40000009537}}
2241 test binary-59.11 {Tcl_BinaryObjCmd: scan} littleEndian {
2243 list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 r2 arg1] $arg1
2244 } {1 {1.60000002384 3.40000009537}}
2245 test binary-59.12 {Tcl_BinaryObjCmd: scan} {
2248 list [binary scan \x52 r1 arg1] $arg1
2250 test binary-59.13 {Tcl_BinaryObjCmd: scan} {
2253 list [catch {binary scan \x3f\xcc\xcc\xcd r1 arg1(a)} msg] $msg
2254 } {1 {can't set "arg1(a)": variable isn't array}}
2255 test binary-59.14 {Tcl_BinaryObjCmd: scan} bigEndian {
2256 catch {unset arg1 arg2}
2259 list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a\x05 R2c* arg1 arg2] $arg1 $arg2
2260 } {2 {1.60000002384 3.40000009537} 5}
2261 test binary-59.15 {Tcl_BinaryObjCmd: scan} littleEndian {
2262 catch {unset arg1 arg2}
2265 list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40\x05 r2c* arg1 arg2] $arg1 $arg2
2266 } {2 {1.60000002384 3.40000009537} 5}
2268 test binary-60.1 {[binary format] with NaN} -body {
2269 binary scan [binary format dqQfrR NaN NaN NaN NaN NaN NaN] dqQfrR \
2271 list $v1 $v2 $v3 $v4 $v5 $v6
2272 } -match regexp -result {NaN(\([[:xdigit:]]+\))? NaN(\([[:xdigit:]]+\))? NaN(\([[:xdigit:]]+\))? NaN(\([[:xdigit:]]+\))? NaN(\([[:xdigit:]]+\))? NaN(\([[:xdigit:]]+\))?}
2275 test binary-61.1 {Tcl_BinaryObjCmd: scan wide int} bigEndian {
2276 binary scan HelloTcl m x
2278 } 5216694956358656876
2279 test binary-61.2 {Tcl_BinaryObjCmd: scan wide int} littleEndian {
2280 binary scan lcTolleH m x
2282 } 5216694956358656876
2283 test binary-61.3 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} littleEndian {
2284 binary scan [binary format w [expr {3 << 31}]] m x
2287 test binary-61.4 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} bigEndian {
2288 binary scan [binary format W [expr {3 << 31}]] m x
2292 # Big test for correct ordering of data in [expr]
2295 array set ieeeValues {}
2296 binary scan [binary format dd -1.0 1.0] c* c
2297 switch -exact -- $c {
2298 {0 0 0 0 0 0 -16 -65 0 0 0 0 0 0 -16 63} {
2300 binary scan \x00\x00\x00\x00\x00\x00\xf0\xff d \
2301 ieeeValues(-Infinity)
2302 binary scan \x00\x00\x00\x00\x00\x00\xf0\xbf d \
2304 binary scan \x00\x00\x00\x00\x00\x00\x08\x80 d \
2305 ieeeValues(-Subnormal)
2306 binary scan \x00\x00\x00\x00\x00\x00\x00\x80 d \
2308 binary scan \x00\x00\x00\x00\x00\x00\x00\x00 d \
2310 binary scan \x00\x00\x00\x00\x00\x00\x08\x00 d \
2311 ieeeValues(+Subnormal)
2312 binary scan \x00\x00\x00\x00\x00\x00\xf0\x3f d \
2314 binary scan \x00\x00\x00\x00\x00\x00\xf0\x7f d \
2315 ieeeValues(+Infinity)
2316 binary scan \x00\x00\x00\x00\x00\x00\xf8\x7f d \
2318 set ieeeValues(littleEndian) 1
2321 {-65 -16 0 0 0 0 0 0 63 -16 0 0 0 0 0 0} {
2322 binary scan \xff\xf0\x00\x00\x00\x00\x00\x00 d \
2323 ieeeValues(-Infinity)
2324 binary scan \xbf\xf0\x00\x00\x00\x00\x00\x00 d \
2326 binary scan \x80\x08\x00\x00\x00\x00\x00\x00 d \
2327 ieeeValues(-Subnormal)
2328 binary scan \x80\x00\x00\x00\x00\x00\x00\x00 d \
2330 binary scan \x00\x00\x00\x00\x00\x00\x00\x00 d \
2332 binary scan \x00\x08\x00\x00\x00\x00\x00\x00 d \
2333 ieeeValues(+Subnormal)
2334 binary scan \x3f\xf0\x00\x00\x00\x00\x00\x00 d \
2336 binary scan \x7f\xf0\x00\x00\x00\x00\x00\x00 d \
2337 ieeeValues(+Infinity)
2338 binary scan \x7f\xf8\x00\x00\x00\x00\x00\x00 d \
2340 set ieeeValues(littleEndian) 0
2349 testConstraint ieeeFloatingPoint [testIEEE]
2351 # scan/format infinities
2353 test binary-62.1 {infinity} ieeeFloatingPoint {
2354 binary scan [binary format q Infinity] w w
2356 } 0x7ff0000000000000
2357 test binary-62.2 {infinity} ieeeFloatingPoint {
2358 binary scan [binary format q -Infinity] w w
2360 } 0xfff0000000000000
2361 test binary-62.3 {infinity} ieeeFloatingPoint {
2362 binary scan [binary format q Inf] w w
2364 } 0x7ff0000000000000
2365 test binary-62.4 {infinity} ieeeFloatingPoint {
2366 binary scan [binary format q -Infinity] w w
2368 } 0xfff0000000000000
2369 test binary-62.5 {infinity} ieeeFloatingPoint {
2370 binary scan [binary format w 0x7ff0000000000000] q d
2373 test binary-62.6 {infinity} ieeeFloatingPoint {
2374 binary scan [binary format w 0xfff0000000000000] q d
2378 # scan/format Not-a-Number
2380 test binary-63.1 {NaN} {ieeeFloatingPoint maxCompatibility} {
2381 binary scan [binary format q NaN] w w
2382 format 0x%016lx [expr {$w & 0xfff3ffffffffffff}]
2383 } 0x7ff0000000000000
2384 # Tests binary-63.2-4, 63.5-9, 64.2 excluded.
2385 # Apparently strtod (and Jim) don't have
2386 # advanced NaN-handling facility as Tcl does :)
2387 test binary-63.2 {NaN} {ieeeFloatingPoint notImplemented} {
2388 binary scan [binary format q -NaN] w w
2389 format 0x%016lx [expr {$w & 0xfff3ffffffffffff}]
2390 } 0xfff0000000000000
2391 test binary-63.3 {NaN} {ieeeFloatingPoint notImplemented} {
2392 binary scan [binary format q NaN(3123456789aBc)] w w
2393 format 0x%016lx [expr {$w & 0xfff3ffffffffffff}]
2394 } 0x7ff3123456789abc
2395 test binary-63.4 {NaN} {ieeeFloatingPoint notImplemented} {
2396 binary scan [binary format q {NaN( 3123456789aBc)}] w w
2397 format 0x%016lx [expr {$w & 0xfff3ffffffffffff}]
2398 } 0x7ff3123456789abc
2400 # Make sure TclParseNumber() rejects invalid nan-hex formats [Bug 3402540]
2401 test binary-63.5 {NaN} -constraints {ieeeFloatingPoint} -body {
2402 binary format q Nan(
2403 } -returnCodes error -match glob -result {expected floating-point number*}
2404 test binary-63.6 {NaN} -constraints {ieeeFloatingPoint notImplemented} -body {
2405 binary format q Nan()
2406 } -returnCodes error -match glob -result {expected floating-point number*}
2407 test binary-63.7 {NaN} -constraints {ieeeFloatingPoint notImplemented} -body {
2408 binary format q Nan(g)
2409 } -returnCodes error -match glob -result {expected floating-point number*}
2410 test binary-63.8 {NaN} -constraints {ieeeFloatingPoint notImplemented} -body {
2411 binary format q Nan(1,2)
2412 } -returnCodes error -match glob -result {expected floating-point number*}
2413 test binary-63.9 {NaN} -constraints {ieeeFloatingPoint notImplemented} -body {
2414 binary format q Nan(1234567890abcd)
2415 } -returnCodes error -match glob -result {expected floating-point number*}
2417 test binary-64.1 {NaN} \
2418 -constraints ieeeFloatingPoint \
2420 binary scan [binary format w 0x7ff8000000000000] q d
2423 -match glob -result NaN*
2424 test binary-64.2 {NaN} \
2425 -constraints {ieeeFloatingPoint notImplemented} \
2427 binary scan [binary format w 0x7ff0123456789aBc] q d
2430 -match glob -result NaN(*123456789abc)
2432 # NB: the problem of %.12g format in Jim_DoubleToString
2433 # make these tests meaningless. Excluded 65.1/3/5,7-9.
2435 test binary-65.1 {largest significand} {ieeeFloatingPoint maxCompatibility} {
2436 binary scan [binary format w 0x3fcfffffffffffff] q d
2438 } 0.24999999999999997
2439 test binary-65.2 {smallest significand} ieeeFloatingPoint {
2440 binary scan [binary format w 0x3fd0000000000000] q d
2443 test binary-65.3 {largest significand} {ieeeFloatingPoint maxCompatibility} {
2444 binary scan [binary format w 0x3fdfffffffffffff] q d
2446 } 0.49999999999999994
2447 test binary-65.4 {smallest significand} ieeeFloatingPoint {
2448 binary scan [binary format w 0x3fe0000000000000] q d
2451 test binary-65.5 {largest significand} {ieeeFloatingPoint maxCompatibility} {
2452 binary scan [binary format w 0x3fffffffffffffff] q d
2454 } 1.9999999999999998
2455 test binary-65.6 {smallest significand} ieeeFloatingPoint {
2456 binary scan [binary format w 0x4000000000000000] q d
2459 test binary-65.7 {smallest significand} {ieeeFloatingPoint maxCompatibility} {
2460 binary scan [binary format w 0x434fffffffffffff] q d
2462 } 18014398509481982.0
2463 test binary-65.8 {largest significand} {ieeeFloatingPoint maxCompatibility} {
2464 binary scan [binary format w 0x4350000000000000] q d
2466 } 18014398509481984.0
2467 test binary-65.9 {largest significand} {ieeeFloatingPoint maxCompatibility} {
2468 binary scan [binary format w 0x4350000000000001] q d
2470 } 18014398509481988.0
2472 # Jim-specific test.
2473 # binary scan must return immediately if there's not enough bytes left.
2474 test binary-66.1 {binary scan: not enought bytes} {} {
2475 unset -nocomplain arg1 arg2
2476 binary scan ab is arg1 arg2
2480 ::tcltest::cleanupTests