1# This file tests the tclBinary.c file and the "binary" Tcl command. 2# 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. 6# 7# Copyright © 1997 Sun Microsystems, Inc. 8# Copyright © 1998-1999 Scriptics Corporation. 9# 10# See the file "license.terms" for information on usage and redistribution of 11# this file, and for a DISCLAIMER OF ALL WARRANTIES. 12 13if {"::tcltest" ni [namespace children]} { 14 package require tcltest 2.5 15 namespace import -force ::tcltest::* 16} 17::tcltest::loadTestedCommands 18catch [list package require -exact tcl::test [info patchlevel]] 19 20testConstraint bigEndian [expr {$tcl_platform(byteOrder) eq "bigEndian"}] 21testConstraint littleEndian [expr {$tcl_platform(byteOrder) eq "littleEndian"}] 22testConstraint testbytestring [llength [info commands testbytestring]] 23 24# Big test for correct ordering of data in [expr] 25proc testIEEE {} { 26 variable ieeeValues 27 binary scan [binary format dd -1.0 1.0] c* c 28 switch -exact -- $c { 29 {0 0 0 0 0 0 -16 -65 0 0 0 0 0 0 -16 63} { 30 # little endian 31 binary scan \x00\x00\x00\x00\x00\x00\xF0\xFF d \ 32 ieeeValues(-Infinity) 33 binary scan \x00\x00\x00\x00\x00\x00\xF0\xBF d \ 34 ieeeValues(-Normal) 35 binary scan \x00\x00\x00\x00\x00\x00\x08\x80 d \ 36 ieeeValues(-Subnormal) 37 binary scan \x00\x00\x00\x00\x00\x00\x00\x80 d \ 38 ieeeValues(-0) 39 binary scan \x00\x00\x00\x00\x00\x00\x00\x00 d \ 40 ieeeValues(+0) 41 binary scan \x00\x00\x00\x00\x00\x00\x08\x00 d \ 42 ieeeValues(+Subnormal) 43 binary scan \x00\x00\x00\x00\x00\x00\xF0\x3F d \ 44 ieeeValues(+Normal) 45 binary scan \x00\x00\x00\x00\x00\x00\xF0\x7F d \ 46 ieeeValues(+Infinity) 47 binary scan \x00\x00\x00\x00\x00\x00\xF8\x7F d \ 48 ieeeValues(NaN) 49 set ieeeValues(littleEndian) 1 50 return 1 51 } 52 {-65 -16 0 0 0 0 0 0 63 -16 0 0 0 0 0 0} { 53 binary scan \xFF\xF0\x00\x00\x00\x00\x00\x00 d \ 54 ieeeValues(-Infinity) 55 binary scan \xBF\xF0\x00\x00\x00\x00\x00\x00 d \ 56 ieeeValues(-Normal) 57 binary scan \x80\x08\x00\x00\x00\x00\x00\x00 d \ 58 ieeeValues(-Subnormal) 59 binary scan \x80\x00\x00\x00\x00\x00\x00\x00 d \ 60 ieeeValues(-0) 61 binary scan \x00\x00\x00\x00\x00\x00\x00\x00 d \ 62 ieeeValues(+0) 63 binary scan \x00\x08\x00\x00\x00\x00\x00\x00 d \ 64 ieeeValues(+Subnormal) 65 binary scan \x3F\xF0\x00\x00\x00\x00\x00\x00 d \ 66 ieeeValues(+Normal) 67 binary scan \x7F\xF0\x00\x00\x00\x00\x00\x00 d \ 68 ieeeValues(+Infinity) 69 binary scan \x7F\xF8\x00\x00\x00\x00\x00\x00 d \ 70 ieeeValues(NaN) 71 set ieeeValues(littleEndian) 0 72 return 1 73 } 74 default { 75 return 0 76 } 77 } 78} 79 80testConstraint ieeeFloatingPoint [testIEEE] 81 82# ---------------------------------------------------------------------- 83 84test binary-0.1 {DupByteArrayInternalRep} { 85 set hdr [binary format cc 0 0316] 86 set buf hellomatt 87 set data $hdr 88 append data $buf 89 string length $data 90} 11 91 92test binary-1.1 {Tcl_BinaryObjCmd: bad args} -body { 93 binary 94} -returnCodes error -match glob -result {wrong # args: *} 95test binary-1.2 {Tcl_BinaryObjCmd: bad args} -returnCodes error -body { 96 binary foo 97} -match glob -result {unknown or ambiguous subcommand "foo": *} 98test binary-1.3 {Tcl_BinaryObjCmd: format error} -returnCodes error -body { 99 binary f 100} -result {wrong # args: should be "binary format formatString ?arg ...?"} 101test binary-1.4 {Tcl_BinaryObjCmd: format} -body { 102 binary format "" 103} -result {} 104 105test binary-2.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 106 binary format a 107} -result {not enough arguments for all format specifiers} 108test binary-2.2 {Tcl_BinaryObjCmd: format} { 109 binary format a0 foo 110} {} 111test binary-2.3 {Tcl_BinaryObjCmd: format} { 112 binary format a f 113} {f} 114test binary-2.4 {Tcl_BinaryObjCmd: format} { 115 binary format a foo 116} {f} 117test binary-2.5 {Tcl_BinaryObjCmd: format} { 118 binary format a3 foo 119} {foo} 120test binary-2.6 {Tcl_BinaryObjCmd: format} { 121 binary format a5 foo 122} foo\x00\x00 123test binary-2.7 {Tcl_BinaryObjCmd: format} { 124 binary format a*a3 foobarbaz blat 125} foobarbazbla 126test binary-2.8 {Tcl_BinaryObjCmd: format} { 127 binary format a*X3a2 foobar x 128} foox\x00r 129 130test binary-3.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 131 binary format A 132} -result {not enough arguments for all format specifiers} 133test binary-3.2 {Tcl_BinaryObjCmd: format} { 134 binary format A0 f 135} {} 136test binary-3.3 {Tcl_BinaryObjCmd: format} { 137 binary format A f 138} {f} 139test binary-3.4 {Tcl_BinaryObjCmd: format} { 140 binary format A foo 141} {f} 142test binary-3.5 {Tcl_BinaryObjCmd: format} { 143 binary format A3 foo 144} {foo} 145test binary-3.6 {Tcl_BinaryObjCmd: format} { 146 binary format A5 foo 147} {foo } 148test binary-3.7 {Tcl_BinaryObjCmd: format} { 149 binary format A*A3 foobarbaz blat 150} foobarbazbla 151test binary-3.8 {Tcl_BinaryObjCmd: format} { 152 binary format A*X3A2 foobar x 153} {foox r} 154 155test binary-4.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 156 binary format B 157} -result {not enough arguments for all format specifiers} 158test binary-4.2 {Tcl_BinaryObjCmd: format} { 159 binary format B0 1 160} {} 161test binary-4.3 {Tcl_BinaryObjCmd: format} { 162 binary format B 1 163} \x80 164test binary-4.4 {Tcl_BinaryObjCmd: format} { 165 binary format B* 010011 166} \x4C 167test binary-4.5 {Tcl_BinaryObjCmd: format} { 168 binary format B8 01001101 169} \x4D 170test binary-4.6 {Tcl_BinaryObjCmd: format} { 171 binary format A2X2B9 oo 01001101 172} \x4D\x00 173test binary-4.7 {Tcl_BinaryObjCmd: format} { 174 binary format B9 010011011010 175} \x4D\x80 176test binary-4.8 {Tcl_BinaryObjCmd: format} { 177 binary format B2B3 10 010 178} \x80\x40 179test binary-4.9 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 180 binary format B1B5 1 foo 181} -result {expected binary string but got "foo" instead} 182 183test binary-5.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 184 binary format b 185} -result {not enough arguments for all format specifiers} 186test binary-5.2 {Tcl_BinaryObjCmd: format} { 187 binary format b0 1 188} {} 189test binary-5.3 {Tcl_BinaryObjCmd: format} { 190 binary format b 1 191} \x01 192test binary-5.4 {Tcl_BinaryObjCmd: format} { 193 binary format b* 010011 194} 2 195test binary-5.5 {Tcl_BinaryObjCmd: format} { 196 binary format b8 01001101 197} \xB2 198test binary-5.6 {Tcl_BinaryObjCmd: format} { 199 binary format A2X2b9 oo 01001101 200} \xB2\x00 201test binary-5.7 {Tcl_BinaryObjCmd: format} { 202 binary format b9 010011011010 203} \xB2\x01 204test binary-5.8 {Tcl_BinaryObjCmd: format} { 205 binary format b17 1 206} \x01\x00\x00 207test binary-5.9 {Tcl_BinaryObjCmd: format} { 208 binary format b2b3 10 010 209} \x01\x02 210test binary-5.10 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 211 binary format b1b5 1 foo 212} -result {expected binary string but got "foo" instead} 213 214test binary-6.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 215 binary format h 216} -result {not enough arguments for all format specifiers} 217test binary-6.2 {Tcl_BinaryObjCmd: format} { 218 binary format h0 1 219} {} 220test binary-6.3 {Tcl_BinaryObjCmd: format} { 221 binary format h 1 222} \x01 223test binary-6.4 {Tcl_BinaryObjCmd: format} { 224 binary format h c 225} \x0C 226test binary-6.5 {Tcl_BinaryObjCmd: format} { 227 binary format h* baadf00d 228} \xAB\xDA\x0F\xD0 229test binary-6.6 {Tcl_BinaryObjCmd: format} { 230 binary format h4 c410 231} \x4C\x01 232test binary-6.7 {Tcl_BinaryObjCmd: format} { 233 binary format h6 c4102 234} \x4C\x01\x02 235test binary-6.8 {Tcl_BinaryObjCmd: format} { 236 binary format h5 c41020304 237} \x4C\x01\x02 238test binary-6.9 {Tcl_BinaryObjCmd: format} { 239 binary format a3X3h5 foo 2 240} \x02\x00\x00 241test binary-6.10 {Tcl_BinaryObjCmd: format} { 242 binary format h2h3 23 456 243} \x32\x54\x06 244test binary-6.11 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 245 binary format h2 foo 246} -result {expected hexadecimal string but got "foo" instead} 247 248test binary-7.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 249 binary format H 250} -result {not enough arguments for all format specifiers} 251test binary-7.2 {Tcl_BinaryObjCmd: format} { 252 binary format H0 1 253} {} 254test binary-7.3 {Tcl_BinaryObjCmd: format} { 255 binary format H 1 256} \x10 257test binary-7.4 {Tcl_BinaryObjCmd: format} { 258 binary format H c 259} \xC0 260test binary-7.5 {Tcl_BinaryObjCmd: format} { 261 binary format H* baadf00d 262} \xBA\xAD\xF0\x0D 263test binary-7.6 {Tcl_BinaryObjCmd: format} { 264 binary format H4 c410 265} \xC4\x10 266test binary-7.7 {Tcl_BinaryObjCmd: format} { 267 binary format H6 c4102 268} \xC4\x10\x20 269test binary-7.8 {Tcl_BinaryObjCmd: format} { 270 binary format H5 c41023304 271} \xC4\x10\x20 272test binary-7.9 {Tcl_BinaryObjCmd: format} { 273 binary format a3X3H5 foo 2 274} \x20\x00\x00 275test binary-7.10 {Tcl_BinaryObjCmd: format} { 276 binary format H2H3 23 456 277} \x23\x45\x60 278test binary-7.11 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 279 binary format H2 foo 280} -result {expected hexadecimal string but got "foo" instead} 281 282test binary-8.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 283 binary format c 284} -result {not enough arguments for all format specifiers} 285test binary-8.2 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 286 binary format c blat 287} -result {expected integer but got "blat"} 288test binary-8.3 {Tcl_BinaryObjCmd: format} { 289 binary format c0 0x50 290} {} 291test binary-8.4 {Tcl_BinaryObjCmd: format} { 292 binary format c 0x50 293} P 294test binary-8.5 {Tcl_BinaryObjCmd: format} { 295 binary format c 0x5052 296} R 297test binary-8.6 {Tcl_BinaryObjCmd: format} { 298 binary format c2 {0x50 0x52} 299} PR 300test binary-8.7 {Tcl_BinaryObjCmd: format} { 301 binary format c2 {0x50 0x52 0x53} 302} PR 303test binary-8.8 {Tcl_BinaryObjCmd: format} { 304 binary format c* {0x50 0x52} 305} PR 306test binary-8.9 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 307 binary format c2 {0x50} 308} -result {number of elements in list does not match count} 309test binary-8.10 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 310 set a {0x50 0x51} 311 binary format c $a 312} -result "expected integer but got \"0x50 0x51\"" 313test binary-8.11 {Tcl_BinaryObjCmd: format} { 314 set a {0x50 0x51} 315 binary format c1 $a 316} P 317 318test binary-9.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 319 binary format s 320} -result {not enough arguments for all format specifiers} 321test binary-9.2 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 322 binary format s blat 323} -result {expected integer but got "blat"} 324test binary-9.3 {Tcl_BinaryObjCmd: format} { 325 binary format s0 0x50 326} {} 327test binary-9.4 {Tcl_BinaryObjCmd: format} { 328 binary format s 0x50 329} P\x00 330test binary-9.5 {Tcl_BinaryObjCmd: format} { 331 binary format s 0x5052 332} RP 333test binary-9.6 {Tcl_BinaryObjCmd: format} { 334 binary format s 0x505251 0x53 335} QR 336test binary-9.7 {Tcl_BinaryObjCmd: format} { 337 binary format s2 {0x50 0x52} 338} P\x00R\x00 339test binary-9.8 {Tcl_BinaryObjCmd: format} { 340 binary format s* {0x5051 0x52} 341} QPR\x00 342test binary-9.9 {Tcl_BinaryObjCmd: format} { 343 binary format s2 {0x50 0x52 0x53} 0x54 344} P\x00R\x00 345test binary-9.10 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 346 binary format s2 {0x50} 347} -result {number of elements in list does not match count} 348test binary-9.11 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 349 set a {0x50 0x51} 350 binary format s $a 351} -result "expected integer but got \"0x50 0x51\"" 352test binary-9.12 {Tcl_BinaryObjCmd: format} { 353 set a {0x50 0x51} 354 binary format s1 $a 355} P\x00 356 357test binary-10.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 358 binary format S 359} -result {not enough arguments for all format specifiers} 360test binary-10.2 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 361 binary format S blat 362} -result {expected integer but got "blat"} 363test binary-10.3 {Tcl_BinaryObjCmd: format} { 364 binary format S0 0x50 365} {} 366test binary-10.4 {Tcl_BinaryObjCmd: format} { 367 binary format S 0x50 368} \x00P 369test binary-10.5 {Tcl_BinaryObjCmd: format} { 370 binary format S 0x5052 371} PR 372test binary-10.6 {Tcl_BinaryObjCmd: format} { 373 binary format S 0x505251 0x53 374} RQ 375test binary-10.7 {Tcl_BinaryObjCmd: format} { 376 binary format S2 {0x50 0x52} 377} \x00P\x00R 378test binary-10.8 {Tcl_BinaryObjCmd: format} { 379 binary format S* {0x5051 0x52} 380} PQ\x00R 381test binary-10.9 {Tcl_BinaryObjCmd: format} { 382 binary format S2 {0x50 0x52 0x53} 0x54 383} \x00P\x00R 384test binary-10.10 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 385 binary format S2 {0x50} 386} -result {number of elements in list does not match count} 387test binary-10.11 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 388 set a {0x50 0x51} 389 binary format S $a 390} -result "expected integer but got \"0x50 0x51\"" 391test binary-10.12 {Tcl_BinaryObjCmd: format} { 392 set a {0x50 0x51} 393 binary format S1 $a 394} \x00P 395 396test binary-11.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 397 binary format i 398} -result {not enough arguments for all format specifiers} 399test binary-11.2 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 400 binary format i blat 401} -result {expected integer but got "blat"} 402test binary-11.3 {Tcl_BinaryObjCmd: format} { 403 binary format i0 0x50 404} {} 405test binary-11.4 {Tcl_BinaryObjCmd: format} { 406 binary format i 0x50 407} P\x00\x00\x00 408test binary-11.5 {Tcl_BinaryObjCmd: format} { 409 binary format i 0x5052 410} RP\x00\x00 411test binary-11.6 {Tcl_BinaryObjCmd: format} { 412 binary format i 0x505251 0x53 413} QRP\x00 414test binary-11.7 {Tcl_BinaryObjCmd: format} { 415 binary format i1 {0x505251 0x53} 416} QRP\x00 417test binary-11.8 {Tcl_BinaryObjCmd: format} { 418 binary format i 0x53525150 419} PQRS 420test binary-11.9 {Tcl_BinaryObjCmd: format} { 421 binary format i2 {0x50 0x52} 422} P\x00\x00\x00R\x00\x00\x00 423test binary-11.10 {Tcl_BinaryObjCmd: format} { 424 binary format i* {0x50515253 0x52} 425} SRQPR\x00\x00\x00 426test binary-11.11 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 427 binary format i2 {0x50} 428} -result {number of elements in list does not match count} 429test binary-11.12 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 430 set a {0x50 0x51} 431 binary format i $a 432} -result "expected integer but got \"0x50 0x51\"" 433test binary-11.13 {Tcl_BinaryObjCmd: format} { 434 set a {0x50 0x51} 435 binary format i1 $a 436} P\x00\x00\x00 437 438test binary-12.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 439 binary format I 440} -result {not enough arguments for all format specifiers} 441test binary-12.2 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 442 binary format I blat 443} -result {expected integer but got "blat"} 444test binary-12.3 {Tcl_BinaryObjCmd: format} { 445 binary format I0 0x50 446} {} 447test binary-12.4 {Tcl_BinaryObjCmd: format} { 448 binary format I 0x50 449} \x00\x00\x00P 450test binary-12.5 {Tcl_BinaryObjCmd: format} { 451 binary format I 0x5052 452} \x00\x00PR 453test binary-12.6 {Tcl_BinaryObjCmd: format} { 454 binary format I 0x505251 0x53 455} \x00PRQ 456test binary-12.7 {Tcl_BinaryObjCmd: format} { 457 binary format I1 {0x505251 0x53} 458} \x00PRQ 459test binary-12.8 {Tcl_BinaryObjCmd: format} { 460 binary format I 0x53525150 461} SRQP 462test binary-12.9 {Tcl_BinaryObjCmd: format} { 463 binary format I2 {0x50 0x52} 464} \x00\x00\x00P\x00\x00\x00R 465test binary-12.10 {Tcl_BinaryObjCmd: format} { 466 binary format I* {0x50515253 0x52} 467} PQRS\x00\x00\x00R 468test binary-12.11 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 469 binary format i2 {0x50} 470} -result {number of elements in list does not match count} 471test binary-12.12 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 472 set a {0x50 0x51} 473 binary format I $a 474} -result "expected integer but got \"0x50 0x51\"" 475test binary-12.13 {Tcl_BinaryObjCmd: format} { 476 set a {0x50 0x51} 477 binary format I1 $a 478} \x00\x00\x00P 479 480test binary-13.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 481 binary format f 482} -result {not enough arguments for all format specifiers} 483test binary-13.2 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 484 binary format f blat 485} -result {expected floating-point number but got "blat"} 486test binary-13.3 {Tcl_BinaryObjCmd: format} { 487 binary format f0 1.6 488} {} 489test binary-13.4 {Tcl_BinaryObjCmd: format} bigEndian { 490 binary format f 1.6 491} \x3F\xCC\xCC\xCD 492test binary-13.5 {Tcl_BinaryObjCmd: format} littleEndian { 493 binary format f 1.6 494} \xCD\xCC\xCC\x3F 495test binary-13.6 {Tcl_BinaryObjCmd: format} bigEndian { 496 binary format f* {1.6 3.4} 497} \x3F\xCC\xCC\xCD\x40\x59\x99\x9A 498test binary-13.7 {Tcl_BinaryObjCmd: format} littleEndian { 499 binary format f* {1.6 3.4} 500} \xCD\xCC\xCC\x3F\x9A\x99\x59\x40 501test binary-13.8 {Tcl_BinaryObjCmd: format} bigEndian { 502 binary format f2 {1.6 3.4} 503} \x3F\xCC\xCC\xCD\x40\x59\x99\x9A 504test binary-13.9 {Tcl_BinaryObjCmd: format} littleEndian { 505 binary format f2 {1.6 3.4} 506} \xCD\xCC\xCC\x3F\x9A\x99\x59\x40 507test binary-13.10 {Tcl_BinaryObjCmd: format} bigEndian { 508 binary format f2 {1.6 3.4 5.6} 509} \x3F\xCC\xCC\xCD\x40\x59\x99\x9A 510test binary-13.11 {Tcl_BinaryObjCmd: format} littleEndian { 511 binary format f2 {1.6 3.4 5.6} 512} \xCD\xCC\xCC\x3F\x9A\x99\x59\x40 513test binary-13.12 {Tcl_BinaryObjCmd: float overflow} bigEndian { 514 binary format f -3.402825e+38 515} \xFF\x7F\xFF\xFF 516test binary-13.13 {Tcl_BinaryObjCmd: float overflow} littleEndian { 517 binary format f -3.402825e+38 518} \xFF\xFF\x7F\xFF 519test binary-13.14 {Tcl_BinaryObjCmd: float underflow} bigEndian { 520 binary format f -3.402825e-100 521} \x80\x00\x00\x00 522test binary-13.15 {Tcl_BinaryObjCmd: float underflow} littleEndian { 523 binary format f -3.402825e-100 524} \x00\x00\x00\x80 525test binary-13.16 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 526 binary format f2 {1.6} 527} -result {number of elements in list does not match count} 528test binary-13.17 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 529 set a {1.6 3.4} 530 binary format f $a 531} -result "expected floating-point number but got \"1.6 3.4\"" 532test binary-13.18 {Tcl_BinaryObjCmd: format} bigEndian { 533 set a {1.6 3.4} 534 binary format f1 $a 535} \x3F\xCC\xCC\xCD 536test binary-13.19 {Tcl_BinaryObjCmd: format} littleEndian { 537 set a {1.6 3.4} 538 binary format f1 $a 539} \xCD\xCC\xCC\x3F 540 541test binary-14.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 542 binary format d 543} -result {not enough arguments for all format specifiers} 544test binary-14.2 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 545 binary format d blat 546} -result {expected floating-point number but got "blat"} 547test binary-14.3 {Tcl_BinaryObjCmd: format} { 548 binary format d0 1.6 549} {} 550test binary-14.4 {Tcl_BinaryObjCmd: format} bigEndian { 551 binary format d 1.6 552} \x3F\xF9\x99\x99\x99\x99\x99\x9A 553test binary-14.5 {Tcl_BinaryObjCmd: format} littleEndian { 554 binary format d 1.6 555} \x9A\x99\x99\x99\x99\x99\xF9\x3F 556test binary-14.6 {Tcl_BinaryObjCmd: format} bigEndian { 557 binary format d* {1.6 3.4} 558} \x3F\xF9\x99\x99\x99\x99\x99\x9A\x40\x0B\x33\x33\x33\x33\x33\x33 559test binary-14.7 {Tcl_BinaryObjCmd: format} littleEndian { 560 binary format d* {1.6 3.4} 561} \x9A\x99\x99\x99\x99\x99\xF9\x3F\x33\x33\x33\x33\x33\x33\x0B\x40 562test binary-14.8 {Tcl_BinaryObjCmd: format} bigEndian { 563 binary format d2 {1.6 3.4} 564} \x3F\xF9\x99\x99\x99\x99\x99\x9A\x40\x0B\x33\x33\x33\x33\x33\x33 565test binary-14.9 {Tcl_BinaryObjCmd: format} littleEndian { 566 binary format d2 {1.6 3.4} 567} \x9A\x99\x99\x99\x99\x99\xF9\x3F\x33\x33\x33\x33\x33\x33\x0B\x40 568test binary-14.10 {Tcl_BinaryObjCmd: format} bigEndian { 569 binary format d2 {1.6 3.4 5.6} 570} \x3F\xF9\x99\x99\x99\x99\x99\x9A\x40\x0B\x33\x33\x33\x33\x33\x33 571test binary-14.11 {Tcl_BinaryObjCmd: format} littleEndian { 572 binary format d2 {1.6 3.4 5.6} 573} \x9A\x99\x99\x99\x99\x99\xF9\x3F\x33\x33\x33\x33\x33\x33\x0B\x40 574test binary-14.14 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 575 binary format d2 {1.6} 576} -result {number of elements in list does not match count} 577test binary-14.15 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 578 set a {1.6 3.4} 579 binary format d $a 580} -result "expected floating-point number but got \"1.6 3.4\"" 581test binary-14.16 {Tcl_BinaryObjCmd: format} bigEndian { 582 set a {1.6 3.4} 583 binary format d1 $a 584} \x3F\xF9\x99\x99\x99\x99\x99\x9A 585test binary-14.17 {Tcl_BinaryObjCmd: format} littleEndian { 586 set a {1.6 3.4} 587 binary format d1 $a 588} \x9A\x99\x99\x99\x99\x99\xF9\x3F 589test binary-14.18 {FormatNumber: Bug 1116542} { 590 binary scan [binary format d 1.25] d w 591 set w 592} 1.25 593 594test binary-15.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 595 binary format ax*a "y" "z" 596} -result {cannot use "*" in format string with "x"} 597test binary-15.2 {Tcl_BinaryObjCmd: format} { 598 binary format axa "y" "z" 599} y\x00z 600test binary-15.3 {Tcl_BinaryObjCmd: format} { 601 binary format ax3a "y" "z" 602} y\x00\x00\x00z 603test binary-15.4 {Tcl_BinaryObjCmd: format} { 604 binary format a*X3x3a* "foo" "z" 605} \x00\x00\x00z 606test binary-15.5 {Tcl_BinaryObjCmd: format - bug #1923966} { 607 binary format x0s 1 608} \x01\x00 609test binary-15.6 {Tcl_BinaryObjCmd: format - bug #1923966} { 610 binary format x0ss 1 1 611} \x01\x00\x01\x00 612test binary-15.7 {Tcl_BinaryObjCmd: format - bug #1923966} { 613 binary format x1s 1 614} \x00\x01\x00 615test binary-15.8 {Tcl_BinaryObjCmd: format - bug #1923966} { 616 binary format x1ss 1 1 617} \x00\x01\x00\x01\x00 618 619test binary-16.1 {Tcl_BinaryObjCmd: format} { 620 binary format a*X*a "foo" "z" 621} zoo 622test binary-16.2 {Tcl_BinaryObjCmd: format} { 623 binary format aX3a "y" "z" 624} z 625test binary-16.3 {Tcl_BinaryObjCmd: format} { 626 binary format a*Xa* "foo" "zy" 627} fozy 628test binary-16.4 {Tcl_BinaryObjCmd: format} { 629 binary format a*X3a "foobar" "z" 630} foozar 631test binary-16.5 {Tcl_BinaryObjCmd: format} { 632 binary format a*X3aX2a "foobar" "z" "b" 633} fobzar 634 635test binary-17.1 {Tcl_BinaryObjCmd: format} { 636 binary format @1 637} \x00 638test binary-17.2 {Tcl_BinaryObjCmd: format} { 639 binary format @5a2 "ab" 640} \x00\x00\x00\x00\x00\x61\x62 641test binary-17.3 {Tcl_BinaryObjCmd: format} { 642 binary format {a* @0 a2 @* a*} "foobar" "ab" "blat" 643} abobarblat 644 645test binary-18.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 646 binary format u0a3 abc abd 647} -result {bad field specifier "u"} 648 649test binary-19.1 {Tcl_BinaryObjCmd: errors} -returnCodes error -body { 650 binary s 651} -result {wrong # args: should be "binary scan value formatString ?varName ...?"} 652test binary-19.2 {Tcl_BinaryObjCmd: errors} -returnCodes error -body { 653 binary scan foo 654} -result {wrong # args: should be "binary scan value formatString ?varName ...?"} 655test binary-19.3 {Tcl_BinaryObjCmd: scan} { 656 binary scan {} {} 657} 0 658 659test binary-20.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body { 660 binary scan abc a 661} -result {not enough arguments for all format specifiers} 662test binary-20.2 {Tcl_BinaryObjCmd: scan} -setup { 663 unset -nocomplain arg1 664} -returnCodes error -body { 665 set arg1 1 666 binary scan abc a arg1(a) 667} -result {can't set "arg1(a)": variable isn't array} 668test binary-20.3 {Tcl_BinaryObjCmd: scan} -setup { 669 unset -nocomplain arg1 670} -body { 671 set arg1 abc 672 list [binary scan abc a0 arg1] $arg1 673} -result {1 {}} 674test binary-20.4 {Tcl_BinaryObjCmd: scan} -setup { 675 unset -nocomplain arg1 676} -body { 677 list [binary scan abc a* arg1] $arg1 678} -result {1 abc} 679test binary-20.5 {Tcl_BinaryObjCmd: scan} -setup { 680 unset -nocomplain arg1 681} -body { 682 list [binary scan abc a5 arg1] [info exists arg1] 683} -result {0 0} 684test binary-20.6 {Tcl_BinaryObjCmd: scan} { 685 set arg1 foo 686 list [binary scan abc a2 arg1] $arg1 687} {1 ab} 688test binary-20.7 {Tcl_BinaryObjCmd: scan} -setup { 689 unset -nocomplain arg1 690 unset -nocomplain arg2 691} -body { 692 list [binary scan abcdef a2a2 arg1 arg2] $arg1 $arg2 693} -result {2 ab cd} 694test binary-20.8 {Tcl_BinaryObjCmd: scan} -setup { 695 unset -nocomplain arg1 696} -body { 697 list [binary scan abc a2 arg1(a)] $arg1(a) 698} -result {1 ab} 699test binary-20.9 {Tcl_BinaryObjCmd: scan} -setup { 700 unset -nocomplain arg1 701} -body { 702 list [binary scan abc a arg1(a)] $arg1(a) 703} -result {1 a} 704 705test binary-21.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body { 706 binary scan abc A 707} -result {not enough arguments for all format specifiers} 708test binary-21.2 {Tcl_BinaryObjCmd: scan} -setup { 709 unset -nocomplain arg1 710} -returnCodes error -body { 711 set arg1 1 712 binary scan abc A arg1(a) 713} -result {can't set "arg1(a)": variable isn't array} 714test binary-21.3 {Tcl_BinaryObjCmd: scan} -setup { 715 unset -nocomplain arg1 716} -body { 717 set arg1 abc 718 list [binary scan abc A0 arg1] $arg1 719} -result {1 {}} 720test binary-21.4 {Tcl_BinaryObjCmd: scan} -setup { 721 unset -nocomplain arg1 722} -body { 723 list [binary scan abc A* arg1] $arg1 724} -result {1 abc} 725test binary-21.5 {Tcl_BinaryObjCmd: scan} -setup { 726 unset -nocomplain arg1 727} -body { 728 list [binary scan abc A5 arg1] [info exists arg1] 729} -result {0 0} 730test binary-21.6 {Tcl_BinaryObjCmd: scan} { 731 set arg1 foo 732 list [binary scan abc A2 arg1] $arg1 733} {1 ab} 734test binary-21.7 {Tcl_BinaryObjCmd: scan} -setup { 735 unset -nocomplain arg1 736 unset -nocomplain arg2 737} -body { 738 list [binary scan abcdef A2A2 arg1 arg2] $arg1 $arg2 739} -result {2 ab cd} 740test binary-21.8 {Tcl_BinaryObjCmd: scan} -setup { 741 unset -nocomplain arg1 742} -body { 743 list [binary scan abc A2 arg1(a)] $arg1(a) 744} -result {1 ab} 745test binary-21.9 {Tcl_BinaryObjCmd: scan} -setup { 746 unset -nocomplain arg1 747} -body { 748 list [binary scan abc A2 arg1(a)] $arg1(a) 749} -result {1 ab} 750test binary-21.10 {Tcl_BinaryObjCmd: scan} -setup { 751 unset -nocomplain arg1 752} -body { 753 list [binary scan abc A arg1(a)] $arg1(a) 754} -result {1 a} 755test binary-21.11 {Tcl_BinaryObjCmd: scan} -setup { 756 unset -nocomplain arg1 757} -body { 758 list [binary scan "abc def \x00 " A* arg1] $arg1 759} -result {1 {abc def}} 760test binary-21.12 {Tcl_BinaryObjCmd: scan} -setup { 761 unset -nocomplain arg1 762} -body { 763 list [binary scan "abc def \x00ghi " A* arg1] $arg1 764} -result [list 1 "abc def \x00ghi"] 765test binary-21.13 {Tcl_BinaryObjCmd: scan} -setup { 766 unset -nocomplain arg1 767} -body { 768 list [binary scan "abc def \x00 " C* arg1] $arg1 769} -result {1 {abc def }} 770test binary-21.12 {Tcl_BinaryObjCmd: scan} -setup { 771 unset -nocomplain arg1 772} -body { 773 list [binary scan "abc def \x00ghi" C* arg1] $arg1 774} -result {1 {abc def }} 775test binary-22.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body { 776 binary scan abc b 777} -result {not enough arguments for all format specifiers} 778test binary-22.2 {Tcl_BinaryObjCmd: scan} { 779 unset -nocomplain arg1 780 list [binary scan \x52\x53 b* arg1] $arg1 781} {1 0100101011001010} 782test binary-22.3 {Tcl_BinaryObjCmd: scan} { 783 unset -nocomplain arg1 784 list [binary scan \x82\x53 b arg1] $arg1 785} {1 0} 786test binary-22.4 {Tcl_BinaryObjCmd: scan} { 787 unset -nocomplain arg1 788 list [binary scan \x82\x53 b1 arg1] $arg1 789} {1 0} 790test binary-22.5 {Tcl_BinaryObjCmd: scan} { 791 unset -nocomplain arg1 792 list [binary scan \x82\x53 b0 arg1] $arg1 793} {1 {}} 794test binary-22.6 {Tcl_BinaryObjCmd: scan} { 795 unset -nocomplain arg1 796 list [binary scan \x52\x53 b5 arg1] $arg1 797} {1 01001} 798test binary-22.7 {Tcl_BinaryObjCmd: scan} { 799 unset -nocomplain arg1 800 list [binary scan \x52\x53 b8 arg1] $arg1 801} {1 01001010} 802test binary-22.8 {Tcl_BinaryObjCmd: scan} { 803 unset -nocomplain arg1 804 list [binary scan \x52\x53 b14 arg1] $arg1 805} {1 01001010110010} 806test binary-22.9 {Tcl_BinaryObjCmd: scan} { 807 unset -nocomplain arg1 808 set arg1 foo 809 list [binary scan \x52 b14 arg1] $arg1 810} {0 foo} 811test binary-22.10 {Tcl_BinaryObjCmd: scan} -setup { 812 unset -nocomplain arg1 813} -returnCodes error -body { 814 set arg1 1 815 binary scan \x52\x53 b1 arg1(a) 816} -result {can't set "arg1(a)": variable isn't array} 817test binary-22.11 {Tcl_BinaryObjCmd: scan} -setup { 818 unset -nocomplain arg1 arg2 819} -body { 820 set arg1 foo 821 set arg2 bar 822 list [binary scan \x07\x87\x05 b5b* arg1 arg2] $arg1 $arg2 823} -result {2 11100 1110000110100000} 824 825test binary-23.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body { 826 binary scan abc B 827} -result {not enough arguments for all format specifiers} 828test binary-23.2 {Tcl_BinaryObjCmd: scan} { 829 unset -nocomplain arg1 830 list [binary scan \x52\x53 B* arg1] $arg1 831} {1 0101001001010011} 832test binary-23.3 {Tcl_BinaryObjCmd: scan} { 833 unset -nocomplain arg1 834 list [binary scan \x82\x53 B arg1] $arg1 835} {1 1} 836test binary-23.4 {Tcl_BinaryObjCmd: scan} { 837 unset -nocomplain arg1 838 list [binary scan \x82\x53 B1 arg1] $arg1 839} {1 1} 840test binary-23.5 {Tcl_BinaryObjCmd: scan} { 841 unset -nocomplain arg1 842 list [binary scan \x52\x53 B0 arg1] $arg1 843} {1 {}} 844test binary-23.6 {Tcl_BinaryObjCmd: scan} { 845 unset -nocomplain arg1 846 list [binary scan \x52\x53 B5 arg1] $arg1 847} {1 01010} 848test binary-23.7 {Tcl_BinaryObjCmd: scan} { 849 unset -nocomplain arg1 850 list [binary scan \x52\x53 B8 arg1] $arg1 851} {1 01010010} 852test binary-23.8 {Tcl_BinaryObjCmd: scan} { 853 unset -nocomplain arg1 854 list [binary scan \x52\x53 B14 arg1] $arg1 855} {1 01010010010100} 856test binary-23.9 {Tcl_BinaryObjCmd: scan} { 857 unset -nocomplain arg1 858 set arg1 foo 859 list [binary scan \x52 B14 arg1] $arg1 860} {0 foo} 861test binary-23.10 {Tcl_BinaryObjCmd: scan} -setup { 862 unset -nocomplain arg1 863} -returnCodes error -body { 864 set arg1 1 865 binary scan \x52\x53 B1 arg1(a) 866} -result {can't set "arg1(a)": variable isn't array} 867test binary-23.11 {Tcl_BinaryObjCmd: scan} -setup { 868 unset -nocomplain arg1 arg2 869} -body { 870 set arg1 foo 871 set arg2 bar 872 list [binary scan \x70\x87\x05 B5B* arg1 arg2] $arg1 $arg2 873} -result {2 01110 1000011100000101} 874 875test binary-24.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body { 876 binary scan abc h 877} -result {not enough arguments for all format specifiers} 878test binary-24.2 {Tcl_BinaryObjCmd: scan} { 879 unset -nocomplain arg1 880 list [binary scan \x52\xA3 h* arg1] $arg1 881} {1 253a} 882test binary-24.3 {Tcl_BinaryObjCmd: scan} { 883 unset -nocomplain arg1 884 list [binary scan \xC2\xA3 h arg1] $arg1 885} {1 2} 886test binary-24.4 {Tcl_BinaryObjCmd: scan} { 887 unset -nocomplain arg1 888 list [binary scan \x82\x53 h1 arg1] $arg1 889} {1 2} 890test binary-24.5 {Tcl_BinaryObjCmd: scan} { 891 unset -nocomplain arg1 892 list [binary scan \x52\x53 h0 arg1] $arg1 893} {1 {}} 894test binary-24.6 {Tcl_BinaryObjCmd: scan} { 895 unset -nocomplain arg1 896 list [binary scan \xF2\x53 h2 arg1] $arg1 897} {1 2f} 898test binary-24.7 {Tcl_BinaryObjCmd: scan} { 899 unset -nocomplain arg1 900 list [binary scan \x52\x53 h3 arg1] $arg1 901} {1 253} 902test binary-24.8 {Tcl_BinaryObjCmd: scan} { 903 unset -nocomplain arg1 904 set arg1 foo 905 list [binary scan \x52 h3 arg1] $arg1 906} {0 foo} 907test binary-24.9 {Tcl_BinaryObjCmd: scan} -setup { 908 unset -nocomplain arg1 909} -returnCodes error -body { 910 set arg1 1 911 binary scan \x52\x53 h1 arg1(a) 912} -result {can't set "arg1(a)": variable isn't array} 913test binary-24.10 {Tcl_BinaryObjCmd: scan} -setup { 914 unset -nocomplain arg1 arg2 915} -body { 916 set arg1 foo 917 set arg2 bar 918 list [binary scan \x70\x87\x05 h2h* arg1 arg2] $arg1 $arg2 919} -result {2 07 7850} 920 921test binary-25.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body { 922 binary scan abc H 923} -result {not enough arguments for all format specifiers} 924test binary-25.2 {Tcl_BinaryObjCmd: scan} { 925 unset -nocomplain arg1 926 list [binary scan \x52\xA3 H* arg1] $arg1 927} {1 52a3} 928test binary-25.3 {Tcl_BinaryObjCmd: scan} { 929 unset -nocomplain arg1 930 list [binary scan \xC2\xA3 H arg1] $arg1 931} {1 c} 932test binary-25.4 {Tcl_BinaryObjCmd: scan} { 933 unset -nocomplain arg1 934 list [binary scan \x82\x53 H1 arg1] $arg1 935} {1 8} 936test binary-25.5 {Tcl_BinaryObjCmd: scan} { 937 unset -nocomplain arg1 938 list [binary scan \x52\x53 H0 arg1] $arg1 939} {1 {}} 940test binary-25.6 {Tcl_BinaryObjCmd: scan} { 941 unset -nocomplain arg1 942 list [binary scan \xF2\x53 H2 arg1] $arg1 943} {1 f2} 944test binary-25.7 {Tcl_BinaryObjCmd: scan} { 945 unset -nocomplain arg1 946 list [binary scan \x52\x53 H3 arg1] $arg1 947} {1 525} 948test binary-25.8 {Tcl_BinaryObjCmd: scan} { 949 unset -nocomplain arg1 950 set arg1 foo 951 list [binary scan \x52 H3 arg1] $arg1 952} {0 foo} 953test binary-25.9 {Tcl_BinaryObjCmd: scan} -setup { 954 unset -nocomplain arg1 955} -returnCodes error -body { 956 set arg1 1 957 binary scan \x52\x53 H1 arg1(a) 958} -result {can't set "arg1(a)": variable isn't array} 959test binary-25.10 {Tcl_BinaryObjCmd: scan} { 960 unset -nocomplain arg1 arg2 961 set arg1 foo 962 set arg2 bar 963 list [binary scan \x70\x87\x05 H2H* arg1 arg2] $arg1 $arg2 964} {2 70 8705} 965 966test binary-26.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body { 967 binary scan abc c 968} -result {not enough arguments for all format specifiers} 969test binary-26.2 {Tcl_BinaryObjCmd: scan} { 970 unset -nocomplain arg1 971 list [binary scan \x52\xA3 c* arg1] $arg1 972} {1 {82 -93}} 973test binary-26.3 {Tcl_BinaryObjCmd: scan} { 974 unset -nocomplain arg1 975 list [binary scan \x52\xA3 c arg1] $arg1 976} {1 82} 977test binary-26.4 {Tcl_BinaryObjCmd: scan} { 978 unset -nocomplain arg1 979 list [binary scan \x52\xA3 c1 arg1] $arg1 980} {1 82} 981test binary-26.5 {Tcl_BinaryObjCmd: scan} { 982 unset -nocomplain arg1 983 list [binary scan \x52\xA3 c0 arg1] $arg1 984} {1 {}} 985test binary-26.6 {Tcl_BinaryObjCmd: scan} { 986 unset -nocomplain arg1 987 list [binary scan \x52\xA3 c2 arg1] $arg1 988} {1 {82 -93}} 989test binary-26.7 {Tcl_BinaryObjCmd: scan} { 990 unset -nocomplain arg1 991 list [binary scan \xFF c arg1] $arg1 992} {1 -1} 993test binary-26.8 {Tcl_BinaryObjCmd: scan} { 994 unset -nocomplain arg1 995 set arg1 foo 996 list [binary scan \x52 c3 arg1] $arg1 997} {0 foo} 998test binary-26.9 {Tcl_BinaryObjCmd: scan} -setup { 999 unset -nocomplain arg1 1000} -returnCodes error -body { 1001 set arg1 1 1002 binary scan \x52\x53 c1 arg1(a) 1003} -result {can't set "arg1(a)": variable isn't array} 1004test binary-26.10 {Tcl_BinaryObjCmd: scan} { 1005 unset -nocomplain arg1 arg2 1006 set arg1 foo 1007 set arg2 bar 1008 list [binary scan \x70\x87\x05 c2c* arg1 arg2] $arg1 $arg2 1009} {2 {112 -121} 5} 1010test binary-26.11 {Tcl_BinaryObjCmd: scan} { 1011 unset -nocomplain arg1 1012 list [binary scan \x52\xA3 cu* arg1] $arg1 1013} {1 {82 163}} 1014test binary-26.12 {Tcl_BinaryObjCmd: scan} { 1015 unset -nocomplain arg1 1016 list [binary scan \x52\xA3 cu arg1] $arg1 1017} {1 82} 1018test binary-26.13 {Tcl_BinaryObjCmd: scan} { 1019 unset -nocomplain arg1 1020 list [binary scan \xFF cu arg1] $arg1 1021} {1 255} 1022test binary-26.14 {Tcl_BinaryObjCmd: scan} { 1023 unset -nocomplain arg1 arg2 1024 set arg1 foo 1025 set arg2 bar 1026 list [binary scan \x80\x80 cuc arg1 arg2] $arg1 $arg2 1027} {2 128 -128} 1028test binary-26.15 {Tcl_BinaryObjCmd: scan} { 1029 unset -nocomplain arg1 arg2 1030 set arg1 foo 1031 set arg2 bar 1032 list [binary scan \x80\x80 ccu arg1 arg2] $arg1 $arg2 1033} {2 -128 128} 1034 1035test binary-27.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body { 1036 binary scan abc s 1037} -result {not enough arguments for all format specifiers} 1038test binary-27.2 {Tcl_BinaryObjCmd: scan} { 1039 unset -nocomplain arg1 1040 list [binary scan \x52\xA3\x53\x54 s* arg1] $arg1 1041} {1 {-23726 21587}} 1042test binary-27.3 {Tcl_BinaryObjCmd: scan} { 1043 unset -nocomplain arg1 1044 list [binary scan \x52\xA3\x53\x54 s arg1] $arg1 1045} {1 -23726} 1046test binary-27.4 {Tcl_BinaryObjCmd: scan} { 1047 unset -nocomplain arg1 1048 list [binary scan \x52\xA3 s1 arg1] $arg1 1049} {1 -23726} 1050test binary-27.5 {Tcl_BinaryObjCmd: scan} { 1051 unset -nocomplain arg1 1052 list [binary scan \x52\xA3 s0 arg1] $arg1 1053} {1 {}} 1054test binary-27.6 {Tcl_BinaryObjCmd: scan} { 1055 unset -nocomplain arg1 1056 list [binary scan \x52\xA3\x53\x54 s2 arg1] $arg1 1057} {1 {-23726 21587}} 1058test binary-27.7 {Tcl_BinaryObjCmd: scan} { 1059 unset -nocomplain arg1 1060 set arg1 foo 1061 list [binary scan \x52 s1 arg1] $arg1 1062} {0 foo} 1063test binary-27.8 {Tcl_BinaryObjCmd: scan} -setup { 1064 unset -nocomplain arg1 1065} -returnCodes error -body { 1066 set arg1 1 1067 binary scan \x52\x53 s1 arg1(a) 1068} -result {can't set "arg1(a)": variable isn't array} 1069test binary-27.9 {Tcl_BinaryObjCmd: scan} { 1070 unset -nocomplain arg1 arg2 1071 set arg1 foo 1072 set arg2 bar 1073 list [binary scan \x52\xA3\x53\x54\x05 s2c* arg1 arg2] $arg1 $arg2 1074} {2 {-23726 21587} 5} 1075test binary-27.10 {Tcl_BinaryObjCmd: scan} { 1076 unset -nocomplain arg1 1077 list [binary scan \x52\xA3\x53\x54 su* arg1] $arg1 1078} {1 {41810 21587}} 1079test binary-27.11 {Tcl_BinaryObjCmd: scan} { 1080 unset -nocomplain arg1 arg2 1081 set arg1 foo 1082 set arg2 bar 1083 list [binary scan \xFF\xFF\xFF\xFF sus arg1 arg2] $arg1 $arg2 1084} {2 65535 -1} 1085test binary-27.12 {Tcl_BinaryObjCmd: scan} { 1086 unset -nocomplain arg1 arg2 1087 set arg1 foo 1088 set arg2 bar 1089 list [binary scan \xFF\xFF\xFF\xFF ssu arg1 arg2] $arg1 $arg2 1090} {2 -1 65535} 1091 1092test binary-28.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body { 1093 binary scan abc S 1094} -result {not enough arguments for all format specifiers} 1095test binary-28.2 {Tcl_BinaryObjCmd: scan} { 1096 unset -nocomplain arg1 1097 list [binary scan \x52\xA3\x53\x54 S* arg1] $arg1 1098} {1 {21155 21332}} 1099test binary-28.3 {Tcl_BinaryObjCmd: scan} { 1100 unset -nocomplain arg1 1101 list [binary scan \x52\xA3\x53\x54 S arg1] $arg1 1102} {1 21155} 1103test binary-28.4 {Tcl_BinaryObjCmd: scan} { 1104 unset -nocomplain arg1 1105 list [binary scan \x52\xA3 S1 arg1] $arg1 1106} {1 21155} 1107test binary-28.5 {Tcl_BinaryObjCmd: scan} { 1108 unset -nocomplain arg1 1109 list [binary scan \x52\xA3 S0 arg1] $arg1 1110} {1 {}} 1111test binary-28.6 {Tcl_BinaryObjCmd: scan} { 1112 unset -nocomplain arg1 1113 list [binary scan \x52\xA3\x53\x54 S2 arg1] $arg1 1114} {1 {21155 21332}} 1115test binary-28.7 {Tcl_BinaryObjCmd: scan} { 1116 unset -nocomplain arg1 1117 set arg1 foo 1118 list [binary scan \x52 S1 arg1] $arg1 1119} {0 foo} 1120test binary-28.8 {Tcl_BinaryObjCmd: scan} -setup { 1121 unset -nocomplain arg1 1122} -returnCodes error -body { 1123 set arg1 1 1124 binary scan \x52\x53 S1 arg1(a) 1125} -result {can't set "arg1(a)": variable isn't array} 1126test binary-28.9 {Tcl_BinaryObjCmd: scan} { 1127 unset -nocomplain arg1 arg2 1128 set arg1 foo 1129 set arg2 bar 1130 list [binary scan \x52\xA3\x53\x54\x05 S2c* arg1 arg2] $arg1 $arg2 1131} {2 {21155 21332} 5} 1132test binary-28.10 {Tcl_BinaryObjCmd: scan} { 1133 unset -nocomplain arg1 1134 list [binary scan \x52\xA3\x53\x54 Su* arg1] $arg1 1135} {1 {21155 21332}} 1136test binary-28.11 {Tcl_BinaryObjCmd: scan} { 1137 unset -nocomplain arg1 1138 list [binary scan \xA3\x52\x54\x53 Su* arg1] $arg1 1139} {1 {41810 21587}} 1140 1141test binary-29.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body { 1142 binary scan abc i 1143} -result {not enough arguments for all format specifiers} 1144test binary-29.2 {Tcl_BinaryObjCmd: scan} { 1145 unset -nocomplain arg1 1146 list [binary scan \x52\xA3\x53\x54\x01\x02\x03\x04 i* arg1] $arg1 1147} {1 {1414767442 67305985}} 1148test binary-29.3 {Tcl_BinaryObjCmd: scan} { 1149 unset -nocomplain arg1 1150 list [binary scan \x52\xA3\x53\x54\x01\x02\x03\x04 i arg1] $arg1 1151} {1 1414767442} 1152test binary-29.4 {Tcl_BinaryObjCmd: scan} { 1153 unset -nocomplain arg1 1154 list [binary scan \x52\xA3\x53\x54 i1 arg1] $arg1 1155} {1 1414767442} 1156test binary-29.5 {Tcl_BinaryObjCmd: scan} { 1157 unset -nocomplain arg1 1158 list [binary scan \x52\xA3\x53 i0 arg1] $arg1 1159} {1 {}} 1160test binary-29.6 {Tcl_BinaryObjCmd: scan} { 1161 unset -nocomplain arg1 1162 list [binary scan \x52\xA3\x53\x54\x01\x02\x03\x04 i2 arg1] $arg1 1163} {1 {1414767442 67305985}} 1164test binary-29.7 {Tcl_BinaryObjCmd: scan} { 1165 unset -nocomplain arg1 1166 set arg1 foo 1167 list [binary scan \x52 i1 arg1] $arg1 1168} {0 foo} 1169test binary-29.8 {Tcl_BinaryObjCmd: scan} -setup { 1170 unset -nocomplain arg1 1171} -returnCodes error -body { 1172 set arg1 1 1173 binary scan \x52\x53\x53\x54 i1 arg1(a) 1174} -result {can't set "arg1(a)": variable isn't array} 1175test binary-29.9 {Tcl_BinaryObjCmd: scan} { 1176 unset -nocomplain arg1 arg2 1177 set arg1 foo 1178 set arg2 bar 1179 list [binary scan \x52\xA3\x53\x54\x01\x02\x03\x04\x05 i2c* arg1 arg2] $arg1 $arg2 1180} {2 {1414767442 67305985} 5} 1181test binary-29.10 {Tcl_BinaryObjCmd: scan} { 1182 unset -nocomplain arg1 arg2 1183 list [binary scan \xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF iui arg1 arg2] $arg1 $arg2 1184} {2 4294967295 -1} 1185test binary-29.11 {Tcl_BinaryObjCmd: scan} { 1186 unset -nocomplain arg1 arg2 1187 list [binary scan \xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF iiu arg1 arg2] $arg1 $arg2 1188} {2 -1 4294967295} 1189test binary-29.12 {Tcl_BinaryObjCmd: scan} { 1190 unset -nocomplain arg1 arg2 1191 list [binary scan \x80\x00\x00\x00\x00\x00\x00\x80 iuiu arg1 arg2] $arg1 $arg2 1192} {2 128 2147483648} 1193 1194test binary-30.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body { 1195 binary scan abc I 1196} -result {not enough arguments for all format specifiers} 1197test binary-30.2 {Tcl_BinaryObjCmd: scan} { 1198 unset -nocomplain arg1 1199 list [binary scan \x52\xA3\x53\x54\x01\x02\x03\x04 I* arg1] $arg1 1200} {1 {1386435412 16909060}} 1201test binary-30.3 {Tcl_BinaryObjCmd: scan} { 1202 unset -nocomplain arg1 1203 list [binary scan \x52\xA3\x53\x54\x01\x02\x03\x04 I arg1] $arg1 1204} {1 1386435412} 1205test binary-30.4 {Tcl_BinaryObjCmd: scan} { 1206 unset -nocomplain arg1 1207 list [binary scan \x52\xA3\x53\x54 I1 arg1] $arg1 1208} {1 1386435412} 1209test binary-30.5 {Tcl_BinaryObjCmd: scan} { 1210 unset -nocomplain arg1 1211 list [binary scan \x52\xA3\x53 I0 arg1] $arg1 1212} {1 {}} 1213test binary-30.6 {Tcl_BinaryObjCmd: scan} { 1214 unset -nocomplain arg1 1215 list [binary scan \x52\xA3\x53\x54\x01\x02\x03\x04 I2 arg1] $arg1 1216} {1 {1386435412 16909060}} 1217test binary-30.7 {Tcl_BinaryObjCmd: scan} { 1218 unset -nocomplain arg1 1219 set arg1 foo 1220 list [binary scan \x52 I1 arg1] $arg1 1221} {0 foo} 1222test binary-30.8 {Tcl_BinaryObjCmd: scan} -setup { 1223 unset -nocomplain arg1 1224} -returnCodes error -body { 1225 set arg1 1 1226 binary scan \x52\x53\x53\x54 I1 arg1(a) 1227} -result {can't set "arg1(a)": variable isn't array} 1228test binary-30.9 {Tcl_BinaryObjCmd: scan} { 1229 unset -nocomplain arg1 arg2 1230 set arg1 foo 1231 set arg2 bar 1232 list [binary scan \x52\xA3\x53\x54\x01\x02\x03\x04\x05 I2c* arg1 arg2] $arg1 $arg2 1233} {2 {1386435412 16909060} 5} 1234test binary-30.10 {Tcl_BinaryObjCmd: scan} { 1235 unset -nocomplain arg1 arg2 1236 list [binary scan \xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF IuI arg1 arg2] $arg1 $arg2 1237} {2 4294967295 -1} 1238test binary-30.11 {Tcl_BinaryObjCmd: scan} { 1239 unset -nocomplain arg1 arg2 1240 list [binary scan \xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF IIu arg1 arg2] $arg1 $arg2 1241} {2 -1 4294967295} 1242test binary-30.12 {Tcl_BinaryObjCmd: scan} { 1243 unset -nocomplain arg1 arg2 1244 list [binary scan \x80\x00\x00\x00\x00\x00\x00\x80 IuIu arg1 arg2] $arg1 $arg2 1245} {2 2147483648 128} 1246 1247test binary-31.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body { 1248 binary scan abc f 1249} -result {not enough arguments for all format specifiers} 1250test binary-31.2 {Tcl_BinaryObjCmd: scan} bigEndian { 1251 unset -nocomplain arg1 1252 list [binary scan \x3F\xCC\xCC\xCD\x40\x59\x99\x9A f* arg1] $arg1 1253} {1 {1.600000023841858 3.4000000953674316}} 1254test binary-31.3 {Tcl_BinaryObjCmd: scan} littleEndian { 1255 unset -nocomplain arg1 1256 list [binary scan \xCD\xCC\xCC\x3F\x9A\x99\x59\x40 f* arg1] $arg1 1257} {1 {1.600000023841858 3.4000000953674316}} 1258test binary-31.4 {Tcl_BinaryObjCmd: scan} bigEndian { 1259 unset -nocomplain arg1 1260 list [binary scan \x3F\xCC\xCC\xCD\x40\x59\x99\x9A f arg1] $arg1 1261} {1 1.600000023841858} 1262test binary-31.5 {Tcl_BinaryObjCmd: scan} littleEndian { 1263 unset -nocomplain arg1 1264 list [binary scan \xCD\xCC\xCC\x3F\x9A\x99\x59\x40 f arg1] $arg1 1265} {1 1.600000023841858} 1266test binary-31.6 {Tcl_BinaryObjCmd: scan} bigEndian { 1267 unset -nocomplain arg1 1268 list [binary scan \x3F\xCC\xCC\xCD f1 arg1] $arg1 1269} {1 1.600000023841858} 1270test binary-31.7 {Tcl_BinaryObjCmd: scan} littleEndian { 1271 unset -nocomplain arg1 1272 list [binary scan \xCD\xCC\xCC\x3F f1 arg1] $arg1 1273} {1 1.600000023841858} 1274test binary-31.8 {Tcl_BinaryObjCmd: scan} bigEndian { 1275 unset -nocomplain arg1 1276 list [binary scan \x3F\xCC\xCC\xCD f0 arg1] $arg1 1277} {1 {}} 1278test binary-31.9 {Tcl_BinaryObjCmd: scan} littleEndian { 1279 unset -nocomplain arg1 1280 list [binary scan \xCD\xCC\xCC\x3F f0 arg1] $arg1 1281} {1 {}} 1282test binary-31.10 {Tcl_BinaryObjCmd: scan} bigEndian { 1283 unset -nocomplain arg1 1284 list [binary scan \x3F\xCC\xCC\xCD\x40\x59\x99\x9A f2 arg1] $arg1 1285} {1 {1.600000023841858 3.4000000953674316}} 1286test binary-31.11 {Tcl_BinaryObjCmd: scan} littleEndian { 1287 unset -nocomplain arg1 1288 list [binary scan \xCD\xCC\xCC\x3F\x9A\x99\x59\x40 f2 arg1] $arg1 1289} {1 {1.600000023841858 3.4000000953674316}} 1290test binary-31.12 {Tcl_BinaryObjCmd: scan} { 1291 unset -nocomplain arg1 1292 set arg1 foo 1293 list [binary scan \x52 f1 arg1] $arg1 1294} {0 foo} 1295test binary-31.13 {Tcl_BinaryObjCmd: scan} -setup { 1296 unset -nocomplain arg1 1297} -returnCodes error -body { 1298 set arg1 1 1299 binary scan \x3F\xCC\xCC\xCD f1 arg1(a) 1300} -result {can't set "arg1(a)": variable isn't array} 1301test binary-31.14 {Tcl_BinaryObjCmd: scan} bigEndian { 1302 unset -nocomplain arg1 arg2 1303 set arg1 foo 1304 set arg2 bar 1305 list [binary scan \x3F\xCC\xCC\xCD\x40\x59\x99\x9A\x05 f2c* arg1 arg2] $arg1 $arg2 1306} {2 {1.600000023841858 3.4000000953674316} 5} 1307test binary-31.15 {Tcl_BinaryObjCmd: scan} littleEndian { 1308 unset -nocomplain arg1 arg2 1309 set arg1 foo 1310 set arg2 bar 1311 list [binary scan \xCD\xCC\xCC\x3F\x9A\x99\x59\x40\x05 f2c* arg1 arg2] $arg1 $arg2 1312} {2 {1.600000023841858 3.4000000953674316} 5} 1313 1314test binary-32.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body { 1315 binary scan abc d 1316} -result {not enough arguments for all format specifiers} 1317test binary-32.2 {Tcl_BinaryObjCmd: scan} bigEndian { 1318 unset -nocomplain arg1 1319 list [binary scan \x3F\xF9\x99\x99\x99\x99\x99\x9A\x40\x0B\x33\x33\x33\x33\x33\x33 d* arg1] $arg1 1320} {1 {1.6 3.4}} 1321test binary-32.3 {Tcl_BinaryObjCmd: scan} littleEndian { 1322 unset -nocomplain arg1 1323 list [binary scan \x9A\x99\x99\x99\x99\x99\xF9\x3F\x33\x33\x33\x33\x33\x33\x0B\x40 d* arg1] $arg1 1324} {1 {1.6 3.4}} 1325test binary-32.4 {Tcl_BinaryObjCmd: scan} bigEndian { 1326 unset -nocomplain arg1 1327 list [binary scan \x3F\xF9\x99\x99\x99\x99\x99\x9A\x40\x0B\x33\x33\x33\x33\x33\x33 d arg1] $arg1 1328} {1 1.6} 1329test binary-32.5 {Tcl_BinaryObjCmd: scan} littleEndian { 1330 unset -nocomplain arg1 1331 list [binary scan \x9A\x99\x99\x99\x99\x99\xF9\x3F\x33\x33\x33\x33\x33\x33\x0B\x40 d arg1] $arg1 1332} {1 1.6} 1333test binary-32.6 {Tcl_BinaryObjCmd: scan} bigEndian { 1334 unset -nocomplain arg1 1335 list [binary scan \x3F\xF9\x99\x99\x99\x99\x99\x9A d1 arg1] $arg1 1336} {1 1.6} 1337test binary-32.7 {Tcl_BinaryObjCmd: scan} littleEndian { 1338 unset -nocomplain arg1 1339 list [binary scan \x9A\x99\x99\x99\x99\x99\xF9\x3F d1 arg1] $arg1 1340} {1 1.6} 1341test binary-32.8 {Tcl_BinaryObjCmd: scan} bigEndian { 1342 unset -nocomplain arg1 1343 list [binary scan \x3F\xF9\x99\x99\x99\x99\x99\x9A d0 arg1] $arg1 1344} {1 {}} 1345test binary-32.9 {Tcl_BinaryObjCmd: scan} littleEndian { 1346 unset -nocomplain arg1 1347 list [binary scan \x9A\x99\x99\x99\x99\x99\xF9\x3F d0 arg1] $arg1 1348} {1 {}} 1349test binary-32.10 {Tcl_BinaryObjCmd: scan} bigEndian { 1350 unset -nocomplain arg1 1351 list [binary scan \x3F\xF9\x99\x99\x99\x99\x99\x9A\x40\x0B\x33\x33\x33\x33\x33\x33 d2 arg1] $arg1 1352} {1 {1.6 3.4}} 1353test binary-32.11 {Tcl_BinaryObjCmd: scan} littleEndian { 1354 unset -nocomplain arg1 1355 list [binary scan \x9A\x99\x99\x99\x99\x99\xF9\x3F\x33\x33\x33\x33\x33\x33\x0B\x40 d2 arg1] $arg1 1356} {1 {1.6 3.4}} 1357test binary-32.12 {Tcl_BinaryObjCmd: scan} { 1358 unset -nocomplain arg1 1359 set arg1 foo 1360 list [binary scan \x52 d1 arg1] $arg1 1361} {0 foo} 1362test binary-32.13 {Tcl_BinaryObjCmd: scan} -setup { 1363 unset -nocomplain arg1 1364} -returnCodes error -body { 1365 set arg1 1 1366 binary scan \x3F\xF9\x99\x99\x99\x99\x99\x9A d1 arg1(a) 1367} -result {can't set "arg1(a)": variable isn't array} 1368test binary-32.14 {Tcl_BinaryObjCmd: scan} bigEndian { 1369 unset -nocomplain arg1 arg2 1370 set arg1 foo 1371 set arg2 bar 1372 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 1373} {2 {1.6 3.4} 5} 1374test binary-32.15 {Tcl_BinaryObjCmd: scan} littleEndian { 1375 unset -nocomplain arg1 arg2 1376 set arg1 foo 1377 set arg2 bar 1378 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 1379} {2 {1.6 3.4} 5} 1380 1381test binary-33.1 {Tcl_BinaryObjCmd: scan} { 1382 unset -nocomplain arg1 1383 unset -nocomplain arg2 1384 list [binary scan abcdefg a2xa3 arg1 arg2] $arg1 $arg2 1385} {2 ab def} 1386test binary-33.2 {Tcl_BinaryObjCmd: scan} { 1387 unset -nocomplain arg1 1388 unset -nocomplain arg2 1389 set arg2 foo 1390 list [binary scan abcdefg a3x*a3 arg1 arg2] $arg1 $arg2 1391} {1 abc foo} 1392test binary-33.3 {Tcl_BinaryObjCmd: scan} { 1393 unset -nocomplain arg1 1394 unset -nocomplain arg2 1395 set arg2 foo 1396 list [binary scan abcdefg a3x20a3 arg1 arg2] $arg1 $arg2 1397} {1 abc foo} 1398test binary-33.4 {Tcl_BinaryObjCmd: scan} { 1399 unset -nocomplain arg1 1400 unset -nocomplain arg2 1401 set arg2 foo 1402 list [binary scan abc a3x20a3 arg1 arg2] $arg1 $arg2 1403} {1 abc foo} 1404test binary-33.5 {Tcl_BinaryObjCmd: scan} { 1405 unset -nocomplain arg1 1406 list [binary scan abcdef x1a1 arg1] $arg1 1407} {1 b} 1408test binary-33.6 {Tcl_BinaryObjCmd: scan} { 1409 unset -nocomplain arg1 1410 list [binary scan abcdef x5a1 arg1] $arg1 1411} {1 f} 1412test binary-33.7 {Tcl_BinaryObjCmd: scan} { 1413 unset -nocomplain arg1 1414 list [binary scan abcdef x0a1 arg1] $arg1 1415} {1 a} 1416 1417test binary-34.1 {Tcl_BinaryObjCmd: scan} { 1418 unset -nocomplain arg1 1419 unset -nocomplain arg2 1420 list [binary scan abcdefg a2Xa3 arg1 arg2] $arg1 $arg2 1421} {2 ab bcd} 1422test binary-34.2 {Tcl_BinaryObjCmd: scan} { 1423 unset -nocomplain arg1 1424 unset -nocomplain arg2 1425 set arg2 foo 1426 list [binary scan abcdefg a3X*a3 arg1 arg2] $arg1 $arg2 1427} {2 abc abc} 1428test binary-34.3 {Tcl_BinaryObjCmd: scan} { 1429 unset -nocomplain arg1 1430 unset -nocomplain arg2 1431 set arg2 foo 1432 list [binary scan abcdefg a3X20a3 arg1 arg2] $arg1 $arg2 1433} {2 abc abc} 1434test binary-34.4 {Tcl_BinaryObjCmd: scan} { 1435 unset -nocomplain arg1 1436 list [binary scan abc X20a3 arg1] $arg1 1437} {1 abc} 1438test binary-34.5 {Tcl_BinaryObjCmd: scan} { 1439 unset -nocomplain arg1 1440 list [binary scan abcdef x*X1a1 arg1] $arg1 1441} {1 f} 1442test binary-34.6 {Tcl_BinaryObjCmd: scan} { 1443 unset -nocomplain arg1 1444 list [binary scan abcdef x*X5a1 arg1] $arg1 1445} {1 b} 1446test binary-34.7 {Tcl_BinaryObjCmd: scan} { 1447 unset -nocomplain arg1 1448 list [binary scan abcdef x3X0a1 arg1] $arg1 1449} {1 d} 1450 1451test binary-35.1 {Tcl_BinaryObjCmd: scan} -setup { 1452 unset -nocomplain arg1 1453 unset -nocomplain arg2 1454} -returnCodes error -body { 1455 binary scan abcdefg a2@a3 arg1 arg2 1456} -result {missing count for "@" field specifier} 1457test binary-35.2 {Tcl_BinaryObjCmd: scan} { 1458 unset -nocomplain arg1 1459 unset -nocomplain arg2 1460 set arg2 foo 1461 list [binary scan abcdefg a3@*a3 arg1 arg2] $arg1 $arg2 1462} {1 abc foo} 1463test binary-35.3 {Tcl_BinaryObjCmd: scan} { 1464 unset -nocomplain arg1 1465 unset -nocomplain arg2 1466 set arg2 foo 1467 list [binary scan abcdefg a3@20a3 arg1 arg2] $arg1 $arg2 1468} {1 abc foo} 1469test binary-35.4 {Tcl_BinaryObjCmd: scan} { 1470 unset -nocomplain arg1 1471 list [binary scan abcdef @2a3 arg1] $arg1 1472} {1 cde} 1473test binary-35.5 {Tcl_BinaryObjCmd: scan} { 1474 unset -nocomplain arg1 1475 list [binary scan abcdef x*@1a1 arg1] $arg1 1476} {1 b} 1477test binary-35.6 {Tcl_BinaryObjCmd: scan} { 1478 unset -nocomplain arg1 1479 list [binary scan abcdef x*@0a1 arg1] $arg1 1480} {1 a} 1481 1482test binary-36.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body { 1483 binary scan abcdef u0a3 1484} -result {bad field specifier "u"} 1485 1486# GetFormatSpec is pretty thoroughly tested above, but there are a few cases 1487# we should text explicitly 1488 1489test binary-37.1 {GetFormatSpec: whitespace} { 1490 binary format "a3 a5 a3" foo barblat baz 1491} foobarblbaz 1492test binary-37.2 {GetFormatSpec: whitespace} { 1493 binary format " " foo 1494} {} 1495test binary-37.3 {GetFormatSpec: whitespace} { 1496 binary format " a3" foo 1497} foo 1498test binary-37.4 {GetFormatSpec: whitespace} { 1499 binary format "" foo 1500} {} 1501test binary-37.5 {GetFormatSpec: whitespace} { 1502 binary format "" foo 1503} {} 1504test binary-37.6 {GetFormatSpec: whitespace} { 1505 binary format " a3 " foo 1506} foo 1507test binary-37.7 {GetFormatSpec: numbers} -returnCodes error -body { 1508 binary scan abcdef "x-1" foo 1509} -result {bad field specifier "-"} 1510test binary-37.8 {GetFormatSpec: numbers} { 1511 unset -nocomplain arg1 1512 set arg1 foo 1513 list [binary scan abcdef "a0x3" arg1] $arg1 1514} {1 {}} 1515test binary-37.9 {GetFormatSpec: numbers} { 1516 # test format of neg numbers 1517 # bug report/fix provided by Harald Kirsch 1518 set x [binary format f* {1 -1 2 -2 0}] 1519 binary scan $x f* bla 1520 set bla 1521} {1.0 -1.0 2.0 -2.0 0.0} 1522test binary-37.10 {GetFormatSpec: count overflow} { 1523 binary scan x a[format %ld 0x7fffffff] r 1524} 0 1525test binary-37.11 {GetFormatSpec: count overflow} { 1526 binary scan x a[format %ld 0x10000000] r 1527} 0 1528test binary-37.12 {GetFormatSpec: count overflow} { 1529 binary scan x a[format %ld 0x100000000] r 1530} 0 1531test binary-37.13 {GetFormatSpec: count overflow} { 1532 binary scan x a[format %lld 0x10000000000000000] r 1533} 0 1534 1535test binary-38.1 {FormatNumber: word alignment} { 1536 set x [binary format c1s1 1 1] 1537} \x01\x01\x00 1538test binary-38.2 {FormatNumber: word alignment} { 1539 set x [binary format c1S1 1 1] 1540} \x01\x00\x01 1541test binary-38.3 {FormatNumber: word alignment} { 1542 set x [binary format c1i1 1 1] 1543} \x01\x01\x00\x00\x00 1544test binary-38.4 {FormatNumber: word alignment} { 1545 set x [binary format c1I1 1 1] 1546} \x01\x00\x00\x00\x01 1547test binary-38.5 {FormatNumber: word alignment} bigEndian { 1548 set x [binary format c1d1 1 1.6] 1549} \x01\x3F\xF9\x99\x99\x99\x99\x99\x9A 1550test binary-38.6 {FormatNumber: word alignment} littleEndian { 1551 set x [binary format c1d1 1 1.6] 1552} \x01\x9A\x99\x99\x99\x99\x99\xF9\x3F 1553test binary-38.7 {FormatNumber: word alignment} bigEndian { 1554 set x [binary format c1f1 1 1.6] 1555} \x01\x3F\xCC\xCC\xCD 1556test binary-38.8 {FormatNumber: word alignment} littleEndian { 1557 set x [binary format c1f1 1 1.6] 1558} \x01\xCD\xCC\xCC\x3F 1559 1560test binary-39.1 {ScanNumber: sign extension} { 1561 unset -nocomplain arg1 1562 list [binary scan \x52\xA3 c2 arg1] $arg1 1563} {1 {82 -93}} 1564test binary-39.2 {ScanNumber: sign extension} { 1565 unset -nocomplain arg1 1566 list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 s4 arg1] $arg1 1567} {1 {513 -32511 386 -32127}} 1568test binary-39.3 {ScanNumber: sign extension} { 1569 unset -nocomplain arg1 1570 list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 S4 arg1] $arg1 1571} {1 {258 385 -32255 -32382}} 1572test binary-39.4 {ScanNumber: sign extension} { 1573 unset -nocomplain arg1 1574 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 1575} {1 {33620225 16843137 16876033 25297153 -2130640639}} 1576test binary-39.5 {ScanNumber: sign extension} { 1577 unset -nocomplain arg1 1578 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 1579} {1 {16843010 -2130640639 25297153 16876033 16843137}} 1580test binary-39.6 {ScanNumber: no sign extension} { 1581 unset -nocomplain arg1 1582 list [binary scan \x52\xA3 cu2 arg1] $arg1 1583} {1 {82 163}} 1584test binary-39.7 {ScanNumber: no sign extension} { 1585 unset -nocomplain arg1 1586 list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 su4 arg1] $arg1 1587} {1 {513 33025 386 33409}} 1588test binary-39.8 {ScanNumber: no sign extension} { 1589 unset -nocomplain arg1 1590 list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 Su4 arg1] $arg1 1591} {1 {258 385 33281 33154}} 1592test binary-39.9 {ScanNumber: no sign extension} { 1593 unset -nocomplain arg1 1594 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 1595} {1 {33620225 16843137 16876033 25297153 2164326657}} 1596test binary-39.10 {ScanNumber: no sign extension} { 1597 unset -nocomplain arg1 1598 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 1599} {1 {16843010 2164326657 25297153 16876033 16843137}} 1600 1601test binary-40.3 {ScanNumber: NaN} -body { 1602 unset -nocomplain arg1 1603 list [binary scan \xFF\xFF\xFF\xFF f1 arg1] $arg1 1604} -match glob -result {1 -NaN*} 1605test binary-40.4 {ScanNumber: NaN} -body { 1606 unset -nocomplain arg1 1607 list [binary scan \xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF d arg1] $arg1 1608} -match glob -result {1 -NaN*} 1609 1610test binary-41.1 {ScanNumber: word alignment} -setup { 1611 unset -nocomplain arg1 arg2 1612} -body { 1613 list [binary scan \x01\x01\x00 c1s1 arg1 arg2] $arg1 $arg2 1614} -result {2 1 1} 1615test binary-41.2 {ScanNumber: word alignment} -setup { 1616 unset -nocomplain arg1 arg2 1617} -body { 1618 list [binary scan \x01\x00\x01 c1S1 arg1 arg2] $arg1 $arg2 1619} -result {2 1 1} 1620test binary-41.3 {ScanNumber: word alignment} -setup { 1621 unset -nocomplain arg1 arg2 1622} -body { 1623 list [binary scan \x01\x01\x00\x00\x00 c1i1 arg1 arg2] $arg1 $arg2 1624} -result {2 1 1} 1625test binary-41.4 {ScanNumber: word alignment} -setup { 1626 unset -nocomplain arg1 arg2 1627} -body { 1628 list [binary scan \x01\x00\x00\x00\x01 c1I1 arg1 arg2] $arg1 $arg2 1629} -result {2 1 1} 1630test binary-41.5 {ScanNumber: word alignment} -setup { 1631 unset -nocomplain arg1 arg2 1632} -constraints bigEndian -body { 1633 list [binary scan \x01\x3F\xCC\xCC\xCD c1f1 arg1 arg2] $arg1 $arg2 1634} -result {2 1 1.600000023841858} 1635test binary-41.6 {ScanNumber: word alignment} -setup { 1636 unset -nocomplain arg1 arg2 1637} -constraints littleEndian -body { 1638 list [binary scan \x01\xCD\xCC\xCC\x3F c1f1 arg1 arg2] $arg1 $arg2 1639} -result {2 1 1.600000023841858} 1640test binary-41.7 {ScanNumber: word alignment} -setup { 1641 unset -nocomplain arg1 arg2 1642} -constraints bigEndian -body { 1643 list [binary scan \x01\x3F\xF9\x99\x99\x99\x99\x99\x9A c1d1 arg1 arg2] $arg1 $arg2 1644} -result {2 1 1.6} 1645test binary-41.8 {ScanNumber: word alignment} -setup { 1646 unset -nocomplain arg1 arg2 1647} -constraints littleEndian -body { 1648 list [binary scan \x01\x9A\x99\x99\x99\x99\x99\xF9\x3F c1d1 arg1 arg2] $arg1 $arg2 1649} -result {2 1 1.6} 1650 1651test binary-42.1 {Tcl_BinaryObjCmd: bad arguments} -constraints {} -body { 1652 binary ? 1653} -returnCodes error -match glob -result {unknown or ambiguous subcommand "?": *} 1654 1655# Wide int (guaranteed at least 64-bit) handling 1656test binary-43.1 {Tcl_BinaryObjCmd: format wide int} {} { 1657 binary format w 7810179016327718216 1658} HelloTcl 1659test binary-43.2 {Tcl_BinaryObjCmd: format wide int} {} { 1660 binary format W 7810179016327718216 1661} lcTolleH 1662 1663test binary-43.5 {Tcl_BinaryObjCmd: scan wide int} {} { 1664 unset -nocomplain arg1 1665 list [binary scan \x80[string repeat \x00 7] W arg1] $arg1 1666} {1 -9223372036854775808} 1667test binary-43.6 {Tcl_BinaryObjCmd: scan unsigned wide int} {} { 1668 unset -nocomplain arg1 1669 list [binary scan \x80[string repeat \x00 7] Wu arg1] $arg1 1670} {1 9223372036854775808} 1671test binary-43.7 {Tcl_BinaryObjCmd: scan unsigned wide int} {} { 1672 unset -nocomplain arg1 1673 list [binary scan [string repeat \x00 7]\x80 wu arg1] $arg1 1674} {1 9223372036854775808} 1675test binary-43.8 {Tcl_BinaryObjCmd: scan unsigned wide int} {} { 1676 unset -nocomplain arg1 arg2 1677 list [binary scan \x80[string repeat \x00 7]\x80[string repeat \x00 7] WuW arg1 arg2] $arg1 $arg2 1678} {2 9223372036854775808 -9223372036854775808} 1679test binary-43.9 {Tcl_BinaryObjCmd: scan unsigned wide int} {} { 1680 unset -nocomplain arg1 arg2 1681 list [binary scan [string repeat \x00 7]\x80[string repeat \x00 7]\x80 wuw arg1 arg2] $arg1 $arg2 1682} {2 9223372036854775808 -9223372036854775808} 1683 1684test binary-44.1 {Tcl_BinaryObjCmd: scan wide int} {} { 1685 binary scan HelloTcl W x 1686 set x 1687} 5216694956358656876 1688test binary-44.2 {Tcl_BinaryObjCmd: scan wide int} {} { 1689 binary scan lcTolleH w x 1690 set x 1691} 5216694956358656876 1692test binary-44.3 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} {} { 1693 binary scan [binary format w [expr {wide(3) << 31}]] w x 1694 set x 1695} 6442450944 1696test binary-44.4 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} {} { 1697 binary scan [binary format W [expr {wide(3) << 31}]] W x 1698 set x 1699} 6442450944 1700test binary-44.5 {Tcl_BinaryObjCmd: scan wide int with bit 31 and 64 set} {} { 1701 binary scan [binary format w [expr {(wide(3) << 31) + (wide(3) << 64)}]] w x 1702 set x 1703} 6442450944 1704test binary-44.6 {Tcl_BinaryObjCmd: scan wide int with bit 31 and 64 set} {} { 1705 binary scan [binary format W [expr {(wide(3) << 31) + (wide(3) << 64)}]] W x 1706 set x 1707} 6442450944 1708 1709test binary-45.1 {Tcl_BinaryObjCmd: combined wide int handling} { 1710 binary scan [binary format sws 16450 -1 19521] c* x 1711 set x 1712} {66 64 -1 -1 -1 -1 -1 -1 -1 -1 65 76} 1713test binary-45.2 {Tcl_BinaryObjCmd: combined wide int handling} { 1714 binary scan [binary format sWs 16450 0x7fffffff 19521] c* x 1715 set x 1716} {66 64 0 0 0 0 127 -1 -1 -1 65 76} 1717 1718test binary-46.1 {Tcl_BinaryObjCmd: handling of non-ISO8859-1 chars} { 1719 binary format a* € 1720} \xAC 1721test binary-46.2 {Tcl_BinaryObjCmd: handling of non-ISO8859-1 chars} { 1722 list [binary scan [binary format a* €₽] s x] $x 1723} {1 -16980} 1724test binary-46.3 {Tcl_BinaryObjCmd: handling of non-ISO8859-1 chars} { 1725 set x {} 1726 set y {} 1727 set z {} 1728 list [binary scan [binary format a* €₽] aaa x y z] $x $y $z 1729} "2 \xAC \xBD {}" 1730test binary-46.4 {Tcl_BinaryObjCmd: handling of non-ISO8859-1 chars} { 1731 set x [encoding convertto iso8859-15 €] 1732 set y [binary format a* $x] 1733 list $x $y 1734} "\xA4 \xA4" 1735test binary-46.5 {Tcl_BinaryObjCmd: handling of non-ISO8859-1 chars} { 1736 set x [binary scan \xA4 a* y] 1737 list $x $y [encoding convertfrom iso8859-15 $y] 1738} "1 \xA4 €" 1739 1740test binary-47.1 {Tcl_BinaryObjCmd: number cache reference count handling} { 1741 # This test is only reliable when memory debugging is turned on, but 1742 # without even memory debugging it should still generate the expected 1743 # answers and might therefore still pick up memory corruption caused by 1744 # [Bug 851747]. 1745 list [binary scan aba ccc x x x] $x 1746} {3 97} 1747 1748### TIP#129: endian specifiers ---- 1749 1750# format t 1751test binary-48.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 1752 binary format t 1753} -result {not enough arguments for all format specifiers} 1754test binary-48.2 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 1755 binary format t blat 1756} -result {expected integer but got "blat"} 1757test binary-48.3 {Tcl_BinaryObjCmd: format} { 1758 binary format S0 0x50 1759} {} 1760test binary-48.4 {Tcl_BinaryObjCmd: format} bigEndian { 1761 binary format t 0x50 1762} \x00P 1763test binary-48.5 {Tcl_BinaryObjCmd: format} littleEndian { 1764 binary format t 0x50 1765} P\x00 1766test binary-48.6 {Tcl_BinaryObjCmd: format} bigEndian { 1767 binary format t 0x5052 1768} PR 1769test binary-48.7 {Tcl_BinaryObjCmd: format} littleEndian { 1770 binary format t 0x5052 1771} RP 1772test binary-48.8 {Tcl_BinaryObjCmd: format} bigEndian { 1773 binary format t 0x505251 0x53 1774} RQ 1775test binary-48.9 {Tcl_BinaryObjCmd: format} littleEndian { 1776 binary format t 0x505251 0x53 1777} QR 1778test binary-48.10 {Tcl_BinaryObjCmd: format} bigEndian { 1779 binary format t2 {0x50 0x52} 1780} \x00P\x00R 1781test binary-48.11 {Tcl_BinaryObjCmd: format} littleEndian { 1782 binary format t2 {0x50 0x52} 1783} P\x00R\x00 1784test binary-48.12 {Tcl_BinaryObjCmd: format} bigEndian { 1785 binary format t* {0x5051 0x52} 1786} PQ\x00R 1787test binary-48.13 {Tcl_BinaryObjCmd: format} littleEndian { 1788 binary format t* {0x5051 0x52} 1789} QPR\x00 1790test binary-48.14 {Tcl_BinaryObjCmd: format} bigEndian { 1791 binary format t2 {0x50 0x52 0x53} 0x54 1792} \x00P\x00R 1793test binary-48.15 {Tcl_BinaryObjCmd: format} littleEndian { 1794 binary format t2 {0x50 0x52 0x53} 0x54 1795} P\x00R\x00 1796test binary-48.16 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 1797 binary format t2 {0x50} 1798} -result {number of elements in list does not match count} 1799test binary-48.17 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 1800 set a {0x50 0x51} 1801 binary format t $a 1802} -result "expected integer but got \"0x50 0x51\"" 1803test binary-48.18 {Tcl_BinaryObjCmd: format} bigEndian { 1804 set a {0x50 0x51} 1805 binary format t1 $a 1806} \x00P 1807test binary-48.19 {Tcl_BinaryObjCmd: format} littleEndian { 1808 set a {0x50 0x51} 1809 binary format t1 $a 1810} P\x00 1811 1812# format n 1813test binary-49.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 1814 binary format n 1815} -result {not enough arguments for all format specifiers} 1816test binary-49.2 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 1817 binary format n blat 1818} -result {expected integer but got "blat"} 1819test binary-49.3 {Tcl_BinaryObjCmd: format} { 1820 binary format n0 0x50 1821} {} 1822test binary-49.4 {Tcl_BinaryObjCmd: format} littleEndian { 1823 binary format n 0x50 1824} P\x00\x00\x00 1825test binary-49.5 {Tcl_BinaryObjCmd: format} littleEndian { 1826 binary format n 0x5052 1827} RP\x00\x00 1828test binary-49.6 {Tcl_BinaryObjCmd: format} littleEndian { 1829 binary format n 0x505251 0x53 1830} QRP\x00 1831test binary-49.7 {Tcl_BinaryObjCmd: format} littleEndian { 1832 binary format i1 {0x505251 0x53} 1833} QRP\x00 1834test binary-49.8 {Tcl_BinaryObjCmd: format} littleEndian { 1835 binary format n 0x53525150 1836} PQRS 1837test binary-49.9 {Tcl_BinaryObjCmd: format} littleEndian { 1838 binary format n2 {0x50 0x52} 1839} P\x00\x00\x00R\x00\x00\x00 1840test binary-49.10 {Tcl_BinaryObjCmd: format} littleEndian { 1841 binary format n* {0x50515253 0x52} 1842} SRQPR\x00\x00\x00 1843test binary-49.11 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 1844 binary format n2 {0x50} 1845} -result {number of elements in list does not match count} 1846test binary-49.12 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 1847 set a {0x50 0x51} 1848 binary format n $a 1849} -result "expected integer but got \"0x50 0x51\"" 1850test binary-49.13 {Tcl_BinaryObjCmd: format} littleEndian { 1851 set a {0x50 0x51} 1852 binary format n1 $a 1853} P\x00\x00\x00 1854test binary-49.14 {Tcl_BinaryObjCmd: format} bigEndian { 1855 binary format n 0x50 1856} \x00\x00\x00P 1857test binary-49.15 {Tcl_BinaryObjCmd: format} bigEndian { 1858 binary format n 0x5052 1859} \x00\x00PR 1860test binary-49.16 {Tcl_BinaryObjCmd: format} bigEndian { 1861 binary format n 0x505251 0x53 1862} \x00PRQ 1863test binary-49.17 {Tcl_BinaryObjCmd: format} bigEndian { 1864 binary format i1 {0x505251 0x53} 1865} QRP\x00 1866test binary-49.18 {Tcl_BinaryObjCmd: format} bigEndian { 1867 binary format n 0x53525150 1868} SRQP 1869test binary-49.19 {Tcl_BinaryObjCmd: format} bigEndian { 1870 binary format n2 {0x50 0x52} 1871} \x00\x00\x00P\x00\x00\x00R 1872test binary-49.20 {Tcl_BinaryObjCmd: format} bigEndian { 1873 binary format n* {0x50515253 0x52} 1874} PQRS\x00\x00\x00R 1875 1876# format m 1877test binary-50.1 {Tcl_BinaryObjCmd: format wide int} littleEndian { 1878 binary format m 7810179016327718216 1879} HelloTcl 1880test binary-50.2 {Tcl_BinaryObjCmd: format wide int} bigEndian { 1881 binary format m 7810179016327718216 1882} lcTolleH 1883test binary-50.3 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} littleEndian { 1884 binary scan [binary format m [expr {wide(3) << 31}]] w x 1885 set x 1886} 6442450944 1887test binary-50.4 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} bigEndian { 1888 binary scan [binary format m [expr {wide(3) << 31}]] W x 1889 set x 1890} 6442450944 1891 1892# format Q/q 1893test binary-51.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 1894 binary format Q 1895} -result {not enough arguments for all format specifiers} 1896test binary-51.2 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 1897 binary format q blat 1898} -result {expected floating-point number but got "blat"} 1899test binary-51.3 {Tcl_BinaryObjCmd: format} { 1900 binary format q0 1.6 1901} {} 1902test binary-51.4 {Tcl_BinaryObjCmd: format} {} { 1903 binary format Q 1.6 1904} \x3F\xF9\x99\x99\x99\x99\x99\x9A 1905test binary-51.5 {Tcl_BinaryObjCmd: format} {} { 1906 binary format q 1.6 1907} \x9A\x99\x99\x99\x99\x99\xF9\x3F 1908test binary-51.6 {Tcl_BinaryObjCmd: format} {} { 1909 binary format Q* {1.6 3.4} 1910} \x3F\xF9\x99\x99\x99\x99\x99\x9A\x40\x0B\x33\x33\x33\x33\x33\x33 1911test binary-51.7 {Tcl_BinaryObjCmd: format} {} { 1912 binary format q* {1.6 3.4} 1913} \x9A\x99\x99\x99\x99\x99\xF9\x3F\x33\x33\x33\x33\x33\x33\x0B\x40 1914test binary-51.8 {Tcl_BinaryObjCmd: format} {} { 1915 binary format Q2 {1.6 3.4} 1916} \x3F\xF9\x99\x99\x99\x99\x99\x9A\x40\x0B\x33\x33\x33\x33\x33\x33 1917test binary-51.9 {Tcl_BinaryObjCmd: format} {} { 1918 binary format q2 {1.6 3.4} 1919} \x9A\x99\x99\x99\x99\x99\xF9\x3F\x33\x33\x33\x33\x33\x33\x0B\x40 1920test binary-51.10 {Tcl_BinaryObjCmd: format} {} { 1921 binary format Q2 {1.6 3.4 5.6} 1922} \x3F\xF9\x99\x99\x99\x99\x99\x9A\x40\x0B\x33\x33\x33\x33\x33\x33 1923test binary-51.11 {Tcl_BinaryObjCmd: format} {} { 1924 binary format q2 {1.6 3.4 5.6} 1925} \x9A\x99\x99\x99\x99\x99\xF9\x3F\x33\x33\x33\x33\x33\x33\x0B\x40 1926test binary-51.14 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 1927 binary format q2 {1.6} 1928} -result {number of elements in list does not match count} 1929test binary-51.15 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 1930 set a {1.6 3.4} 1931 binary format q $a 1932} -result "expected floating-point number but got \"1.6 3.4\"" 1933test binary-51.16 {Tcl_BinaryObjCmd: format} {} { 1934 set a {1.6 3.4} 1935 binary format Q1 $a 1936} \x3F\xF9\x99\x99\x99\x99\x99\x9A 1937test binary-51.17 {Tcl_BinaryObjCmd: format} {} { 1938 set a {1.6 3.4} 1939 binary format q1 $a 1940} \x9A\x99\x99\x99\x99\x99\xF9\x3F 1941 1942# format R/r 1943test binary-53.1 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 1944 binary format r 1945} -result {not enough arguments for all format specifiers} 1946test binary-53.2 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 1947 binary format r blat 1948} -result {expected floating-point number but got "blat"} 1949test binary-53.3 {Tcl_BinaryObjCmd: format} { 1950 binary format f0 1.6 1951} {} 1952test binary-53.4 {Tcl_BinaryObjCmd: format} {} { 1953 binary format R 1.6 1954} \x3F\xCC\xCC\xCD 1955test binary-53.5 {Tcl_BinaryObjCmd: format} {} { 1956 binary format r 1.6 1957} \xCD\xCC\xCC\x3F 1958test binary-53.6 {Tcl_BinaryObjCmd: format} {} { 1959 binary format R* {1.6 3.4} 1960} \x3F\xCC\xCC\xCD\x40\x59\x99\x9A 1961test binary-53.7 {Tcl_BinaryObjCmd: format} {} { 1962 binary format r* {1.6 3.4} 1963} \xCD\xCC\xCC\x3F\x9A\x99\x59\x40 1964test binary-53.8 {Tcl_BinaryObjCmd: format} {} { 1965 binary format R2 {1.6 3.4} 1966} \x3F\xCC\xCC\xCD\x40\x59\x99\x9A 1967test binary-53.9 {Tcl_BinaryObjCmd: format} {} { 1968 binary format r2 {1.6 3.4} 1969} \xCD\xCC\xCC\x3F\x9A\x99\x59\x40 1970test binary-53.10 {Tcl_BinaryObjCmd: format} {} { 1971 binary format R2 {1.6 3.4 5.6} 1972} \x3F\xCC\xCC\xCD\x40\x59\x99\x9A 1973test binary-53.11 {Tcl_BinaryObjCmd: format} {} { 1974 binary format r2 {1.6 3.4 5.6} 1975} \xCD\xCC\xCC\x3F\x9A\x99\x59\x40 1976test binary-53.12 {Tcl_BinaryObjCmd: float overflow} {} { 1977 binary format R -3.402825e+38 1978} \xFF\x7F\xFF\xFF 1979test binary-53.13 {Tcl_BinaryObjCmd: float overflow} {} { 1980 binary format r -3.402825e+38 1981} \xFF\xFF\x7F\xFF 1982test binary-53.14 {Tcl_BinaryObjCmd: float underflow} {} { 1983 binary format R -3.402825e-100 1984} \x80\x00\x00\x00 1985test binary-53.15 {Tcl_BinaryObjCmd: float underflow} {} { 1986 binary format r -3.402825e-100 1987} \x00\x00\x00\x80 1988test binary-53.16 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 1989 binary format r2 {1.6} 1990} -result {number of elements in list does not match count} 1991test binary-53.17 {Tcl_BinaryObjCmd: format} -returnCodes error -body { 1992 set a {1.6 3.4} 1993 binary format r $a 1994} -result "expected floating-point number but got \"1.6 3.4\"" 1995test binary-53.18 {Tcl_BinaryObjCmd: format} {} { 1996 set a {1.6 3.4} 1997 binary format R1 $a 1998} \x3F\xCC\xCC\xCD 1999test binary-53.19 {Tcl_BinaryObjCmd: format} {} { 2000 set a {1.6 3.4} 2001 binary format r1 $a 2002} \xCD\xCC\xCC\x3F 2003 2004# scan t (s) 2005test binary-54.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body { 2006 binary scan abc t 2007} -result {not enough arguments for all format specifiers} 2008test binary-54.2 {Tcl_BinaryObjCmd: scan} littleEndian { 2009 unset -nocomplain arg1 2010 list [binary scan \x52\xA3\x53\x54 t* arg1] $arg1 2011} {1 {-23726 21587}} 2012test binary-54.3 {Tcl_BinaryObjCmd: scan} littleEndian { 2013 unset -nocomplain arg1 2014 list [binary scan \x52\xA3\x53\x54 t arg1] $arg1 2015} {1 -23726} 2016test binary-54.4 {Tcl_BinaryObjCmd: scan} littleEndian { 2017 unset -nocomplain arg1 2018 list [binary scan \x52\xA3 t1 arg1] $arg1 2019} {1 -23726} 2020test binary-54.5 {Tcl_BinaryObjCmd: scan} littleEndian { 2021 unset -nocomplain arg1 2022 list [binary scan \x52\xA3 t0 arg1] $arg1 2023} {1 {}} 2024test binary-54.6 {Tcl_BinaryObjCmd: scan} littleEndian { 2025 unset -nocomplain arg1 2026 list [binary scan \x52\xA3\x53\x54 t2 arg1] $arg1 2027} {1 {-23726 21587}} 2028test binary-54.7 {Tcl_BinaryObjCmd: scan} littleEndian { 2029 unset -nocomplain arg1 2030 set arg1 foo 2031 list [binary scan \x52 t1 arg1] $arg1 2032} {0 foo} 2033test binary-54.8 {Tcl_BinaryObjCmd: scan} -setup { 2034 unset -nocomplain arg1 2035} -returnCodes error -body { 2036 set arg1 1 2037 binary scan \x52\x53 t1 arg1(a) 2038} -result {can't set "arg1(a)": variable isn't array} 2039test binary-54.9 {Tcl_BinaryObjCmd: scan} littleEndian { 2040 unset -nocomplain arg1 arg2 2041 set arg1 foo 2042 set arg2 bar 2043 list [binary scan \x52\xA3\x53\x54\x05 t2c* arg1 arg2] $arg1 $arg2 2044} {2 {-23726 21587} 5} 2045test binary-54.10 {Tcl_BinaryObjCmd: scan} littleEndian { 2046 unset -nocomplain arg1 arg2 2047 set arg1 foo 2048 set arg2 bar 2049 list [binary scan \x00\x80\x00\x80 tut arg1 arg2] $arg1 $arg2 2050} {2 32768 -32768} 2051test binary-54.11 {Tcl_BinaryObjCmd: scan} littleEndian { 2052 unset -nocomplain arg1 arg2 2053 set arg1 foo 2054 set arg2 bar 2055 list [binary scan \x00\x80\x00\x80 ttu arg1 arg2] $arg1 $arg2 2056} {2 -32768 32768} 2057 2058# scan t (b) 2059test binary-55.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body { 2060 binary scan abc t 2061} -result {not enough arguments for all format specifiers} 2062test binary-55.2 {Tcl_BinaryObjCmd: scan} bigEndian { 2063 unset -nocomplain arg1 2064 list [binary scan \x52\xA3\x53\x54 t* arg1] $arg1 2065} {1 {21155 21332}} 2066test binary-55.3 {Tcl_BinaryObjCmd: scan} bigEndian { 2067 unset -nocomplain arg1 2068 list [binary scan \x52\xA3\x53\x54 t arg1] $arg1 2069} {1 21155} 2070test binary-55.4 {Tcl_BinaryObjCmd: scan} bigEndian { 2071 unset -nocomplain arg1 2072 list [binary scan \x52\xA3 t1 arg1] $arg1 2073} {1 21155} 2074test binary-55.5 {Tcl_BinaryObjCmd: scan} bigEndian { 2075 unset -nocomplain arg1 2076 list [binary scan \x52\xA3 t0 arg1] $arg1 2077} {1 {}} 2078test binary-55.6 {Tcl_BinaryObjCmd: scan} bigEndian { 2079 unset -nocomplain arg1 2080 list [binary scan \x52\xA3\x53\x54 t2 arg1] $arg1 2081} {1 {21155 21332}} 2082test binary-55.7 {Tcl_BinaryObjCmd: scan} bigEndian { 2083 unset -nocomplain arg1 2084 set arg1 foo 2085 list [binary scan \x52 t1 arg1] $arg1 2086} {0 foo} 2087test binary-55.8 {Tcl_BinaryObjCmd: scan} -setup { 2088 unset -nocomplain arg1 2089} -returnCodes error -body { 2090 set arg1 1 2091 binary scan \x52\x53 t1 arg1(a) 2092} -result {can't set "arg1(a)": variable isn't array} 2093test binary-55.9 {Tcl_BinaryObjCmd: scan} bigEndian { 2094 unset -nocomplain arg1 arg2 2095 set arg1 foo 2096 set arg2 bar 2097 list [binary scan \x52\xA3\x53\x54\x05 t2c* arg1 arg2] $arg1 $arg2 2098} {2 {21155 21332} 5} 2099test binary-55.10 {Tcl_BinaryObjCmd: scan} bigEndian { 2100 unset -nocomplain arg1 arg2 2101 set arg1 foo 2102 set arg2 bar 2103 list [binary scan \x80\x00\x80\x00 tut arg1 arg2] $arg1 $arg2 2104} {2 32768 -32768} 2105test binary-55.11 {Tcl_BinaryObjCmd: scan} bigEndian { 2106 unset -nocomplain arg1 arg2 2107 set arg1 foo 2108 set arg2 bar 2109 list [binary scan \x80\x00\x80\x00 ttu arg1 arg2] $arg1 $arg2 2110} {2 -32768 32768} 2111 2112# scan n (s) 2113test binary-56.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body { 2114 binary scan abc n 2115} -result {not enough arguments for all format specifiers} 2116test binary-56.2 {Tcl_BinaryObjCmd: scan} littleEndian { 2117 unset -nocomplain arg1 2118 list [binary scan \x52\xA3\x53\x54\x01\x02\x03\x04 n* arg1] $arg1 2119} {1 {1414767442 67305985}} 2120test binary-56.3 {Tcl_BinaryObjCmd: scan} littleEndian { 2121 unset -nocomplain arg1 2122 list [binary scan \x52\xA3\x53\x54\x01\x02\x03\x04 n arg1] $arg1 2123} {1 1414767442} 2124test binary-56.4 {Tcl_BinaryObjCmd: scan} littleEndian { 2125 unset -nocomplain arg1 2126 list [binary scan \x52\xA3\x53\x54 n1 arg1] $arg1 2127} {1 1414767442} 2128test binary-56.5 {Tcl_BinaryObjCmd: scan} littleEndian { 2129 unset -nocomplain arg1 2130 list [binary scan \x52\xA3\x53 n0 arg1] $arg1 2131} {1 {}} 2132test binary-56.6 {Tcl_BinaryObjCmd: scan} littleEndian { 2133 unset -nocomplain arg1 2134 list [binary scan \x52\xA3\x53\x54\x01\x02\x03\x04 n2 arg1] $arg1 2135} {1 {1414767442 67305985}} 2136test binary-56.7 {Tcl_BinaryObjCmd: scan} littleEndian { 2137 unset -nocomplain arg1 2138 set arg1 foo 2139 list [binary scan \x52 n1 arg1] $arg1 2140} {0 foo} 2141test binary-56.8 {Tcl_BinaryObjCmd: scan} -setup { 2142 unset -nocomplain arg1 2143} -returnCodes error -body { 2144 set arg1 1 2145 binary scan \x52\x53\x53\x54 n1 arg1(a) 2146} -result {can't set "arg1(a)": variable isn't array} 2147test binary-56.9 {Tcl_BinaryObjCmd: scan} littleEndian { 2148 unset -nocomplain arg1 arg2 2149 set arg1 foo 2150 set arg2 bar 2151 list [binary scan \x52\xA3\x53\x54\x01\x02\x03\x04\x05 n2c* arg1 arg2] $arg1 $arg2 2152} {2 {1414767442 67305985} 5} 2153test binary-56.10 {Tcl_BinaryObjCmd: scan} littleEndian { 2154 unset -nocomplain arg1 arg2 2155 set arg1 foo 2156 set arg2 bar 2157 list [binary scan \x80\x00\x00\x00\x80\x00\x00\x00 nun arg1 arg2] $arg1 $arg2 2158} {2 128 128} 2159test binary-56.11 {Tcl_BinaryObjCmd: scan} littleEndian { 2160 unset -nocomplain arg1 arg2 2161 set arg1 foo 2162 set arg2 bar 2163 list [binary scan \x00\x00\x00\x80\x00\x00\x00\x80 nun arg1 arg2] $arg1 $arg2 2164} {2 2147483648 -2147483648} 2165 2166# scan n (b) 2167test binary-57.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body { 2168 binary scan abc n 2169} -result {not enough arguments for all format specifiers} 2170test binary-57.2 {Tcl_BinaryObjCmd: scan} bigEndian { 2171 unset -nocomplain arg1 2172 list [binary scan \x52\xA3\x53\x54\x01\x02\x03\x04 n* arg1] $arg1 2173} {1 {1386435412 16909060}} 2174test binary-57.3 {Tcl_BinaryObjCmd: scan} bigEndian { 2175 unset -nocomplain arg1 2176 list [binary scan \x52\xA3\x53\x54\x01\x02\x03\x04 n arg1] $arg1 2177} {1 1386435412} 2178test binary-57.4 {Tcl_BinaryObjCmd: scan} bigEndian { 2179 unset -nocomplain arg1 2180 list [binary scan \x52\xA3\x53\x54 n1 arg1] $arg1 2181} {1 1386435412} 2182test binary-57.5 {Tcl_BinaryObjCmd: scan} bigEndian { 2183 unset -nocomplain arg1 2184 list [binary scan \x52\xA3\x53 n0 arg1] $arg1 2185} {1 {}} 2186test binary-57.6 {Tcl_BinaryObjCmd: scan} bigEndian { 2187 unset -nocomplain arg1 2188 list [binary scan \x52\xA3\x53\x54\x01\x02\x03\x04 n2 arg1] $arg1 2189} {1 {1386435412 16909060}} 2190test binary-57.7 {Tcl_BinaryObjCmd: scan} bigEndian { 2191 unset -nocomplain arg1 2192 set arg1 foo 2193 list [binary scan \x52 n1 arg1] $arg1 2194} {0 foo} 2195test binary-57.8 {Tcl_BinaryObjCmd: scan} -setup { 2196 unset -nocomplain arg1 2197} -returnCodes error -body { 2198 set arg1 1 2199 binary scan \x52\x53\x53\x54 n1 arg1(a) 2200} -result {can't set "arg1(a)": variable isn't array} 2201test binary-57.9 {Tcl_BinaryObjCmd: scan} bigEndian { 2202 unset -nocomplain arg1 arg2 2203 set arg1 foo 2204 set arg2 bar 2205 list [binary scan \x52\xA3\x53\x54\x01\x02\x03\x04\x05 n2c* arg1 arg2] $arg1 $arg2 2206} {2 {1386435412 16909060} 5} 2207test binary-57.10 {Tcl_BinaryObjCmd: scan} bigEndian { 2208 unset -nocomplain arg1 arg2 2209 set arg1 foo 2210 set arg2 bar 2211 list [binary scan \x80\x00\x00\x00\x80\x00\x00\x00 nun arg1 arg2] $arg1 $arg2 2212} {2 2147483648 -2147483648} 2213test binary-57.11 {Tcl_BinaryObjCmd: scan} bigEndian { 2214 unset -nocomplain arg1 arg2 2215 set arg1 foo 2216 set arg2 bar 2217 list [binary scan \x00\x00\x00\x80\x00\x00\x00\x80 nun arg1 arg2] $arg1 $arg2 2218} {2 128 128} 2219 2220# scan Q/q 2221test binary-58.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body { 2222 binary scan abc q 2223} -result {not enough arguments for all format specifiers} 2224test binary-58.2 {Tcl_BinaryObjCmd: scan} bigEndian { 2225 unset -nocomplain arg1 2226 list [binary scan \x3F\xF9\x99\x99\x99\x99\x99\x9A\x40\x0B\x33\x33\x33\x33\x33\x33 Q* arg1] $arg1 2227} {1 {1.6 3.4}} 2228test binary-58.3 {Tcl_BinaryObjCmd: scan} littleEndian { 2229 unset -nocomplain arg1 2230 list [binary scan \x9A\x99\x99\x99\x99\x99\xF9\x3F\x33\x33\x33\x33\x33\x33\x0B\x40 q* arg1] $arg1 2231} {1 {1.6 3.4}} 2232test binary-58.4 {Tcl_BinaryObjCmd: scan} bigEndian { 2233 unset -nocomplain arg1 2234 list [binary scan \x3F\xF9\x99\x99\x99\x99\x99\x9A\x40\x0B\x33\x33\x33\x33\x33\x33 Q arg1] $arg1 2235} {1 1.6} 2236test binary-58.5 {Tcl_BinaryObjCmd: scan} littleEndian { 2237 unset -nocomplain arg1 2238 list [binary scan \x9A\x99\x99\x99\x99\x99\xF9\x3F\x33\x33\x33\x33\x33\x33\x0B\x40 q arg1] $arg1 2239} {1 1.6} 2240test binary-58.6 {Tcl_BinaryObjCmd: scan} bigEndian { 2241 unset -nocomplain arg1 2242 list [binary scan \x3F\xF9\x99\x99\x99\x99\x99\x9A Q1 arg1] $arg1 2243} {1 1.6} 2244test binary-58.7 {Tcl_BinaryObjCmd: scan} littleEndian { 2245 unset -nocomplain arg1 2246 list [binary scan \x9A\x99\x99\x99\x99\x99\xF9\x3F q1 arg1] $arg1 2247} {1 1.6} 2248test binary-58.8 {Tcl_BinaryObjCmd: scan} bigEndian { 2249 unset -nocomplain arg1 2250 list [binary scan \x3F\xF9\x99\x99\x99\x99\x99\x9A Q0 arg1] $arg1 2251} {1 {}} 2252test binary-58.9 {Tcl_BinaryObjCmd: scan} littleEndian { 2253 unset -nocomplain arg1 2254 list [binary scan \x9A\x99\x99\x99\x99\x99\xF9\x3F q0 arg1] $arg1 2255} {1 {}} 2256test binary-58.10 {Tcl_BinaryObjCmd: scan} bigEndian { 2257 unset -nocomplain arg1 2258 list [binary scan \x3F\xF9\x99\x99\x99\x99\x99\x9A\x40\x0B\x33\x33\x33\x33\x33\x33 Q2 arg1] $arg1 2259} {1 {1.6 3.4}} 2260test binary-58.11 {Tcl_BinaryObjCmd: scan} littleEndian { 2261 unset -nocomplain arg1 2262 list [binary scan \x9A\x99\x99\x99\x99\x99\xF9\x3F\x33\x33\x33\x33\x33\x33\x0B\x40 q2 arg1] $arg1 2263} {1 {1.6 3.4}} 2264test binary-58.12 {Tcl_BinaryObjCmd: scan} { 2265 unset -nocomplain arg1 2266 set arg1 foo 2267 list [binary scan \x52 q1 arg1] $arg1 2268} {0 foo} 2269test binary-58.13 {Tcl_BinaryObjCmd: scan} -setup { 2270 unset -nocomplain arg1 2271} -returnCodes error -body { 2272 set arg1 1 2273 binary scan \x3F\xF9\x99\x99\x99\x99\x99\x9A q1 arg1(a) 2274} -result {can't set "arg1(a)": variable isn't array} 2275test binary-58.14 {Tcl_BinaryObjCmd: scan} bigEndian { 2276 unset -nocomplain arg1 arg2 2277 set arg1 foo 2278 set arg2 bar 2279 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 2280} {2 {1.6 3.4} 5} 2281test binary-58.15 {Tcl_BinaryObjCmd: scan} littleEndian { 2282 unset -nocomplain arg1 arg2 2283 set arg1 foo 2284 set arg2 bar 2285 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 2286} {2 {1.6 3.4} 5} 2287 2288# scan R/r 2289test binary-59.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body { 2290 binary scan abc r 2291} -result {not enough arguments for all format specifiers} 2292test binary-59.2 {Tcl_BinaryObjCmd: scan} bigEndian { 2293 unset -nocomplain arg1 2294 list [binary scan \x3F\xCC\xCC\xCD\x40\x59\x99\x9A R* arg1] $arg1 2295} {1 {1.600000023841858 3.4000000953674316}} 2296test binary-59.3 {Tcl_BinaryObjCmd: scan} littleEndian { 2297 unset -nocomplain arg1 2298 list [binary scan \xCD\xCC\xCC\x3F\x9A\x99\x59\x40 r* arg1] $arg1 2299} {1 {1.600000023841858 3.4000000953674316}} 2300test binary-59.4 {Tcl_BinaryObjCmd: scan} bigEndian { 2301 unset -nocomplain arg1 2302 list [binary scan \x3F\xCC\xCC\xCD\x40\x59\x99\x9A R arg1] $arg1 2303} {1 1.600000023841858} 2304test binary-59.5 {Tcl_BinaryObjCmd: scan} littleEndian { 2305 unset -nocomplain arg1 2306 list [binary scan \xCD\xCC\xCC\x3F\x9A\x99\x59\x40 r arg1] $arg1 2307} {1 1.600000023841858} 2308test binary-59.6 {Tcl_BinaryObjCmd: scan} bigEndian { 2309 unset -nocomplain arg1 2310 list [binary scan \x3F\xCC\xCC\xCD R1 arg1] $arg1 2311} {1 1.600000023841858} 2312test binary-59.7 {Tcl_BinaryObjCmd: scan} littleEndian { 2313 unset -nocomplain arg1 2314 list [binary scan \xCD\xCC\xCC\x3F r1 arg1] $arg1 2315} {1 1.600000023841858} 2316test binary-59.8 {Tcl_BinaryObjCmd: scan} bigEndian { 2317 unset -nocomplain arg1 2318 list [binary scan \x3F\xCC\xCC\xCD R0 arg1] $arg1 2319} {1 {}} 2320test binary-59.9 {Tcl_BinaryObjCmd: scan} littleEndian { 2321 unset -nocomplain arg1 2322 list [binary scan \xCD\xCC\xCC\x3F r0 arg1] $arg1 2323} {1 {}} 2324test binary-59.10 {Tcl_BinaryObjCmd: scan} bigEndian { 2325 unset -nocomplain arg1 2326 list [binary scan \x3F\xCC\xCC\xCD\x40\x59\x99\x9A R2 arg1] $arg1 2327} {1 {1.600000023841858 3.4000000953674316}} 2328test binary-59.11 {Tcl_BinaryObjCmd: scan} littleEndian { 2329 unset -nocomplain arg1 2330 list [binary scan \xCD\xCC\xCC\x3F\x9A\x99\x59\x40 r2 arg1] $arg1 2331} {1 {1.600000023841858 3.4000000953674316}} 2332test binary-59.12 {Tcl_BinaryObjCmd: scan} { 2333 unset -nocomplain arg1 2334 set arg1 foo 2335 list [binary scan \x52 r1 arg1] $arg1 2336} {0 foo} 2337test binary-59.13 {Tcl_BinaryObjCmd: scan} -setup { 2338 unset -nocomplain arg1 2339} -returnCodes error -body { 2340 set arg1 1 2341 binary scan \x3F\xCC\xCC\xCD r1 arg1(a) 2342} -result {can't set "arg1(a)": variable isn't array} 2343test binary-59.14 {Tcl_BinaryObjCmd: scan} bigEndian { 2344 unset -nocomplain arg1 arg2 2345 set arg1 foo 2346 set arg2 bar 2347 list [binary scan \x3F\xCC\xCC\xCD\x40\x59\x99\x9A\x05 R2c* arg1 arg2] $arg1 $arg2 2348} {2 {1.600000023841858 3.4000000953674316} 5} 2349test binary-59.15 {Tcl_BinaryObjCmd: scan} littleEndian { 2350 unset -nocomplain arg1 arg2 2351 set arg1 foo 2352 set arg2 bar 2353 list [binary scan \xCD\xCC\xCC\x3F\x9A\x99\x59\x40\x05 r2c* arg1 arg2] $arg1 $arg2 2354} {2 {1.600000023841858 3.4000000953674316} 5} 2355 2356test binary-60.1 {[binary format] with NaN} -body { 2357 binary scan [binary format dqQfrR NaN NaN NaN NaN NaN NaN] dqQfrR \ 2358 v1 v2 v3 v4 v5 v6 2359 list $v1 $v2 $v3 $v4 $v5 $v6 2360} -match regexp -result {NaN(\([[:xdigit:]]+\))? NaN(\([[:xdigit:]]+\))? NaN(\([[:xdigit:]]+\))? NaN(\([[:xdigit:]]+\))? NaN(\([[:xdigit:]]+\))? NaN(\([[:xdigit:]]+\))?} 2361 2362# scan m 2363test binary-61.1 {Tcl_BinaryObjCmd: scan wide int} bigEndian { 2364 binary scan HelloTcl m x 2365 set x 2366} 5216694956358656876 2367test binary-61.2 {Tcl_BinaryObjCmd: scan wide int} littleEndian { 2368 binary scan lcTolleH m x 2369 set x 2370} 5216694956358656876 2371test binary-61.3 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} littleEndian { 2372 binary scan [binary format w [expr {wide(3) << 31}]] m x 2373 set x 2374} 6442450944 2375test binary-61.4 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} bigEndian { 2376 binary scan [binary format W [expr {wide(3) << 31}]] m x 2377 set x 2378} 6442450944 2379 2380# scan/format infinities 2381 2382test binary-62.1 {infinity} ieeeFloatingPoint { 2383 binary scan [binary format q Infinity] w w 2384 format 0x%016lx $w 2385} 0x7ff0000000000000 2386test binary-62.2 {infinity} ieeeFloatingPoint { 2387 binary scan [binary format q -Infinity] w w 2388 format 0x%016lx $w 2389} 0xfff0000000000000 2390test binary-62.3 {infinity} ieeeFloatingPoint { 2391 binary scan [binary format q Inf] w w 2392 format 0x%016lx $w 2393} 0x7ff0000000000000 2394test binary-62.4 {infinity} ieeeFloatingPoint { 2395 binary scan [binary format q -Infinity] w w 2396 format 0x%016lx $w 2397} 0xfff0000000000000 2398test binary-62.5 {infinity} ieeeFloatingPoint { 2399 binary scan [binary format w 0x7ff0000000000000] q d 2400 set d 2401} Inf 2402test binary-62.6 {infinity} ieeeFloatingPoint { 2403 binary scan [binary format w 0xfff0000000000000] q d 2404 set d 2405} -Inf 2406 2407# scan/format Not-a-Number 2408 2409test binary-63.1 {NaN} ieeeFloatingPoint { 2410 binary scan [binary format q NaN] w w 2411 format 0x%016lx [expr {$w & 0xfff3ffffffffffff}] 2412} 0x7ff0000000000000 2413test binary-63.2 {NaN} ieeeFloatingPoint { 2414 binary scan [binary format q -NaN] w w 2415 format 0x%016lx [expr {$w & 0xfff3ffffffffffff}] 2416} 0xfff0000000000000 2417test binary-63.3 {NaN} ieeeFloatingPoint { 2418 binary scan [binary format q NaN(3123456789aBc)] w w 2419 format 0x%016lx [expr {$w & 0xfff3ffffffffffff}] 2420} 0x7ff3123456789abc 2421test binary-63.4 {NaN} ieeeFloatingPoint { 2422 binary scan [binary format q {NaN( 3123456789aBc)}] w w 2423 format 0x%016lx [expr {$w & 0xfff3ffffffffffff}] 2424} 0x7ff3123456789abc 2425 2426# Make sure TclParseNumber() rejects invalid nan-hex formats [Bug 3402540] 2427test binary-63.5 {NaN} -constraints ieeeFloatingPoint -body { 2428 binary format q Nan( 2429} -returnCodes error -match glob -result {expected floating-point number*} 2430test binary-63.6 {NaN} -constraints ieeeFloatingPoint -body { 2431 binary format q Nan() 2432} -returnCodes error -match glob -result {expected floating-point number*} 2433test binary-63.7 {NaN} -constraints ieeeFloatingPoint -body { 2434 binary format q Nan(g) 2435} -returnCodes error -match glob -result {expected floating-point number*} 2436test binary-63.8 {NaN} -constraints ieeeFloatingPoint -body { 2437 binary format q Nan(1,2) 2438} -returnCodes error -match glob -result {expected floating-point number*} 2439test binary-63.9 {NaN} -constraints ieeeFloatingPoint -body { 2440 binary format q Nan(1234567890abcd) 2441} -returnCodes error -match glob -result {expected floating-point number*} 2442 2443test binary-64.1 {NaN} -constraints ieeeFloatingPoint -body { 2444 binary scan [binary format w 0x7ff8000000000000] q d 2445 set d 2446} -match glob -result NaN* 2447test binary-64.2 {NaN} -constraints ieeeFloatingPoint -body { 2448 binary scan [binary format w 0x7ff0123456789aBc] q d 2449 set d 2450} -match glob -result NaN(*123456789abc) 2451 2452test binary-65.1 {largest significand} ieeeFloatingPoint { 2453 binary scan [binary format w 0x3fcfffffffffffff] q d 2454 set d 2455} 0.24999999999999997 2456test binary-65.2 {smallest significand} ieeeFloatingPoint { 2457 binary scan [binary format w 0x3fd0000000000000] q d 2458 set d 2459} 0.25 2460test binary-65.3 {largest significand} ieeeFloatingPoint { 2461 binary scan [binary format w 0x3fdfffffffffffff] q d 2462 set d 2463} 0.49999999999999994 2464test binary-65.4 {smallest significand} ieeeFloatingPoint { 2465 binary scan [binary format w 0x3fe0000000000000] q d 2466 set d 2467} 0.5 2468test binary-65.5 {largest significand} ieeeFloatingPoint { 2469 binary scan [binary format w 0x3fffffffffffffff] q d 2470 set d 2471} 1.9999999999999998 2472test binary-65.6 {smallest significand} ieeeFloatingPoint { 2473 binary scan [binary format w 0x4000000000000000] q d 2474 set d 2475} 2.0 2476test binary-65.7 {smallest significand} ieeeFloatingPoint { 2477 binary scan [binary format w 0x434fffffffffffff] q d 2478 set d 2479} 18014398509481982.0 2480test binary-65.8 {largest significand} ieeeFloatingPoint { 2481 binary scan [binary format w 0x4350000000000000] q d 2482 set d 2483} 18014398509481984.0 2484test binary-65.9 {largest significand} ieeeFloatingPoint { 2485 binary scan [binary format w 0x4350000000000001] q d 2486 set d 2487} 18014398509481988.0 2488 2489test binary-70.1 {binary encode hex} -body { 2490 binary encode hex 2491} -returnCodes error -match glob -result "wrong # args: *" 2492test binary-70.2 {binary encode hex} -body { 2493 binary encode hex a 2494} -result {61} 2495test binary-70.3 {binary encode hex} -body { 2496 binary encode hex {} 2497} -result {} 2498test binary-70.4 {binary encode hex} -body { 2499 binary encode hex [string repeat a 20] 2500} -result [string repeat 61 20] 2501test binary-70.5 {binary encode hex} -body { 2502 binary encode hex \x00\x01\x02\x03\x04\x00\x01\x02\x03\x04 2503} -result {00010203040001020304} 2504 2505test binary-71.1 {binary decode hex} -body { 2506 binary decode hex 2507} -returnCodes error -match glob -result "wrong # args: *" 2508test binary-71.2 {binary decode hex} -body { 2509 binary decode hex 61 2510} -result {a} 2511test binary-71.3 {binary decode hex} -body { 2512 binary decode hex {} 2513} -result {} 2514test binary-71.4 {binary decode hex} -body { 2515 binary decode hex [string repeat 61 20] 2516} -result [string repeat a 20] 2517test binary-71.5 {binary decode hex} -body { 2518 binary decode hex 00010203040001020304 2519} -result "\x00\x01\x02\x03\x04\x00\x01\x02\x03\x04" 2520test binary-71.6 {binary decode hex} -body { 2521 binary decode hex "61 61" 2522} -result {aa} 2523test binary-71.7 {binary decode hex} -body { 2524 binary decode hex "61\n\n\n61" 2525} -result {aa} 2526test binary-71.8 {binary decode hex} -match glob -body { 2527 binary decode hex -strict "61 61" 2528} -returnCodes error -result {invalid hexadecimal digit " " * at position 2} 2529test binary-71.9 {binary decode hex} -body { 2530 set r [binary decode hex "6"] 2531 list [string length $r] $r 2532} -result {0 {}} 2533test binary-71.10 {binary decode hex} -body { 2534 string length [binary decode hex " "] 2535} -result 0 2536test binary-71.11 {binary decode hex: Bug b98fa55285} -body { 2537 apply {{} { 2538 set str "137b6f95e7519389e7c4b36599781e2ccf492699649249aae43fbe8c26\n" 2539 set decoded [binary decode hex $str] 2540 list [string length $decoded] [scan [string index $decoded end] %c] 2541 }} 2542} -result {29 38} 2543test binary-71.12 {binary decode hex: Bug b98fa55285 cross check} -body { 2544 apply {{} { 2545 set str "137b6f95e7519389e7c4b36599781e2ccf492699649249aae43fbe8c2\n" 2546 set decoded [binary decode hex $str] 2547 list [string length $decoded] [scan [string index $decoded end] %c] 2548 }} 2549} -result {28 140} 2550test binary-71.13 {binary decode hex: Bug b98fa55285 cross check} -body { 2551 apply {{} { 2552 set str "137b6f95e7519389e7c4b36599781e2ccf492699649249aae43fbe8c2\n\n" 2553 set decoded [binary decode hex $str] 2554 list [string length $decoded] [scan [string index $decoded end] %c] 2555 }} 2556} -result {28 140} 2557test binary-71.14 {binary decode hex: Bug b98fa55285 cross check} -body { 2558 apply {{} { 2559 set str "137b6f95e7519389e7c4b36599781e2ccf492699649249aae43fbe8c2\n\n\n" 2560 set decoded [binary decode hex $str] 2561 list [string length $decoded] [scan [string index $decoded end] %c] 2562 }} 2563} -result {28 140} 2564 2565test binary-72.1 {binary encode base64} -body { 2566 binary encode base64 2567} -returnCodes error -match glob -result "wrong # args: *" 2568test binary-72.2 {binary encode base64} -body { 2569 binary encode base64 abc 2570} -result {YWJj} 2571test binary-72.3 {binary encode base64} -body { 2572 binary encode base64 {} 2573} -result {} 2574test binary-72.4 {binary encode base64} -body { 2575 binary encode base64 [string repeat abc 20] 2576} -result [string repeat YWJj 20] 2577test binary-72.5 {binary encode base64} -body { 2578 binary encode base64 \x00\x01\x02\x03\x04\x00\x01\x02\x03 2579} -result {AAECAwQAAQID} 2580test binary-72.6 {binary encode base64} -body { 2581 binary encode base64 \x00 2582} -result {AA==} 2583test binary-72.7 {binary encode base64} -body { 2584 binary encode base64 \x00\x00 2585} -result {AAA=} 2586test binary-72.8 {binary encode base64} -body { 2587 binary encode base64 \x00\x00\x00 2588} -result {AAAA} 2589test binary-72.9 {binary encode base64} -body { 2590 binary encode base64 \x00\x00\x00\x00 2591} -result {AAAAAA==} 2592test binary-72.10 {binary encode base64} -body { 2593 binary encode base64 -maxlen 0 -wrapchar : abcabcabc 2594} -result {YWJjYWJjYWJj} 2595test binary-72.11 {binary encode base64} -body { 2596 binary encode base64 -maxlen 1 -wrapchar : abcabcabc 2597} -result {Y:W:J:j:Y:W:J:j:Y:W:J:j} 2598test binary-72.12 {binary encode base64} -body { 2599 binary encode base64 -maxlen 2 -wrapchar : abcabcabc 2600} -result {YW:Jj:YW:Jj:YW:Jj} 2601test binary-72.13 {binary encode base64} -body { 2602 binary encode base64 -maxlen 3 -wrapchar : abcabcabc 2603} -result {YWJ:jYW:JjY:WJj} 2604test binary-72.14 {binary encode base64} -body { 2605 binary encode base64 -maxlen 4 -wrapchar : abcabcabc 2606} -result {YWJj:YWJj:YWJj} 2607test binary-72.15 {binary encode base64} -body { 2608 binary encode base64 -maxlen 5 -wrapchar : abcabcabc 2609} -result {YWJjY:WJjYW:Jj} 2610test binary-72.16 {binary encode base64} -body { 2611 binary encode base64 -maxlen 6 -wrapchar : abcabcabc 2612} -result {YWJjYW:JjYWJj} 2613test binary-72.17 {binary encode base64} -body { 2614 binary encode base64 -maxlen 7 -wrapchar : abcabcabc 2615} -result {YWJjYWJ:jYWJj} 2616test binary-72.18 {binary encode base64} -body { 2617 binary encode base64 -maxlen 8 -wrapchar : abcabcabc 2618} -result {YWJjYWJj:YWJj} 2619test binary-72.19 {binary encode base64} -body { 2620 binary encode base64 -maxlen 9 -wrapchar : abcabcabc 2621} -result {YWJjYWJjY:WJj} 2622test binary-72.20 {binary encode base64} -body { 2623 binary encode base64 -maxlen 10 -wrapchar : abcabcabc 2624} -result {YWJjYWJjYW:Jj} 2625test binary-72.21 {binary encode base64} -body { 2626 binary encode base64 -maxlen 11 -wrapchar : abcabcabc 2627} -result {YWJjYWJjYWJ:j} 2628test binary-72.22 {binary encode base64} -body { 2629 binary encode base64 -maxlen 12 -wrapchar : abcabcabc 2630} -result {YWJjYWJjYWJj} 2631test binary-72.23 {binary encode base64} -body { 2632 binary encode base64 -maxlen 13 -wrapchar : abcabcabc 2633} -result {YWJjYWJjYWJj} 2634test binary-72.24 {binary encode base64} -body { 2635 binary encode base64 -maxlen 60 -wrapchar : abcabcabc 2636} -result {YWJjYWJjYWJj} 2637test binary-72.25 {binary encode base64} -body { 2638 binary encode base64 -maxlen 2 -wrapchar * abcabcabc 2639} -result {YW*Jj*YW*Jj*YW*Jj} 2640test binary-72.26 {binary encode base64} -body { 2641 binary encode base64 -maxlen 6 -wrapchar -*- abcabcabc 2642} -result {YWJjYW-*-JjYWJj} 2643test binary-72.27 {binary encode base64} -body { 2644 binary encode base64 -maxlen 4 -wrapchar -*- abcabcabc 2645} -result {YWJj-*-YWJj-*-YWJj} 2646test binary-72.28 {binary encode base64} -body { 2647 binary encode base64 -maxlen 6 -wrapchar 0123456789 abcabcabc 2648} -result {YWJjYW0123456789JjYWJj} 2649test binary-72.29 {binary encode base64} { 2650 string length [binary encode base64 -maxlen 3 -wrapchar \xCA abc] 2651} 5 2652 2653test binary-73.1 {binary decode base64} -body { 2654 binary decode base64 2655} -returnCodes error -match glob -result "wrong # args: *" 2656test binary-73.2 {binary decode base64} -body { 2657 binary decode base64 YWJj 2658} -result {abc} 2659test binary-73.3 {binary decode base64} -body { 2660 binary decode base64 {} 2661} -result {} 2662test binary-73.4 {binary decode base64} -body { 2663 binary decode base64 [string repeat YWJj 20] 2664} -result [string repeat abc 20] 2665test binary-73.5 {binary decode base64} -body { 2666 binary decode base64 AAECAwQAAQID 2667} -result "\x00\x01\x02\x03\x04\x00\x01\x02\x03" 2668test binary-73.6 {binary decode base64} -body { 2669 binary decode base64 AA== 2670} -result "\x00" 2671test binary-73.7 {binary decode base64} -body { 2672 binary decode base64 AAA= 2673} -result "\x00\x00" 2674test binary-73.8 {binary decode base64} -body { 2675 binary decode base64 AAAA 2676} -result "\x00\x00\x00" 2677test binary-73.9 {binary decode base64} -body { 2678 binary decode base64 AAAAAA== 2679} -result "\x00\x00\x00\x00" 2680test binary-73.10 {binary decode base64} -body { 2681 set s "[string repeat YWJj 10]\n[string repeat YWJj 10]" 2682 binary decode base64 $s 2683} -result [string repeat abc 20] 2684test binary-73.11 {binary decode base64} -body { 2685 set s "[string repeat YWJj 10]\n [string repeat YWJj 10]" 2686 binary decode base64 $s 2687} -result [string repeat abc 20] 2688test binary-73.12 {binary decode base64} -body { 2689 binary decode base64 -strict ":YWJj" 2690} -returnCodes error -match glob -result {invalid base64 character ":" * at position 0} 2691test binary-73.13 {binary decode base64} -body { 2692 set s "[string repeat YWJj 10]:[string repeat YWJj 10]" 2693 binary decode base64 -strict $s 2694} -returnCodes error -match glob -result {invalid base64 character ":" * at position 40} 2695test binary-73.14 {binary decode base64} -body { 2696 set s "[string repeat YWJj 10]\n [string repeat YWJj 10]" 2697 binary decode base64 -strict $s 2698} -returnCodes error -match glob -result {invalid base64 character *} 2699test binary-73.20 {binary decode base64} -body { 2700 set r [binary decode base64 Y] 2701 list [string length $r] $r 2702} -result {0 {}} 2703test binary-73.21 {binary decode base64} -body { 2704 set r [binary decode base64 YW] 2705 list [string length $r] $r 2706} -result {1 a} 2707test binary-73.22 {binary decode base64} -body { 2708 set r [binary decode base64 YWJ] 2709 list [string length $r] $r 2710} -result {2 ab} 2711test binary-73.23 {binary decode base64} -body { 2712 set r [binary decode base64 YWJj] 2713 list [string length $r] $r 2714} -result {3 abc} 2715test binary-73.24 {binary decode base64} -body { 2716 string length [binary decode base64 " "] 2717} -result 0 2718test binary-73.25 {binary decode base64} -body { 2719 list [string length [set r [binary decode base64 WA==\n]]] $r 2720} -result {1 X} 2721test binary-73.26 {binary decode base64} -body { 2722 list [string length [set r [binary decode base64 WFk=\n]]] $r 2723} -result {2 XY} 2724test binary-73.27 {binary decode base64} -body { 2725 list [string length [set r [binary decode base64 WFla\n]]] $r 2726} -result {3 XYZ} 2727test binary-73.28 {binary decode base64} -body { 2728 list [string length [set r [binary decode base64 -strict WA==\n]]] $r 2729} -returnCodes error -match glob -result {invalid base64 character *} 2730test binary-73.29 {binary decode base64} -body { 2731 list [string length [set r [binary decode base64 -strict WFk=\n]]] $r 2732} -returnCodes error -match glob -result {invalid base64 character *} 2733test binary-73.30 {binary decode base64} -body { 2734 list [string length [set r [binary decode base64 -strict WFla\n]]] $r 2735} -returnCodes error -match glob -result {invalid base64 character *} 2736test binary-73.31 {binary decode base64} -body { 2737 list [string length [set r [binary decode base64 -strict WA==WFla]]] $r 2738} -returnCodes error -match glob -result {invalid base64 character *} 2739test binary-73.32 {binary decode base64, bug [00d04c4f12]} -body { 2740 list \ 2741 [string length [binary decode base64 =]] \ 2742 [string length [binary decode base64 " ="]] \ 2743 [string length [binary decode base64 " ="]] \ 2744 [string length [binary decode base64 "\r\n\t="]] \ 2745} -result [lrepeat 4 0] 2746test binary-73.33 {binary decode base64, bug [00d04c4f12]} -body { 2747 list \ 2748 [string length [binary decode base64 ==]] \ 2749 [string length [binary decode base64 " =="]] \ 2750 [string length [binary decode base64 " =="]] \ 2751 [string length [binary decode base64 " =="]] \ 2752} -result [lrepeat 4 0] 2753test binary-73.34 {binary decode base64, (compatibility) unfulfilled base64 (single char) in non-strict mode} -body { 2754 list \ 2755 [expr {[binary decode base64 a] eq [binary decode base64 ""]}] \ 2756 [expr {[binary decode base64 abcda] eq [binary decode base64 "abcd"]}] 2757} -result [lrepeat 2 1] 2758test binary-73.35 {binary decode base64, bad base64 in strict mode} -body { 2759 set r {} 2760 foreach c {a " a" " a" " a" " a" abcda abcdabcda a= a== abcda= abcda==} { 2761 lappend r \ 2762 [catch {binary decode base64 $c}] \ 2763 [catch {binary decode base64 -strict $c}] 2764 } 2765 set r 2766} -result [lrepeat 11 0 1] 2767test binary-73.36 {binary decode base64: check encoded & decoded equals original} -body { 2768 set r {} 2769 for {set i 0} {$i < 255 && [llength $r] < 20} {incr i} { 2770 foreach c {1 2 3 4 5 6 7 8} { 2771 set c [string repeat [format %c $i] $c] 2772 if {[set a [binary decode base64 [set x [binary encode base64 $c]]]] ne $c} { 2773 lappend r "encode & decode is wrong on string `$c` (encoded: $x): `$a` != `$c`" 2774 } 2775 } 2776 } 2777 join $r \n 2778} -result {} 2779test binary-73.37 {binary decode base64: Bug ffeb2097af} { 2780 binary decode base64 [binary encode base64 -maxlen 3 -wrapchar : abc] 2781} abc 2782 2783test binary-74.1 {binary encode uuencode} -body { 2784 binary encode uuencode 2785} -returnCodes error -match glob -result "wrong # args: *" 2786test binary-74.2 {binary encode uuencode} -body { 2787 binary encode uuencode abc 2788} -result {#86)C 2789} 2790test binary-74.3 {binary encode uuencode} -body { 2791 binary encode uuencode {} 2792} -result {} 2793test binary-74.4 {binary encode uuencode} -body { 2794 binary encode uuencode [string repeat abc 20] 2795} -result "M[string repeat 86)C 15]\n/[string repeat 86)C 5]\n" 2796test binary-74.5 {binary encode uuencode} -body { 2797 binary encode uuencode \x00\x01\x02\x03\x04\x00\x01\x02\x03 2798} -result ")``\$\"`P0``0(#\n" 2799test binary-74.6 {binary encode uuencode} -body { 2800 binary encode uuencode \0 2801} -result {!`` 2802} 2803test binary-74.7 {binary encode uuencode} -body { 2804 binary encode uuencode \x00\x00 2805} -result "\"``` 2806" 2807test binary-74.8 {binary encode uuencode} -body { 2808 binary encode uuencode \x00\x00\x00 2809} -result {#```` 2810} 2811test binary-74.9 {binary encode uuencode} -body { 2812 binary encode uuencode \x00\x00\x00\x00 2813} -result {$`````` 2814} 2815test binary-74.10 {binary encode uuencode} -returnCodes error -body { 2816 binary encode uuencode -foo 30 abcabcabc 2817} -result {bad option "-foo": must be -maxlen or -wrapchar} 2818test binary-74.11 {binary encode uuencode} -returnCodes error -body { 2819 binary encode uuencode -maxlen 4 abcabcabc 2820} -result {line length out of range} 2821test binary-74.12 {binary encode uuencode} -body { 2822 binary encode uuencode -maxlen 5 -wrapchar \t abcabcabc 2823} -result #86)C\t#86)C\t#86)C\t 2824test binary-74.13 {binary encode uuencode} -body { 2825 binary encode uuencode -maxlen 85 -wrapchar \t abcabcabc 2826} -result )86)C86)C86)C\t 2827test binary-74.14 {binary encode uuencode} -returnCodes error -body { 2828 binary encode uuencode -maxlen 86 abcabcabc 2829} -result {line length out of range} 2830 2831test binary-75.1 {binary decode uuencode} -body { 2832 binary decode uuencode 2833} -returnCodes error -match glob -result "wrong # args: *" 2834test binary-75.2 {binary decode uuencode} -body { 2835 binary decode uuencode "#86)C\n" 2836} -result {abc} 2837test binary-75.3 {binary decode uuencode} -body { 2838 binary decode uuencode {} 2839} -result {} 2840test binary-75.3.1 {binary decode uuencode} -body { 2841 binary decode uuencode `\n 2842} -result {} 2843test binary-75.4 {binary decode uuencode} -body { 2844 binary decode uuencode "M[string repeat 86)C 15]\n/[string repeat 86)C 5]\n" 2845} -result [string repeat abc 20] 2846test binary-75.5 {binary decode uuencode} -body { 2847 binary decode uuencode ")``\$\"`P0``0(#" 2848} -result "\x00\x01\x02\x03\x04\x00\x01\x02\x03" 2849test binary-75.6 {binary decode uuencode} -body { 2850 string length [binary decode uuencode "`\n"] 2851} -result 0 2852test binary-75.7 {binary decode uuencode} -body { 2853 string length [binary decode uuencode "!`\n"] 2854} -result 1 2855test binary-75.8 {binary decode uuencode} -body { 2856 string length [binary decode uuencode "\"``\n"] 2857} -result 2 2858test binary-75.9 {binary decode uuencode} -body { 2859 string length [binary decode uuencode "#```\n"] 2860} -result 3 2861test binary-75.10 {binary decode uuencode} -body { 2862 set s ">[string repeat 86)C 10]\n>[string repeat 86)C 10]" 2863 binary decode uuencode $s 2864} -result [string repeat abc 20] 2865test binary-75.11 {binary decode uuencode} -body { 2866 set s ">[string repeat 86)C 10]\n\t>\t[string repeat 86)C 10]\r" 2867 binary decode uuencode $s 2868} -result [string repeat abc 20] 2869test binary-75.12 {binary decode uuencode} -body { 2870 binary decode uuencode -strict "|86)C" 2871} -returnCodes error -match glob -result {invalid uuencode character "|" * at position 0} 2872test binary-75.13 {binary decode uuencode} -body { 2873 set s ">[string repeat 86)C 10]|[string repeat 86)C 10]" 2874 binary decode uuencode -strict $s 2875} -returnCodes error -match glob -result {invalid uuencode character "|" * at position 41} 2876test binary-75.14 {binary decode uuencode} -body { 2877 set s ">[string repeat 86)C 10]\na[string repeat 86)C 10]" 2878 binary decode uuencode -strict $s 2879} -returnCodes error -match glob -result {invalid uuencode character *} 2880test binary-75.20 {binary decode uuencode} -body { 2881 set r [binary decode uuencode " 8"] 2882 list [string length $r] $r 2883} -result {0 {}} 2884test binary-75.21 {binary decode uuencode} -body { 2885 set r [binary decode uuencode "!86"] 2886 list [string length $r] $r 2887} -result {1 a} 2888test binary-75.22 {binary decode uuencode} -body { 2889 set r [binary decode uuencode "\"86)"] 2890 list [string length $r] $r 2891} -result {2 ab} 2892test binary-75.23 {binary decode uuencode} -body { 2893 set r [binary decode uuencode "#86)C"] 2894 list [string length $r] $r 2895} -result {3 abc} 2896test binary-75.24 {binary decode uuencode} -body { 2897 set s "#04)\# " 2898 binary decode uuencode $s 2899} -result ABC 2900test binary-75.25 {binary decode uuencode} -body { 2901 set s "#04)\#z" 2902 binary decode uuencode $s 2903} -returnCodes error -match glob -result {invalid uuencode character "z" * at position 5} 2904test binary-75.26 {binary decode uuencode} -body { 2905 string length [binary decode uuencode " "] 2906} -result 0 2907 2908test binary-76.1 {binary string appending growth algorithm} unix { 2909 # Create zero-length byte array first 2910 set f [open /dev/null rb] 2911 chan configure $f -blocking 0 2912 set str [read $f 2] 2913 close $f 2914 # Append to it 2915 string length [append str [binary format a* foo]] 2916} 3 2917test binary-76.2 {binary string appending growth algorithm} win { 2918 # Create zero-length byte array first 2919 set f [open NUL rb] 2920 chan configure $f -blocking 0 2921 set str [read $f 2] 2922 close $f 2923 # Append to it 2924 string length [append str [binary format a* foo]] 2925} 3 2926 2927test binary-77.1 {string cat ops on all bytearrays} { 2928 apply {{a b} { 2929 return [binary format H* $a][binary format H* $b] 2930 }} ab cd 2931} [binary format H* abcd] 2932test binary-77.2 {string cat ops on all bytearrays} { 2933 apply {{a b} { 2934 set one [binary format H* $a] 2935 return $one[binary format H* $b] 2936 }} ab cd 2937} [binary format H* abcd] 2938 2939test binary-78.1 {unicode (out of BMP) to byte-array conversion, bug-[bd94500678]} -body { 2940 # just test for BO-segfault (high surrogate w/o advance source pointer for out of BMP char if TCL_UTF_MAX == 3): 2941 binary encode hex \U0001f415 2942 binary scan \U0001f415 a* v; set v 2943 set str {} 2944} -result {} 2945 2946 2947testConstraint testsetbytearraylength \ 2948 [expr {"testsetbytearraylength" in [info commands]}] 2949 2950test binary-79.1 {Tcl_SetByteArrayLength} testsetbytearraylength { 2951 testsetbytearraylength [string cat A B C] 1 2952} A 2953test binary-79.2 {Tcl_SetByteArrayLength} testsetbytearraylength { 2954 testsetbytearraylength [string cat Ł B C] 1 2955} A 2956 2957test binary-80.1 {TclGetBytesFromObj} -constraints testbytestring -returnCodes 1 -body { 2958 testbytestring "乎" 2959} -result "expected byte sequence but character 0 was '乎' (U+004E4E)" 2960test binary-80.2 {TclGetBytesFromObj} -constraints testbytestring -returnCodes 1 -body { 2961 testbytestring [testbytestring "\x00\xA0\xA0\xA0\xE4\xB9\x8E"] 2962} -result "expected byte sequence but character 4 was '乎' (U+004E4E)" 2963test binary-80.3 {TclGetBytesFromObj} -constraints testbytestring -returnCodes 1 -body { 2964 testbytestring [testbytestring "\xC0\x80\xA0\xA0\xA0\xE4\xB9\x8E"] 2965} -result "expected byte sequence but character 4 was '乎' (U+004E4E)" 2966test binary-80.4 {TclGetBytesFromObj} -constraints testbytestring -returnCodes 1 -body { 2967 testbytestring [testbytestring "\xC0\x80\xA0\xA0\xA0\xF0\x9F\x98\x81"] 2968} -result "expected byte sequence but character 4 was '\U01F601' (U+01F601)" 2969 2970# ---------------------------------------------------------------------- 2971# cleanup 2972 2973::tcltest::cleanupTests 2974return 2975 2976# Local Variables: 2977# mode: tcl 2978# End: 2979