os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/binary.test
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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
     4 # built-in commands.  Sourcing this file into Tcl runs the tests and
     5 # generates output for errors.  No output means no errors were found.
     6 #
     7 # Copyright (c) 1997 by Sun Microsystems, Inc.
     8 # Copyright (c) 1998-1999 by Scriptics Corporation.
     9 #
    10 # See the file "license.terms" for information on usage and redistribution
    11 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    12 #
    13 # RCS: @(#) $Id: binary.test,v 1.11.2.4 2006/04/05 15:17:06 dgp Exp $
    14 
    15 if {[lsearch [namespace children] ::tcltest] == -1} {
    16     package require tcltest
    17     namespace import -force ::tcltest::*
    18 }
    19 
    20 test binary-0.1 {DupByteArrayInternalRep} {
    21     set hdr [binary format cc 0 0316]
    22     set buf hellomatt
    23     
    24     set data $hdr
    25     append data $buf
    26     
    27     string length $data
    28 } 11
    29 
    30 test binary-1.1 {Tcl_BinaryObjCmd: bad args} {
    31     list [catch {binary} msg] $msg
    32 } {1 {wrong # args: should be "binary option ?arg arg ...?"}}
    33 test binary-1.2 {Tcl_BinaryObjCmd: bad args} {
    34     list [catch {binary foo} msg] $msg
    35 } {1 {bad option "foo": must be format or scan}}
    36 
    37 test binary-1.3 {Tcl_BinaryObjCmd: format error} {
    38     list [catch {binary f} msg] $msg
    39 } {1 {wrong # args: should be "binary format formatString ?arg arg ...?"}}
    40 test binary-1.4 {Tcl_BinaryObjCmd: format} {
    41     binary format ""
    42 } {}
    43 
    44 
    45 test binary-2.1 {Tcl_BinaryObjCmd: format} {
    46     list [catch {binary format a } msg] $msg
    47 } {1 {not enough arguments for all format specifiers}}
    48 test binary-2.2 {Tcl_BinaryObjCmd: format} {
    49     binary format a0 foo
    50 } {}
    51 test binary-2.3 {Tcl_BinaryObjCmd: format} {
    52     binary format a f
    53 } {f}
    54 test binary-2.4 {Tcl_BinaryObjCmd: format} {
    55     binary format a foo
    56 } {f}
    57 test binary-2.5 {Tcl_BinaryObjCmd: format} {
    58     binary format a3 foo
    59 } {foo}
    60 test binary-2.6 {Tcl_BinaryObjCmd: format} {
    61     binary format a5 foo
    62 } foo\x00\x00
    63 test binary-2.7 {Tcl_BinaryObjCmd: format} {
    64     binary format a*a3 foobarbaz blat
    65 } foobarbazbla
    66 test binary-2.8 {Tcl_BinaryObjCmd: format} {
    67     binary format a*X3a2 foobar x
    68 } foox\x00r
    69 
    70 test binary-3.1 {Tcl_BinaryObjCmd: format} {
    71     list [catch {binary format A} msg] $msg
    72 } {1 {not enough arguments for all format specifiers}}
    73 test binary-3.2 {Tcl_BinaryObjCmd: format} {
    74     binary format A0 f
    75 } {}
    76 test binary-3.3 {Tcl_BinaryObjCmd: format} {
    77     binary format A f
    78 } {f}
    79 test binary-3.4 {Tcl_BinaryObjCmd: format} {
    80     binary format A foo
    81 } {f}
    82 test binary-3.5 {Tcl_BinaryObjCmd: format} {
    83     binary format A3 foo
    84 } {foo}
    85 test binary-3.6 {Tcl_BinaryObjCmd: format} {
    86     binary format A5 foo
    87 } {foo  }
    88 test binary-3.7 {Tcl_BinaryObjCmd: format} {
    89     binary format A*A3 foobarbaz blat
    90 } foobarbazbla
    91 test binary-3.8 {Tcl_BinaryObjCmd: format} {
    92     binary format A*X3A2 foobar x
    93 } {foox r}
    94 
    95 test binary-4.1 {Tcl_BinaryObjCmd: format} {
    96     list [catch {binary format B} msg] $msg
    97 } {1 {not enough arguments for all format specifiers}}
    98 test binary-4.2 {Tcl_BinaryObjCmd: format} {
    99     binary format B0 1
   100 } {}
   101 test binary-4.3 {Tcl_BinaryObjCmd: format} {
   102     binary format B 1
   103 } \x80
   104 test binary-4.4 {Tcl_BinaryObjCmd: format} {
   105     binary format B* 010011
   106 } \x4c
   107 test binary-4.5 {Tcl_BinaryObjCmd: format} {
   108     binary format B8 01001101
   109 } \x4d
   110 test binary-4.6 {Tcl_BinaryObjCmd: format} {
   111     binary format A2X2B9 oo 01001101
   112 } \x4d\x00
   113 test binary-4.7 {Tcl_BinaryObjCmd: format} {
   114     binary format B9 010011011010
   115 } \x4d\x80
   116 test binary-4.8 {Tcl_BinaryObjCmd: format} {
   117     binary format B2B3 10 010
   118 } \x80\x40
   119 test binary-4.9 {Tcl_BinaryObjCmd: format} {
   120     list [catch {binary format B1B5 1 foo} msg] $msg
   121 } {1 {expected binary string but got "foo" instead}}
   122 
   123 test binary-5.1 {Tcl_BinaryObjCmd: format} {
   124     list [catch {binary format b} msg] $msg
   125 } {1 {not enough arguments for all format specifiers}}
   126 test binary-5.2 {Tcl_BinaryObjCmd: format} {
   127     binary format b0 1
   128 } {}
   129 test binary-5.3 {Tcl_BinaryObjCmd: format} {
   130     binary format b 1
   131 } \x01
   132 test binary-5.4 {Tcl_BinaryObjCmd: format} {
   133     binary format b* 010011
   134 } 2
   135 test binary-5.5 {Tcl_BinaryObjCmd: format} {
   136     binary format b8 01001101
   137 } \xb2
   138 test binary-5.6 {Tcl_BinaryObjCmd: format} {
   139     binary format A2X2b9 oo 01001101
   140 } \xb2\x00
   141 test binary-5.7 {Tcl_BinaryObjCmd: format} {
   142     binary format b9 010011011010
   143 } \xb2\x01
   144 test binary-5.8 {Tcl_BinaryObjCmd: format} {
   145     binary format b17 1
   146 } \x01\00\00
   147 test binary-5.9 {Tcl_BinaryObjCmd: format} {
   148     binary format b2b3 10 010
   149 } \x01\x02
   150 test binary-5.10 {Tcl_BinaryObjCmd: format} {
   151     list [catch {binary format b1b5 1 foo} msg] $msg
   152 } {1 {expected binary string but got "foo" instead}}
   153 
   154 test binary-6.1 {Tcl_BinaryObjCmd: format} {
   155     list [catch {binary format h} msg] $msg
   156 } {1 {not enough arguments for all format specifiers}}
   157 test binary-6.2 {Tcl_BinaryObjCmd: format} {
   158     binary format h0 1
   159 } {}
   160 test binary-6.3 {Tcl_BinaryObjCmd: format} {
   161     binary format h 1
   162 } \x01
   163 test binary-6.4 {Tcl_BinaryObjCmd: format} {
   164     binary format h c
   165 } \x0c
   166 test binary-6.5 {Tcl_BinaryObjCmd: format} {
   167     binary format h* baadf00d
   168 } \xab\xda\x0f\xd0
   169 test binary-6.6 {Tcl_BinaryObjCmd: format} {
   170     binary format h4 c410
   171 } \x4c\x01
   172 test binary-6.7 {Tcl_BinaryObjCmd: format} {
   173     binary format h6 c4102
   174 } \x4c\x01\x02
   175 test binary-6.8 {Tcl_BinaryObjCmd: format} {
   176     binary format h5 c41020304
   177 } \x4c\x01\x02
   178 test binary-6.9 {Tcl_BinaryObjCmd: format} {
   179     binary format a3X3h5 foo 2
   180 } \x02\x00\x00
   181 test binary-6.10 {Tcl_BinaryObjCmd: format} {
   182     binary format h2h3 23 456
   183 } \x32\x54\x06
   184 test binary-6.11 {Tcl_BinaryObjCmd: format} {
   185     list [catch {binary format h2 foo} msg] $msg
   186 } {1 {expected hexadecimal string but got "foo" instead}}
   187 
   188 test binary-7.1 {Tcl_BinaryObjCmd: format} {
   189     list [catch {binary format H} msg] $msg
   190 } {1 {not enough arguments for all format specifiers}}
   191 test binary-7.2 {Tcl_BinaryObjCmd: format} {
   192     binary format H0 1
   193 } {}
   194 test binary-7.3 {Tcl_BinaryObjCmd: format} {
   195     binary format H 1
   196 } \x10
   197 test binary-7.4 {Tcl_BinaryObjCmd: format} {
   198     binary format H c
   199 } \xc0
   200 test binary-7.5 {Tcl_BinaryObjCmd: format} {
   201     binary format H* baadf00d
   202 } \xba\xad\xf0\x0d
   203 test binary-7.6 {Tcl_BinaryObjCmd: format} {
   204     binary format H4 c410
   205 } \xc4\x10
   206 test binary-7.7 {Tcl_BinaryObjCmd: format} {
   207     binary format H6 c4102
   208 } \xc4\x10\x20
   209 test binary-7.8 {Tcl_BinaryObjCmd: format} {
   210     binary format H5 c41023304
   211 } \xc4\x10\x20
   212 test binary-7.9 {Tcl_BinaryObjCmd: format} {
   213     binary format a3X3H5 foo 2
   214 } \x20\x00\x00
   215 test binary-7.10 {Tcl_BinaryObjCmd: format} {
   216     binary format H2H3 23 456
   217 } \x23\x45\x60
   218 test binary-7.11 {Tcl_BinaryObjCmd: format} {
   219     list [catch {binary format H2 foo} msg] $msg
   220 } {1 {expected hexadecimal string but got "foo" instead}}
   221 
   222 test binary-8.1 {Tcl_BinaryObjCmd: format} {
   223     list [catch {binary format c} msg] $msg
   224 } {1 {not enough arguments for all format specifiers}}
   225 test binary-8.2 {Tcl_BinaryObjCmd: format} {
   226     list [catch {binary format c blat} msg] $msg
   227 } {1 {expected integer but got "blat"}}
   228 test binary-8.3 {Tcl_BinaryObjCmd: format} {
   229     binary format c0 0x50
   230 } {}
   231 test binary-8.4 {Tcl_BinaryObjCmd: format} {
   232     binary format c 0x50
   233 } P
   234 test binary-8.5 {Tcl_BinaryObjCmd: format} {
   235     binary format c 0x5052
   236 } R
   237 test binary-8.6 {Tcl_BinaryObjCmd: format} {
   238     binary format c2 {0x50 0x52}
   239 } PR
   240 test binary-8.7 {Tcl_BinaryObjCmd: format} {
   241     binary format c2 {0x50 0x52 0x53}
   242 } PR
   243 test binary-8.8 {Tcl_BinaryObjCmd: format} {
   244     binary format c* {0x50 0x52}
   245 } PR
   246 test binary-8.9 {Tcl_BinaryObjCmd: format} {
   247     list [catch {binary format c2 {0x50}} msg] $msg
   248 } {1 {number of elements in list does not match count}}
   249 test binary-8.10 {Tcl_BinaryObjCmd: format} {
   250     set a {0x50 0x51}
   251     list [catch {binary format c $a} msg] $msg
   252 } [list 1 "expected integer but got \"0x50 0x51\""]
   253 test binary-8.11 {Tcl_BinaryObjCmd: format} {
   254     set a {0x50 0x51}
   255     binary format c1 $a
   256 } P
   257 
   258 test binary-9.1 {Tcl_BinaryObjCmd: format} {
   259     list [catch {binary format s} msg] $msg
   260 } {1 {not enough arguments for all format specifiers}}
   261 test binary-9.2 {Tcl_BinaryObjCmd: format} {
   262     list [catch {binary format s blat} msg] $msg
   263 } {1 {expected integer but got "blat"}}
   264 test binary-9.3 {Tcl_BinaryObjCmd: format} {
   265     binary format s0 0x50
   266 } {}
   267 test binary-9.4 {Tcl_BinaryObjCmd: format} {
   268     binary format s 0x50
   269 } P\x00
   270 test binary-9.5 {Tcl_BinaryObjCmd: format} {
   271     binary format s 0x5052
   272 } RP
   273 test binary-9.6 {Tcl_BinaryObjCmd: format} {
   274     binary format s 0x505251 0x53
   275 } QR
   276 test binary-9.7 {Tcl_BinaryObjCmd: format} {
   277     binary format s2 {0x50 0x52}
   278 } P\x00R\x00
   279 test binary-9.8 {Tcl_BinaryObjCmd: format} {
   280     binary format s* {0x5051 0x52}
   281 } QPR\x00
   282 test binary-9.9 {Tcl_BinaryObjCmd: format} {
   283     binary format s2 {0x50 0x52 0x53} 0x54
   284 } P\x00R\x00
   285 test binary-9.10 {Tcl_BinaryObjCmd: format} {
   286     list [catch {binary format s2 {0x50}} msg] $msg
   287 } {1 {number of elements in list does not match count}}
   288 test binary-9.11 {Tcl_BinaryObjCmd: format} {
   289     set a {0x50 0x51}
   290     list [catch {binary format s $a} msg] $msg
   291 } [list 1 "expected integer but got \"0x50 0x51\""]
   292 test binary-9.12 {Tcl_BinaryObjCmd: format} {
   293     set a {0x50 0x51}
   294     binary format s1 $a
   295 } P\x00
   296 
   297 test binary-10.1 {Tcl_BinaryObjCmd: format} {
   298     list [catch {binary format S} msg] $msg
   299 } {1 {not enough arguments for all format specifiers}}
   300 test binary-10.2 {Tcl_BinaryObjCmd: format} {
   301     list [catch {binary format S blat} msg] $msg
   302 } {1 {expected integer but got "blat"}}
   303 test binary-10.3 {Tcl_BinaryObjCmd: format} {
   304     binary format S0 0x50
   305 } {}
   306 test binary-10.4 {Tcl_BinaryObjCmd: format} {
   307     binary format S 0x50
   308 } \x00P
   309 test binary-10.5 {Tcl_BinaryObjCmd: format} {
   310     binary format S 0x5052
   311 } PR
   312 test binary-10.6 {Tcl_BinaryObjCmd: format} {
   313     binary format S 0x505251 0x53
   314 } RQ
   315 test binary-10.7 {Tcl_BinaryObjCmd: format} {
   316     binary format S2 {0x50 0x52}
   317 } \x00P\x00R
   318 test binary-10.8 {Tcl_BinaryObjCmd: format} {
   319     binary format S* {0x5051 0x52}
   320 } PQ\x00R
   321 test binary-10.9 {Tcl_BinaryObjCmd: format} {
   322     binary format S2 {0x50 0x52 0x53} 0x54
   323 } \x00P\x00R
   324 test binary-10.10 {Tcl_BinaryObjCmd: format} {
   325     list [catch {binary format S2 {0x50}} msg] $msg
   326 } {1 {number of elements in list does not match count}}
   327 test binary-10.11 {Tcl_BinaryObjCmd: format} {
   328     set a {0x50 0x51}
   329     list [catch {binary format S $a} msg] $msg
   330 } [list 1 "expected integer but got \"0x50 0x51\""]
   331 test binary-10.12 {Tcl_BinaryObjCmd: format} {
   332     set a {0x50 0x51}
   333     binary format S1 $a
   334 } \x00P
   335 
   336 test binary-11.1 {Tcl_BinaryObjCmd: format} {
   337     list [catch {binary format i} msg] $msg
   338 } {1 {not enough arguments for all format specifiers}}
   339 test binary-11.2 {Tcl_BinaryObjCmd: format} {
   340     list [catch {binary format i blat} msg] $msg
   341 } {1 {expected integer but got "blat"}}
   342 test binary-11.3 {Tcl_BinaryObjCmd: format} {
   343     binary format i0 0x50
   344 } {}
   345 test binary-11.4 {Tcl_BinaryObjCmd: format} {
   346     binary format i 0x50
   347 } P\x00\x00\x00
   348 test binary-11.5 {Tcl_BinaryObjCmd: format} {
   349     binary format i 0x5052
   350 } RP\x00\x00
   351 test binary-11.6 {Tcl_BinaryObjCmd: format} {
   352     binary format i 0x505251 0x53
   353 } QRP\x00
   354 test binary-11.7 {Tcl_BinaryObjCmd: format} {
   355     binary format i1 {0x505251 0x53}
   356 } QRP\x00
   357 test binary-11.8 {Tcl_BinaryObjCmd: format} {
   358     binary format i 0x53525150
   359 } PQRS
   360 test binary-11.9 {Tcl_BinaryObjCmd: format} {
   361     binary format i2 {0x50 0x52}
   362 } P\x00\x00\x00R\x00\x00\x00
   363 test binary-11.10 {Tcl_BinaryObjCmd: format} {
   364     binary format i* {0x50515253 0x52}
   365 } SRQPR\x00\x00\x00
   366 test binary-11.11 {Tcl_BinaryObjCmd: format} {
   367     list [catch {binary format i2 {0x50}} msg] $msg
   368 } {1 {number of elements in list does not match count}}
   369 test binary-11.12 {Tcl_BinaryObjCmd: format} {
   370     set a {0x50 0x51}
   371     list [catch {binary format i $a} msg] $msg
   372 } [list 1 "expected integer but got \"0x50 0x51\""]
   373 test binary-11.13 {Tcl_BinaryObjCmd: format} {
   374     set a {0x50 0x51}
   375     binary format i1 $a
   376 } P\x00\x00\x00
   377 
   378 test binary-12.1 {Tcl_BinaryObjCmd: format} {
   379     list [catch {binary format I} msg] $msg
   380 } {1 {not enough arguments for all format specifiers}}
   381 test binary-12.2 {Tcl_BinaryObjCmd: format} {
   382     list [catch {binary format I blat} msg] $msg
   383 } {1 {expected integer but got "blat"}}
   384 test binary-12.3 {Tcl_BinaryObjCmd: format} {
   385     binary format I0 0x50
   386 } {}
   387 test binary-12.4 {Tcl_BinaryObjCmd: format} {
   388     binary format I 0x50
   389 } \x00\x00\x00P
   390 test binary-12.5 {Tcl_BinaryObjCmd: format} {
   391     binary format I 0x5052
   392 } \x00\x00PR
   393 test binary-12.6 {Tcl_BinaryObjCmd: format} {
   394     binary format I 0x505251 0x53
   395 } \x00PRQ
   396 test binary-12.7 {Tcl_BinaryObjCmd: format} {
   397     binary format I1 {0x505251 0x53}
   398 } \x00PRQ
   399 test binary-12.8 {Tcl_BinaryObjCmd: format} {
   400     binary format I 0x53525150
   401 } SRQP
   402 test binary-12.9 {Tcl_BinaryObjCmd: format} {
   403     binary format I2 {0x50 0x52}
   404 } \x00\x00\x00P\x00\x00\x00R
   405 test binary-12.10 {Tcl_BinaryObjCmd: format} {
   406     binary format I* {0x50515253 0x52}
   407 } PQRS\x00\x00\x00R
   408 test binary-12.11 {Tcl_BinaryObjCmd: format} {
   409     list [catch {binary format i2 {0x50}} msg] $msg
   410 } {1 {number of elements in list does not match count}}
   411 test binary-12.12 {Tcl_BinaryObjCmd: format} {
   412     set a {0x50 0x51}
   413     list [catch {binary format I $a} msg] $msg
   414 } [list 1 "expected integer but got \"0x50 0x51\""]
   415 test binary-12.13 {Tcl_BinaryObjCmd: format} {
   416     set a {0x50 0x51}
   417     binary format I1 $a
   418 } \x00\x00\x00P
   419 
   420 test binary-13.1 {Tcl_BinaryObjCmd: format} {
   421     list [catch {binary format f} msg] $msg
   422 } {1 {not enough arguments for all format specifiers}}
   423 test binary-13.2 {Tcl_BinaryObjCmd: format} {
   424     list [catch {binary format f blat} msg] $msg
   425 } {1 {expected floating-point number but got "blat"}}
   426 test binary-13.3 {Tcl_BinaryObjCmd: format} {
   427     binary format f0 1.6
   428 } {}
   429 test binary-13.4 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
   430     binary format f 1.6
   431 } \x3f\xcc\xcc\xcd
   432 test binary-13.5 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
   433     binary format f 1.6
   434 } \xcd\xcc\xcc\x3f
   435 test binary-13.6 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
   436     binary format f* {1.6 3.4}
   437 } \x3f\xcc\xcc\xcd\x40\x59\x99\x9a
   438 test binary-13.7 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
   439     binary format f* {1.6 3.4}
   440 } \xcd\xcc\xcc\x3f\x9a\x99\x59\x40
   441 test binary-13.8 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
   442     binary format f2 {1.6 3.4}
   443 } \x3f\xcc\xcc\xcd\x40\x59\x99\x9a
   444 test binary-13.9 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
   445     binary format f2 {1.6 3.4}
   446 } \xcd\xcc\xcc\x3f\x9a\x99\x59\x40
   447 test binary-13.10 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
   448     binary format f2 {1.6 3.4 5.6}
   449 } \x3f\xcc\xcc\xcd\x40\x59\x99\x9a
   450 test binary-13.11 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
   451     binary format f2 {1.6 3.4 5.6}
   452 } \xcd\xcc\xcc\x3f\x9a\x99\x59\x40
   453 test binary-13.12 {Tcl_BinaryObjCmd: float overflow} {nonPortable macOrUnix} {
   454     binary format f -3.402825e+38
   455 } \xff\x7f\xff\xff
   456 test binary-13.13 {Tcl_BinaryObjCmd: float overflow} {nonPortable pcOnly} {
   457     binary format f -3.402825e+38
   458 } \xff\xff\x7f\xff
   459 test binary-13.14 {Tcl_BinaryObjCmd: float underflow} {nonPortable macOrUnix} {
   460     binary format f -3.402825e-100
   461 } \x80\x00\x00\x00
   462 test binary-13.15 {Tcl_BinaryObjCmd: float underflow} {nonPortable pcOnly} {
   463     binary format f -3.402825e-100
   464 } \x00\x00\x00\x80
   465 test binary-13.16 {Tcl_BinaryObjCmd: format} {
   466     list [catch {binary format f2 {1.6}} msg] $msg
   467 } {1 {number of elements in list does not match count}}
   468 test binary-13.17 {Tcl_BinaryObjCmd: format} {
   469     set a {1.6 3.4}
   470     list [catch {binary format f $a} msg] $msg
   471 } [list 1 "expected floating-point number but got \"1.6 3.4\""]
   472 test binary-13.18 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
   473     set a {1.6 3.4}
   474     binary format f1 $a
   475 } \x3f\xcc\xcc\xcd
   476 test binary-13.19 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
   477     set a {1.6 3.4}
   478     binary format f1 $a
   479 } \xcd\xcc\xcc\x3f
   480 
   481 test binary-14.1 {Tcl_BinaryObjCmd: format} {
   482     list [catch {binary format d} msg] $msg
   483 } {1 {not enough arguments for all format specifiers}}
   484 test binary-14.2 {Tcl_BinaryObjCmd: format} {
   485     list [catch {binary format d blat} msg] $msg
   486 } {1 {expected floating-point number but got "blat"}}
   487 test binary-14.3 {Tcl_BinaryObjCmd: format} {
   488     binary format d0 1.6
   489 } {}
   490 test binary-14.4 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
   491     binary format d 1.6
   492 } \x3f\xf9\x99\x99\x99\x99\x99\x9a
   493 test binary-14.5 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
   494     binary format d 1.6
   495 } \x9a\x99\x99\x99\x99\x99\xf9\x3f
   496 test binary-14.6 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
   497     binary format d* {1.6 3.4}
   498 } \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33
   499 test binary-14.7 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
   500     binary format d* {1.6 3.4}
   501 } \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40
   502 test binary-14.8 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
   503     binary format d2 {1.6 3.4}
   504 } \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33
   505 test binary-14.9 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
   506     binary format d2 {1.6 3.4}
   507 } \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40
   508 test binary-14.10 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
   509     binary format d2 {1.6 3.4 5.6}
   510 } \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33
   511 test binary-14.11 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
   512     binary format d2 {1.6 3.4 5.6}
   513 } \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40
   514 test binary-14.12 {Tcl_BinaryObjCmd: float overflow} {nonPortable unixOnly} {
   515     binary format d NaN
   516 } \x7f\xff\xff\xff\xff\xff\xff\xff
   517 test binary-14.13 {Tcl_BinaryObjCmd: float overflow} {nonPortable macOnly} {
   518     binary format d NaN
   519 } \x7f\xf8\x02\xa0\x00\x00\x00\x00
   520 test binary-14.14 {Tcl_BinaryObjCmd: format} {
   521     list [catch {binary format d2 {1.6}} msg] $msg
   522 } {1 {number of elements in list does not match count}}
   523 test binary-14.15 {Tcl_BinaryObjCmd: format} {
   524     set a {1.6 3.4}
   525     list [catch {binary format d $a} msg] $msg
   526 } [list 1 "expected floating-point number but got \"1.6 3.4\""]
   527 test binary-14.16 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
   528     set a {1.6 3.4}
   529     binary format d1 $a
   530 } \x3f\xf9\x99\x99\x99\x99\x99\x9a
   531 test binary-14.17 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
   532     set a {1.6 3.4}
   533     binary format d1 $a
   534 } \x9a\x99\x99\x99\x99\x99\xf9\x3f
   535 test binary-14.18 {FormatNumber: Bug 1116542} {
   536     binary scan [binary format d 1.25] d w
   537     set w
   538 } 1.25
   539 
   540 test binary-15.1 {Tcl_BinaryObjCmd: format} {
   541     list [catch {binary format ax*a "y" "z"} msg] $msg
   542 } {1 {cannot use "*" in format string with "x"}}
   543 test binary-15.2 {Tcl_BinaryObjCmd: format} {
   544     binary format axa "y" "z"
   545 } y\x00z
   546 test binary-15.3 {Tcl_BinaryObjCmd: format} {
   547     binary format ax3a "y" "z"
   548 } y\x00\x00\x00z
   549 test binary-15.4 {Tcl_BinaryObjCmd: format} {
   550     binary format a*X3x3a* "foo" "z"
   551 } \x00\x00\x00z
   552 
   553 test binary-16.1 {Tcl_BinaryObjCmd: format} {
   554     binary format a*X*a "foo" "z"
   555 } zoo
   556 test binary-16.2 {Tcl_BinaryObjCmd: format} {
   557     binary format aX3a "y" "z"
   558 } z
   559 test binary-16.3 {Tcl_BinaryObjCmd: format} {
   560     binary format a*Xa* "foo" "zy"
   561 } fozy
   562 test binary-16.4 {Tcl_BinaryObjCmd: format} {
   563     binary format a*X3a "foobar" "z"
   564 } foozar
   565 test binary-16.5 {Tcl_BinaryObjCmd: format} {
   566     binary format a*X3aX2a "foobar" "z" "b"
   567 } fobzar
   568 
   569 test binary-17.1 {Tcl_BinaryObjCmd: format} {
   570     binary format @1
   571 } \x00
   572 test binary-17.2 {Tcl_BinaryObjCmd: format} {
   573     binary format @5a2 "ab"
   574 } \x00\x00\x00\x00\x00\x61\x62
   575 test binary-17.3 {Tcl_BinaryObjCmd: format} {
   576     binary format {a*  @0  a2 @* a*} "foobar" "ab" "blat"
   577 } abobarblat
   578 
   579 test binary-18.1 {Tcl_BinaryObjCmd: format} {
   580     list [catch {binary format u0a3 abc abd} msg] $msg
   581 } {1 {bad field specifier "u"}}
   582 
   583 
   584 test binary-19.1 {Tcl_BinaryObjCmd: errors} {
   585     list [catch {binary s} msg] $msg
   586 } {1 {wrong # args: should be "binary scan value formatString ?varName varName ...?"}}
   587 test binary-19.2 {Tcl_BinaryObjCmd: errors} {
   588     list [catch {binary scan foo} msg] $msg
   589 } {1 {wrong # args: should be "binary scan value formatString ?varName varName ...?"}}
   590 test binary-19.3 {Tcl_BinaryObjCmd: scan} {
   591     binary scan {} {}
   592 } 0
   593 
   594 test binary-20.1 {Tcl_BinaryObjCmd: scan} {
   595     list [catch {binary scan abc a} msg] $msg
   596 } {1 {not enough arguments for all format specifiers}}
   597 test binary-20.2 {Tcl_BinaryObjCmd: scan} {
   598     catch {unset arg1}
   599     set arg1 1
   600     list [catch {binary scan abc a arg1(a)} msg] $msg
   601 } {1 {can't set "arg1(a)": variable isn't array}}
   602 test binary-20.3 {Tcl_BinaryObjCmd: scan} {
   603     catch {unset arg1}
   604     set arg1 abc
   605     list [binary scan abc a0 arg1] $arg1
   606 } {1 {}}
   607 test binary-20.4 {Tcl_BinaryObjCmd: scan} {
   608     catch {unset arg1}
   609     list [binary scan abc a* arg1] $arg1
   610 } {1 abc}
   611 test binary-20.5 {Tcl_BinaryObjCmd: scan} {
   612     catch {unset arg1}
   613     list [binary scan abc a5 arg1] [info exists arg1]
   614 } {0 0}
   615 test binary-20.6 {Tcl_BinaryObjCmd: scan} {
   616     set arg1 foo
   617     list [binary scan abc a2 arg1] $arg1
   618 } {1 ab}
   619 test binary-20.7 {Tcl_BinaryObjCmd: scan} {
   620     catch {unset arg1}
   621     catch {unset arg2}
   622     list [binary scan abcdef a2a2 arg1 arg2] $arg1 $arg2
   623 } {2 ab cd}
   624 test binary-20.8 {Tcl_BinaryObjCmd: scan} {
   625     catch {unset arg1}
   626     list [binary scan abc a2 arg1(a)] $arg1(a)
   627 } {1 ab}
   628 test binary-20.9 {Tcl_BinaryObjCmd: scan} {
   629     catch {unset arg1}
   630     list [binary scan abc a arg1(a)] $arg1(a)
   631 } {1 a}
   632 
   633 test binary-21.1 {Tcl_BinaryObjCmd: scan} {
   634     list [catch {binary scan abc A} msg] $msg
   635 } {1 {not enough arguments for all format specifiers}}
   636 test binary-21.2 {Tcl_BinaryObjCmd: scan} {
   637     catch {unset arg1}
   638     set arg1 1
   639     list [catch {binary scan abc A arg1(a)} msg] $msg
   640 } {1 {can't set "arg1(a)": variable isn't array}}
   641 test binary-21.3 {Tcl_BinaryObjCmd: scan} {
   642     catch {unset arg1}
   643     set arg1 abc
   644     list [binary scan abc A0 arg1] $arg1
   645 } {1 {}}
   646 test binary-21.4 {Tcl_BinaryObjCmd: scan} {
   647     catch {unset arg1}
   648     list [binary scan abc A* arg1] $arg1
   649 } {1 abc}
   650 test binary-21.5 {Tcl_BinaryObjCmd: scan} {
   651     catch {unset arg1}
   652     list [binary scan abc A5 arg1] [info exists arg1]
   653 } {0 0}
   654 test binary-21.6 {Tcl_BinaryObjCmd: scan} {
   655     set arg1 foo
   656     list [binary scan abc A2 arg1] $arg1
   657 } {1 ab}
   658 test binary-21.7 {Tcl_BinaryObjCmd: scan} {
   659     catch {unset arg1}
   660     catch {unset arg2}
   661     list [binary scan abcdef A2A2 arg1 arg2] $arg1 $arg2
   662 } {2 ab cd}
   663 test binary-21.8 {Tcl_BinaryObjCmd: scan} {
   664     catch {unset arg1}
   665     list [binary scan abc A2 arg1(a)] $arg1(a)
   666 } {1 ab}
   667 test binary-21.9 {Tcl_BinaryObjCmd: scan} {
   668     catch {unset arg1}
   669     list [binary scan abc A2 arg1(a)] $arg1(a)
   670 } {1 ab}
   671 test binary-21.10 {Tcl_BinaryObjCmd: scan} {
   672     catch {unset arg1}
   673     list [binary scan abc A arg1(a)] $arg1(a)
   674 } {1 a}
   675 test binary-21.11 {Tcl_BinaryObjCmd: scan} {
   676     catch {unset arg1}
   677     list [binary scan "abc def \x00  " A* arg1] $arg1
   678 } {1 {abc def}}
   679 test binary-21.12 {Tcl_BinaryObjCmd: scan} {
   680     catch {unset arg1}
   681     list [binary scan "abc def \x00ghi  " A* arg1] $arg1
   682 } [list 1 "abc def \x00ghi"]
   683 
   684 test binary-22.1 {Tcl_BinaryObjCmd: scan} {
   685     list [catch {binary scan abc b} msg] $msg
   686 } {1 {not enough arguments for all format specifiers}}
   687 test binary-22.2 {Tcl_BinaryObjCmd: scan} {
   688     catch {unset arg1}
   689     list [binary scan \x52\x53 b* arg1] $arg1
   690 } {1 0100101011001010}
   691 test binary-22.3 {Tcl_BinaryObjCmd: scan} {
   692     catch {unset arg1}
   693     list [binary scan \x82\x53 b arg1] $arg1
   694 } {1 0}
   695 test binary-22.4 {Tcl_BinaryObjCmd: scan} {
   696     catch {unset arg1}
   697     list [binary scan \x82\x53 b1 arg1] $arg1
   698 } {1 0}
   699 test binary-22.5 {Tcl_BinaryObjCmd: scan} {
   700     catch {unset arg1}
   701     list [binary scan \x82\x53 b0 arg1] $arg1
   702 } {1 {}}
   703 test binary-22.6 {Tcl_BinaryObjCmd: scan} {
   704     catch {unset arg1}
   705     list [binary scan \x52\x53 b5 arg1] $arg1
   706 } {1 01001}
   707 test binary-22.7 {Tcl_BinaryObjCmd: scan} {
   708     catch {unset arg1}
   709     list [binary scan \x52\x53 b8 arg1] $arg1
   710 } {1 01001010}
   711 test binary-22.8 {Tcl_BinaryObjCmd: scan} {
   712     catch {unset arg1}
   713     list [binary scan \x52\x53 b14 arg1] $arg1
   714 } {1 01001010110010}
   715 test binary-22.9 {Tcl_BinaryObjCmd: scan} {
   716     catch {unset arg1}
   717     set arg1 foo
   718     list [binary scan \x52 b14 arg1] $arg1
   719 } {0 foo}
   720 test binary-22.10 {Tcl_BinaryObjCmd: scan} {
   721     catch {unset arg1}
   722     set arg1 1
   723     list [catch {binary scan \x52\x53 b1 arg1(a)} msg] $msg
   724 } {1 {can't set "arg1(a)": variable isn't array}}
   725 test binary-22.11 {Tcl_BinaryObjCmd: scan} {
   726     catch {unset arg1 arg2}
   727     set arg1 foo
   728     set arg2 bar
   729     list [binary scan \x07\x87\x05 b5b* arg1 arg2] $arg1 $arg2
   730 } {2 11100 1110000110100000}
   731 
   732 
   733 test binary-23.1 {Tcl_BinaryObjCmd: scan} {
   734     list [catch {binary scan abc B} msg] $msg
   735 } {1 {not enough arguments for all format specifiers}}
   736 test binary-23.2 {Tcl_BinaryObjCmd: scan} {
   737     catch {unset arg1}
   738     list [binary scan \x52\x53 B* arg1] $arg1
   739 } {1 0101001001010011}
   740 test binary-23.3 {Tcl_BinaryObjCmd: scan} {
   741     catch {unset arg1}
   742     list [binary scan \x82\x53 B arg1] $arg1
   743 } {1 1}
   744 test binary-23.4 {Tcl_BinaryObjCmd: scan} {
   745     catch {unset arg1}
   746     list [binary scan \x82\x53 B1 arg1] $arg1
   747 } {1 1}
   748 test binary-23.5 {Tcl_BinaryObjCmd: scan} {
   749     catch {unset arg1}
   750     list [binary scan \x52\x53 B0 arg1] $arg1
   751 } {1 {}}
   752 test binary-23.6 {Tcl_BinaryObjCmd: scan} {
   753     catch {unset arg1}
   754     list [binary scan \x52\x53 B5 arg1] $arg1
   755 } {1 01010}
   756 test binary-23.7 {Tcl_BinaryObjCmd: scan} {
   757     catch {unset arg1}
   758     list [binary scan \x52\x53 B8 arg1] $arg1
   759 } {1 01010010}
   760 test binary-23.8 {Tcl_BinaryObjCmd: scan} {
   761     catch {unset arg1}
   762     list [binary scan \x52\x53 B14 arg1] $arg1
   763 } {1 01010010010100}
   764 test binary-23.9 {Tcl_BinaryObjCmd: scan} {
   765     catch {unset arg1}
   766     set arg1 foo
   767     list [binary scan \x52 B14 arg1] $arg1
   768 } {0 foo}
   769 test binary-23.10 {Tcl_BinaryObjCmd: scan} {
   770     catch {unset arg1}
   771     set arg1 1
   772     list [catch {binary scan \x52\x53 B1 arg1(a)} msg] $msg
   773 } {1 {can't set "arg1(a)": variable isn't array}}
   774 test binary-23.11 {Tcl_BinaryObjCmd: scan} {
   775     catch {unset arg1 arg2}
   776     set arg1 foo
   777     set arg2 bar
   778     list [binary scan \x70\x87\x05 B5B* arg1 arg2] $arg1 $arg2
   779 } {2 01110 1000011100000101}
   780 
   781 test binary-24.1 {Tcl_BinaryObjCmd: scan} {
   782     list [catch {binary scan abc h} msg] $msg
   783 } {1 {not enough arguments for all format specifiers}}
   784 test binary-24.2 {Tcl_BinaryObjCmd: scan} {
   785     catch {unset arg1}
   786     list [binary scan \x52\xa3 h* arg1] $arg1
   787 } {1 253a}
   788 test binary-24.3 {Tcl_BinaryObjCmd: scan} {
   789     catch {unset arg1}
   790     list [binary scan \xc2\xa3 h arg1] $arg1
   791 } {1 2}
   792 test binary-24.4 {Tcl_BinaryObjCmd: scan} {
   793     catch {unset arg1}
   794     list [binary scan \x82\x53 h1 arg1] $arg1
   795 } {1 2}
   796 test binary-24.5 {Tcl_BinaryObjCmd: scan} {
   797     catch {unset arg1}
   798     list [binary scan \x52\x53 h0 arg1] $arg1
   799 } {1 {}}
   800 test binary-24.6 {Tcl_BinaryObjCmd: scan} {
   801     catch {unset arg1}
   802     list [binary scan \xf2\x53 h2 arg1] $arg1
   803 } {1 2f}
   804 test binary-24.7 {Tcl_BinaryObjCmd: scan} {
   805     catch {unset arg1}
   806     list [binary scan \x52\x53 h3 arg1] $arg1
   807 } {1 253}
   808 test binary-24.8 {Tcl_BinaryObjCmd: scan} {
   809     catch {unset arg1}
   810     set arg1 foo
   811     list [binary scan \x52 h3 arg1] $arg1
   812 } {0 foo}
   813 test binary-24.9 {Tcl_BinaryObjCmd: scan} {
   814     catch {unset arg1}
   815     set arg1 1
   816     list [catch {binary scan \x52\x53 h1 arg1(a)} msg] $msg
   817 } {1 {can't set "arg1(a)": variable isn't array}}
   818 test binary-24.10 {Tcl_BinaryObjCmd: scan} {
   819     catch {unset arg1 arg2}
   820     set arg1 foo
   821     set arg2 bar
   822     list [binary scan \x70\x87\x05 h2h* arg1 arg2] $arg1 $arg2
   823 } {2 07 7850}
   824 
   825 test binary-25.1 {Tcl_BinaryObjCmd: scan} {
   826     list [catch {binary scan abc H} msg] $msg
   827 } {1 {not enough arguments for all format specifiers}}
   828 test binary-25.2 {Tcl_BinaryObjCmd: scan} {
   829     catch {unset arg1}
   830     list [binary scan \x52\xa3 H* arg1] $arg1
   831 } {1 52a3}
   832 test binary-25.3 {Tcl_BinaryObjCmd: scan} {
   833     catch {unset arg1}
   834     list [binary scan \xc2\xa3 H arg1] $arg1
   835 } {1 c}
   836 test binary-25.4 {Tcl_BinaryObjCmd: scan} {
   837     catch {unset arg1}
   838     list [binary scan \x82\x53 H1 arg1] $arg1
   839 } {1 8}
   840 test binary-25.5 {Tcl_BinaryObjCmd: scan} {
   841     catch {unset arg1}
   842     list [binary scan \x52\x53 H0 arg1] $arg1
   843 } {1 {}}
   844 test binary-25.6 {Tcl_BinaryObjCmd: scan} {
   845     catch {unset arg1}
   846     list [binary scan \xf2\x53 H2 arg1] $arg1
   847 } {1 f2}
   848 test binary-25.7 {Tcl_BinaryObjCmd: scan} {
   849     catch {unset arg1}
   850     list [binary scan \x52\x53 H3 arg1] $arg1
   851 } {1 525}
   852 test binary-25.8 {Tcl_BinaryObjCmd: scan} {
   853     catch {unset arg1}
   854     set arg1 foo
   855     list [binary scan \x52 H3 arg1] $arg1
   856 } {0 foo}
   857 test binary-25.9 {Tcl_BinaryObjCmd: scan} {
   858     catch {unset arg1}
   859     set arg1 1
   860     list [catch {binary scan \x52\x53 H1 arg1(a)} msg] $msg
   861 } {1 {can't set "arg1(a)": variable isn't array}}
   862 test binary-25.10 {Tcl_BinaryObjCmd: scan} {
   863     catch {unset arg1 arg2}
   864     set arg1 foo
   865     set arg2 bar
   866     list [binary scan \x70\x87\x05 H2H* arg1 arg2] $arg1 $arg2
   867 } {2 70 8705}
   868 
   869 test binary-26.1 {Tcl_BinaryObjCmd: scan} {
   870     list [catch {binary scan abc c} msg] $msg
   871 } {1 {not enough arguments for all format specifiers}}
   872 test binary-26.2 {Tcl_BinaryObjCmd: scan} {
   873     catch {unset arg1}
   874     list [binary scan \x52\xa3 c* arg1] $arg1
   875 } {1 {82 -93}}
   876 test binary-26.3 {Tcl_BinaryObjCmd: scan} {
   877     catch {unset arg1}
   878     list [binary scan \x52\xa3 c arg1] $arg1
   879 } {1 82}
   880 test binary-26.4 {Tcl_BinaryObjCmd: scan} {
   881     catch {unset arg1}
   882     list [binary scan \x52\xa3 c1 arg1] $arg1
   883 } {1 82}
   884 test binary-26.5 {Tcl_BinaryObjCmd: scan} {
   885     catch {unset arg1}
   886     list [binary scan \x52\xa3 c0 arg1] $arg1
   887 } {1 {}}
   888 test binary-26.6 {Tcl_BinaryObjCmd: scan} {
   889     catch {unset arg1}
   890     list [binary scan \x52\xa3 c2 arg1] $arg1
   891 } {1 {82 -93}}
   892 test binary-26.7 {Tcl_BinaryObjCmd: scan} {
   893     catch {unset arg1}
   894     list [binary scan \xff c arg1] $arg1
   895 } {1 -1}
   896 test binary-26.8 {Tcl_BinaryObjCmd: scan} {
   897     catch {unset arg1}
   898     set arg1 foo
   899     list [binary scan \x52 c3 arg1] $arg1
   900 } {0 foo}
   901 test binary-26.9 {Tcl_BinaryObjCmd: scan} {
   902     catch {unset arg1}
   903     set arg1 1
   904     list [catch {binary scan \x52\x53 c1 arg1(a)} msg] $msg
   905 } {1 {can't set "arg1(a)": variable isn't array}}
   906 test binary-26.10 {Tcl_BinaryObjCmd: scan} {
   907     catch {unset arg1 arg2}
   908     set arg1 foo
   909     set arg2 bar
   910     list [binary scan \x70\x87\x05 c2c* arg1 arg2] $arg1 $arg2
   911 } {2 {112 -121} 5}
   912 
   913 test binary-27.1 {Tcl_BinaryObjCmd: scan} {
   914     list [catch {binary scan abc s} msg] $msg
   915 } {1 {not enough arguments for all format specifiers}}
   916 test binary-27.2 {Tcl_BinaryObjCmd: scan} {
   917     catch {unset arg1}
   918     list [binary scan \x52\xa3\x53\x54 s* arg1] $arg1
   919 } {1 {-23726 21587}}
   920 test binary-27.3 {Tcl_BinaryObjCmd: scan} {
   921     catch {unset arg1}
   922     list [binary scan \x52\xa3\x53\x54 s arg1] $arg1
   923 } {1 -23726}
   924 test binary-27.4 {Tcl_BinaryObjCmd: scan} {
   925     catch {unset arg1}
   926     list [binary scan \x52\xa3 s1 arg1] $arg1
   927 } {1 -23726}
   928 test binary-27.5 {Tcl_BinaryObjCmd: scan} {
   929     catch {unset arg1}
   930     list [binary scan \x52\xa3 s0 arg1] $arg1
   931 } {1 {}}
   932 test binary-27.6 {Tcl_BinaryObjCmd: scan} {
   933     catch {unset arg1}
   934     list [binary scan \x52\xa3\x53\x54 s2 arg1] $arg1
   935 } {1 {-23726 21587}}
   936 test binary-27.7 {Tcl_BinaryObjCmd: scan} {
   937     catch {unset arg1}
   938     set arg1 foo
   939     list [binary scan \x52 s1 arg1] $arg1
   940 } {0 foo}
   941 test binary-27.8 {Tcl_BinaryObjCmd: scan} {
   942     catch {unset arg1}
   943     set arg1 1
   944     list [catch {binary scan \x52\x53 s1 arg1(a)} msg] $msg
   945 } {1 {can't set "arg1(a)": variable isn't array}}
   946 test binary-27.9 {Tcl_BinaryObjCmd: scan} {
   947     catch {unset arg1 arg2}
   948     set arg1 foo
   949     set arg2 bar
   950     list [binary scan \x52\xa3\x53\x54\x05 s2c* arg1 arg2] $arg1 $arg2
   951 } {2 {-23726 21587} 5}
   952 
   953 test binary-28.1 {Tcl_BinaryObjCmd: scan} {
   954     list [catch {binary scan abc S} msg] $msg
   955 } {1 {not enough arguments for all format specifiers}}
   956 test binary-28.2 {Tcl_BinaryObjCmd: scan} {
   957     catch {unset arg1}
   958     list [binary scan \x52\xa3\x53\x54 S* arg1] $arg1
   959 } {1 {21155 21332}}
   960 test binary-28.3 {Tcl_BinaryObjCmd: scan} {
   961     catch {unset arg1}
   962     list [binary scan \x52\xa3\x53\x54 S arg1] $arg1
   963 } {1 21155}
   964 test binary-28.4 {Tcl_BinaryObjCmd: scan} {
   965     catch {unset arg1}
   966     list [binary scan \x52\xa3 S1 arg1] $arg1
   967 } {1 21155}
   968 test binary-28.5 {Tcl_BinaryObjCmd: scan} {
   969     catch {unset arg1}
   970     list [binary scan \x52\xa3 S0 arg1] $arg1
   971 } {1 {}}
   972 test binary-28.6 {Tcl_BinaryObjCmd: scan} {
   973     catch {unset arg1}
   974     list [binary scan \x52\xa3\x53\x54 S2 arg1] $arg1
   975 } {1 {21155 21332}}
   976 test binary-28.7 {Tcl_BinaryObjCmd: scan} {
   977     catch {unset arg1}
   978     set arg1 foo
   979     list [binary scan \x52 S1 arg1] $arg1
   980 } {0 foo}
   981 test binary-28.8 {Tcl_BinaryObjCmd: scan} {
   982     catch {unset arg1}
   983     set arg1 1
   984     list [catch {binary scan \x52\x53 S1 arg1(a)} msg] $msg
   985 } {1 {can't set "arg1(a)": variable isn't array}}
   986 test binary-28.9 {Tcl_BinaryObjCmd: scan} {
   987     catch {unset arg1 arg2}
   988     set arg1 foo
   989     set arg2 bar
   990     list [binary scan \x52\xa3\x53\x54\x05 S2c* arg1 arg2] $arg1 $arg2
   991 } {2 {21155 21332} 5}
   992 
   993 test binary-29.1 {Tcl_BinaryObjCmd: scan} {
   994     list [catch {binary scan abc i} msg] $msg
   995 } {1 {not enough arguments for all format specifiers}}
   996 test binary-29.2 {Tcl_BinaryObjCmd: scan} {
   997     catch {unset arg1}
   998     list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 i* arg1] $arg1
   999 } {1 {1414767442 67305985}}
  1000 test binary-29.3 {Tcl_BinaryObjCmd: scan} {
  1001     catch {unset arg1}
  1002     list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 i arg1] $arg1
  1003 } {1 1414767442}
  1004 test binary-29.4 {Tcl_BinaryObjCmd: scan} {
  1005     catch {unset arg1}
  1006     list [binary scan \x52\xa3\x53\x54 i1 arg1] $arg1
  1007 } {1 1414767442}
  1008 test binary-29.5 {Tcl_BinaryObjCmd: scan} {
  1009     catch {unset arg1}
  1010     list [binary scan \x52\xa3\x53 i0 arg1] $arg1
  1011 } {1 {}}
  1012 test binary-29.6 {Tcl_BinaryObjCmd: scan} {
  1013     catch {unset arg1}
  1014     list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 i2 arg1] $arg1
  1015 } {1 {1414767442 67305985}}
  1016 test binary-29.7 {Tcl_BinaryObjCmd: scan} {
  1017     catch {unset arg1}
  1018     set arg1 foo
  1019     list [binary scan \x52 i1 arg1] $arg1
  1020 } {0 foo}
  1021 test binary-29.8 {Tcl_BinaryObjCmd: scan} {
  1022     catch {unset arg1}
  1023     set arg1 1
  1024     list [catch {binary scan \x52\x53\x53\x54 i1 arg1(a)} msg] $msg
  1025 } {1 {can't set "arg1(a)": variable isn't array}}
  1026 test binary-29.9 {Tcl_BinaryObjCmd: scan} {
  1027     catch {unset arg1 arg2}
  1028     set arg1 foo
  1029     set arg2 bar
  1030     list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04\x05 i2c* arg1 arg2] $arg1 $arg2
  1031 } {2 {1414767442 67305985} 5}
  1032 
  1033 test binary-30.1 {Tcl_BinaryObjCmd: scan} {
  1034     list [catch {binary scan abc I} msg] $msg
  1035 } {1 {not enough arguments for all format specifiers}}
  1036 test binary-30.2 {Tcl_BinaryObjCmd: scan} {
  1037     catch {unset arg1}
  1038     list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 I* arg1] $arg1
  1039 } {1 {1386435412 16909060}}
  1040 test binary-30.3 {Tcl_BinaryObjCmd: scan} {
  1041     catch {unset arg1}
  1042     list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 I arg1] $arg1
  1043 } {1 1386435412}
  1044 test binary-30.4 {Tcl_BinaryObjCmd: scan} {
  1045     catch {unset arg1}
  1046     list [binary scan \x52\xa3\x53\x54 I1 arg1] $arg1
  1047 } {1 1386435412}
  1048 test binary-30.5 {Tcl_BinaryObjCmd: scan} {
  1049     catch {unset arg1}
  1050     list [binary scan \x52\xa3\x53 I0 arg1] $arg1
  1051 } {1 {}}
  1052 test binary-30.6 {Tcl_BinaryObjCmd: scan} {
  1053     catch {unset arg1}
  1054     list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 I2 arg1] $arg1
  1055 } {1 {1386435412 16909060}}
  1056 test binary-30.7 {Tcl_BinaryObjCmd: scan} {
  1057     catch {unset arg1}
  1058     set arg1 foo
  1059     list [binary scan \x52 I1 arg1] $arg1
  1060 } {0 foo}
  1061 test binary-30.8 {Tcl_BinaryObjCmd: scan} {
  1062     catch {unset arg1}
  1063     set arg1 1
  1064     list [catch {binary scan \x52\x53\x53\x54 I1 arg1(a)} msg] $msg
  1065 } {1 {can't set "arg1(a)": variable isn't array}}
  1066 test binary-30.9 {Tcl_BinaryObjCmd: scan} {
  1067     catch {unset arg1 arg2}
  1068     set arg1 foo
  1069     set arg2 bar
  1070     list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04\x05 I2c* arg1 arg2] $arg1 $arg2
  1071 } {2 {1386435412 16909060} 5}
  1072 
  1073 test binary-31.1 {Tcl_BinaryObjCmd: scan} {
  1074     list [catch {binary scan abc f} msg] $msg
  1075 } {1 {not enough arguments for all format specifiers}}
  1076 test binary-31.2 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
  1077     catch {unset arg1}
  1078     list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a f* arg1] $arg1
  1079 } {1 {1.60000002384 3.40000009537}}
  1080 test binary-31.3 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
  1081     catch {unset arg1}
  1082     list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 f* arg1] $arg1
  1083 } {1 {1.60000002384 3.40000009537}}
  1084 test binary-31.4 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
  1085     catch {unset arg1}
  1086     list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a f arg1] $arg1
  1087 } {1 1.60000002384}
  1088 test binary-31.5 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
  1089     catch {unset arg1}
  1090     list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 f arg1] $arg1
  1091 } {1 1.60000002384}
  1092 test binary-31.6 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
  1093     catch {unset arg1}
  1094     list [binary scan \x3f\xcc\xcc\xcd f1 arg1] $arg1
  1095 } {1 1.60000002384}
  1096 test binary-31.7 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
  1097     catch {unset arg1}
  1098     list [binary scan \xcd\xcc\xcc\x3f f1 arg1] $arg1
  1099 } {1 1.60000002384}
  1100 test binary-31.8 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
  1101     catch {unset arg1}
  1102     list [binary scan \x3f\xcc\xcc\xcd f0 arg1] $arg1
  1103 } {1 {}}
  1104 test binary-31.9 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
  1105     catch {unset arg1}
  1106     list [binary scan \xcd\xcc\xcc\x3f f0 arg1] $arg1
  1107 } {1 {}}
  1108 test binary-31.10 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
  1109     catch {unset arg1}
  1110     list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a f2 arg1] $arg1
  1111 } {1 {1.60000002384 3.40000009537}}
  1112 test binary-31.11 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
  1113     catch {unset arg1}
  1114     list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 f2 arg1] $arg1
  1115 } {1 {1.60000002384 3.40000009537}}
  1116 test binary-31.12 {Tcl_BinaryObjCmd: scan} {
  1117     catch {unset arg1}
  1118     set arg1 foo
  1119     list [binary scan \x52 f1 arg1] $arg1
  1120 } {0 foo}
  1121 test binary-31.13 {Tcl_BinaryObjCmd: scan} {
  1122     catch {unset arg1}
  1123     set arg1 1
  1124     list [catch {binary scan \x3f\xcc\xcc\xcd f1 arg1(a)} msg] $msg
  1125 } {1 {can't set "arg1(a)": variable isn't array}}
  1126 test binary-31.14 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
  1127     catch {unset arg1 arg2}
  1128     set arg1 foo
  1129     set arg2 bar
  1130     list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a\x05 f2c* arg1 arg2] $arg1 $arg2
  1131 } {2 {1.60000002384 3.40000009537} 5}
  1132 test binary-31.15 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
  1133     catch {unset arg1 arg2}
  1134     set arg1 foo
  1135     set arg2 bar
  1136     list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40\x05 f2c* arg1 arg2] $arg1 $arg2
  1137 } {2 {1.60000002384 3.40000009537} 5}
  1138 
  1139 test binary-32.1 {Tcl_BinaryObjCmd: scan} {
  1140     list [catch {binary scan abc d} msg] $msg
  1141 } {1 {not enough arguments for all format specifiers}}
  1142 test binary-32.2 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
  1143     catch {unset arg1}
  1144     list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 d* arg1] $arg1
  1145 } {1 {1.6 3.4}}
  1146 test binary-32.3 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
  1147     catch {unset arg1}
  1148     list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 d* arg1] $arg1
  1149 } {1 {1.6 3.4}}
  1150 test binary-32.4 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
  1151     catch {unset arg1}
  1152     list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 d arg1] $arg1
  1153 } {1 1.6}
  1154 test binary-32.5 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
  1155     catch {unset arg1}
  1156     list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 d arg1] $arg1
  1157 } {1 1.6}
  1158 test binary-32.6 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
  1159     catch {unset arg1}
  1160     list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a d1 arg1] $arg1
  1161 } {1 1.6}
  1162 test binary-32.7 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
  1163     catch {unset arg1}
  1164     list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f d1 arg1] $arg1
  1165 } {1 1.6}
  1166 test binary-32.8 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
  1167     catch {unset arg1}
  1168     list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a d0 arg1] $arg1
  1169 } {1 {}}
  1170 test binary-32.9 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
  1171     catch {unset arg1}
  1172     list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f d0 arg1] $arg1
  1173 } {1 {}}
  1174 test binary-32.10 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
  1175     catch {unset arg1}
  1176     list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 d2 arg1] $arg1
  1177 } {1 {1.6 3.4}}
  1178 test binary-32.11 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
  1179     catch {unset arg1}
  1180     list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 d2 arg1] $arg1
  1181 } {1 {1.6 3.4}}
  1182 test binary-32.12 {Tcl_BinaryObjCmd: scan} {
  1183     catch {unset arg1}
  1184     set arg1 foo
  1185     list [binary scan \x52 d1 arg1] $arg1
  1186 } {0 foo}
  1187 test binary-32.13 {Tcl_BinaryObjCmd: scan} {
  1188     catch {unset arg1}
  1189     set arg1 1
  1190     list [catch {binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a d1 arg1(a)} msg] $msg
  1191 } {1 {can't set "arg1(a)": variable isn't array}}
  1192 test binary-32.14 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
  1193     catch {unset arg1 arg2}
  1194     set arg1 foo
  1195     set arg2 bar
  1196     list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33\x05 d2c* arg1 arg2] $arg1 $arg2
  1197 } {2 {1.6 3.4} 5}
  1198 test binary-32.15 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
  1199     catch {unset arg1 arg2}
  1200     set arg1 foo
  1201     set arg2 bar
  1202     list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40\x05 d2c* arg1 arg2] $arg1 $arg2
  1203 } {2 {1.6 3.4} 5}
  1204 
  1205 test binary-33.1 {Tcl_BinaryObjCmd: scan} {
  1206     catch {unset arg1}
  1207     catch {unset arg2}
  1208     list [binary scan abcdefg a2xa3 arg1 arg2] $arg1 $arg2
  1209 } {2 ab def}
  1210 test binary-33.2 {Tcl_BinaryObjCmd: scan} {
  1211     catch {unset arg1}
  1212     catch {unset arg2}
  1213     set arg2 foo
  1214     list [binary scan abcdefg a3x*a3 arg1 arg2] $arg1 $arg2
  1215 } {1 abc foo}
  1216 test binary-33.3 {Tcl_BinaryObjCmd: scan} {
  1217     catch {unset arg1}
  1218     catch {unset arg2}
  1219     set arg2 foo
  1220     list [binary scan abcdefg a3x20a3 arg1 arg2] $arg1 $arg2
  1221 } {1 abc foo}
  1222 test binary-33.4 {Tcl_BinaryObjCmd: scan} {
  1223     catch {unset arg1}
  1224     catch {unset arg2}
  1225     set arg2 foo
  1226     list [binary scan abc a3x20a3 arg1 arg2] $arg1 $arg2
  1227 } {1 abc foo}
  1228 test binary-33.5 {Tcl_BinaryObjCmd: scan} {
  1229     catch {unset arg1}
  1230     list [binary scan abcdef x1a1 arg1] $arg1
  1231 } {1 b}
  1232 test binary-33.6 {Tcl_BinaryObjCmd: scan} {
  1233     catch {unset arg1}
  1234     list [binary scan abcdef x5a1 arg1] $arg1
  1235 } {1 f}
  1236 test binary-33.7 {Tcl_BinaryObjCmd: scan} {
  1237     catch {unset arg1}
  1238     list [binary scan abcdef x0a1 arg1] $arg1
  1239 } {1 a}
  1240 
  1241 test binary-34.1 {Tcl_BinaryObjCmd: scan} {
  1242     catch {unset arg1}
  1243     catch {unset arg2}
  1244     list [binary scan abcdefg a2Xa3 arg1 arg2] $arg1 $arg2
  1245 } {2 ab bcd}
  1246 test binary-34.2 {Tcl_BinaryObjCmd: scan} {
  1247     catch {unset arg1}
  1248     catch {unset arg2}
  1249     set arg2 foo
  1250     list [binary scan abcdefg a3X*a3 arg1 arg2] $arg1 $arg2
  1251 } {2 abc abc}
  1252 test binary-34.3 {Tcl_BinaryObjCmd: scan} {
  1253     catch {unset arg1}
  1254     catch {unset arg2}
  1255     set arg2 foo
  1256     list [binary scan abcdefg a3X20a3 arg1 arg2] $arg1 $arg2
  1257 } {2 abc abc}
  1258 test binary-34.4 {Tcl_BinaryObjCmd: scan} {
  1259     catch {unset arg1}
  1260     list [binary scan abc X20a3 arg1] $arg1
  1261 } {1 abc}
  1262 test binary-34.5 {Tcl_BinaryObjCmd: scan} {
  1263     catch {unset arg1}
  1264     list [binary scan abcdef x*X1a1 arg1] $arg1
  1265 } {1 f}
  1266 test binary-34.6 {Tcl_BinaryObjCmd: scan} {
  1267     catch {unset arg1}
  1268     list [binary scan abcdef x*X5a1 arg1] $arg1
  1269 } {1 b}
  1270 test binary-34.7 {Tcl_BinaryObjCmd: scan} {
  1271     catch {unset arg1}
  1272     list [binary scan abcdef x3X0a1 arg1] $arg1
  1273 } {1 d}
  1274 
  1275 test binary-35.1 {Tcl_BinaryObjCmd: scan} {
  1276     catch {unset arg1}
  1277     catch {unset arg2}
  1278     list [catch {binary scan abcdefg a2@a3 arg1 arg2} msg] $msg
  1279 } {1 {missing count for "@" field specifier}}
  1280 test binary-35.2 {Tcl_BinaryObjCmd: scan} {
  1281     catch {unset arg1}
  1282     catch {unset arg2}
  1283     set arg2 foo
  1284     list [binary scan abcdefg a3@*a3 arg1 arg2] $arg1 $arg2
  1285 } {1 abc foo}
  1286 test binary-35.3 {Tcl_BinaryObjCmd: scan} {
  1287     catch {unset arg1}
  1288     catch {unset arg2}
  1289     set arg2 foo
  1290     list [binary scan abcdefg a3@20a3 arg1 arg2] $arg1 $arg2
  1291 } {1 abc foo}
  1292 test binary-35.4 {Tcl_BinaryObjCmd: scan} {
  1293     catch {unset arg1}
  1294     list [binary scan abcdef @2a3 arg1] $arg1
  1295 } {1 cde}
  1296 test binary-35.5 {Tcl_BinaryObjCmd: scan} {
  1297     catch {unset arg1}
  1298     list [binary scan abcdef x*@1a1 arg1] $arg1
  1299 } {1 b}
  1300 test binary-35.6 {Tcl_BinaryObjCmd: scan} {
  1301     catch {unset arg1}
  1302     list [binary scan abcdef x*@0a1 arg1] $arg1
  1303 } {1 a}
  1304 
  1305 test binary-36.1 {Tcl_BinaryObjCmd: scan} {
  1306     list [catch {binary scan abcdef u0a3} msg] $msg
  1307 } {1 {bad field specifier "u"}}
  1308 
  1309 # GetFormatSpec is pretty thoroughly tested above, but there are a few
  1310 # cases we should text explicitly
  1311 
  1312 test binary-37.1 {GetFormatSpec: whitespace} {
  1313     binary format "a3 a5     a3" foo barblat baz
  1314 } foobarblbaz
  1315 test binary-37.2 {GetFormatSpec: whitespace} {
  1316     binary format "      " foo
  1317 } {}
  1318 test binary-37.3 {GetFormatSpec: whitespace} {
  1319     binary format "     a3" foo
  1320 } foo
  1321 test binary-37.4 {GetFormatSpec: whitespace} {
  1322     binary format "" foo
  1323 } {}
  1324 test binary-37.5 {GetFormatSpec: whitespace} {
  1325     binary format "" foo
  1326 } {}
  1327 test binary-37.6 {GetFormatSpec: whitespace} {
  1328     binary format "     a3   " foo
  1329 } foo
  1330 test binary-37.7 {GetFormatSpec: numbers} {
  1331     list [catch {binary scan abcdef "x-1" foo} msg] $msg
  1332 } {1 {bad field specifier "-"}}
  1333 test binary-37.8 {GetFormatSpec: numbers} {
  1334     catch {unset arg1}
  1335     set arg1 foo
  1336     list [binary scan abcdef "a0x3" arg1] $arg1
  1337 } {1 {}}
  1338 test binary-37.9 {GetFormatSpec: numbers} {
  1339     # test format of neg numbers
  1340     # bug report/fix provided by Harald Kirsch
  1341     set x [binary format f* {1 -1 2 -2 0}]
  1342     binary scan $x f* bla
  1343     set bla
  1344 } {1.0 -1.0 2.0 -2.0 0.0}
  1345 
  1346 test binary-38.1 {FormatNumber: word alignment} {
  1347     set x [binary format c1s1 1 1]
  1348 } \x01\x01\x00
  1349 test binary-38.2 {FormatNumber: word alignment} {
  1350     set x [binary format c1S1 1 1]
  1351 } \x01\x00\x01
  1352 test binary-38.3 {FormatNumber: word alignment} {
  1353     set x [binary format c1i1 1 1]
  1354 } \x01\x01\x00\x00\x00
  1355 test binary-38.4 {FormatNumber: word alignment} {
  1356     set x [binary format c1I1 1 1]
  1357 } \x01\x00\x00\x00\x01
  1358 test binary-38.5 {FormatNumber: word alignment} {nonPortable macOrUnix} {
  1359     set x [binary format c1d1 1 1.6]
  1360 } \x01\x3f\xf9\x99\x99\x99\x99\x99\x9a
  1361 test binary-38.6 {FormatNumber: word alignment} {nonPortable pcOnly} {
  1362     set x [binary format c1d1 1 1.6]
  1363 } \x01\x9a\x99\x99\x99\x99\x99\xf9\x3f
  1364 test binary-38.7 {FormatNumber: word alignment} {nonPortable macOrUnix} {
  1365     set x [binary format c1f1 1 1.6]
  1366 } \x01\x3f\xcc\xcc\xcd
  1367 test binary-38.8 {FormatNumber: word alignment} {nonPortable pcOnly} {
  1368     set x [binary format c1f1 1 1.6]
  1369 } \x01\xcd\xcc\xcc\x3f
  1370 
  1371 test binary-39.1 {ScanNumber: sign extension} {
  1372     catch {unset arg1}
  1373     list [binary scan \x52\xa3 c2 arg1] $arg1
  1374 } {1 {82 -93}}
  1375 test binary-39.2 {ScanNumber: sign extension} {
  1376     catch {unset arg1}
  1377     list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 s4 arg1] $arg1
  1378 } {1 {513 -32511 386 -32127}}
  1379 test binary-39.3 {ScanNumber: sign extension} {
  1380     catch {unset arg1}
  1381     list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 S4 arg1] $arg1
  1382 } {1 {258 385 -32255 -32382}}
  1383 test binary-39.4 {ScanNumber: sign extension} {
  1384     catch {unset arg1}
  1385     list [binary scan \x01\x01\x01\x02\x81\x01\x01\x01\x01\x82\x01\x01\x01\x01\x82\x01\x01\x01\x01\x81 i5 arg1] $arg1
  1386 } {1 {33620225 16843137 16876033 25297153 -2130640639}}
  1387 test binary-39.5 {ScanNumber: sign extension} {
  1388     catch {unset arg1}
  1389     list [binary scan \x01\x01\x01\x02\x81\x01\x01\x01\x01\x82\x01\x01\x01\x01\x82\x01\x01\x01\x01\x81 I5 arg1] $arg1
  1390 } {1 {16843010 -2130640639 25297153 16876033 16843137}}
  1391 
  1392 test binary-40.1 {ScanNumber: floating point overflow} {nonPortable unixOnly} {
  1393     catch {unset arg1}
  1394     list [binary scan \xff\xff\xff\xff f1 arg1] $arg1
  1395 } {1 -NaN}
  1396 test binary-40.2 {ScanNumber: floating point overflow} {nonPortable macOnly} {
  1397     catch {unset arg1}
  1398     list [binary scan \xff\xff\xff\xff f1 arg1] $arg1
  1399 } {1 -NAN(255)}
  1400 test binary-40.3 {ScanNumber: floating point overflow} {nonPortable pcOnly} {
  1401     catch {unset arg1}
  1402     set result [binary scan \xff\xff\xff\xff f1 arg1]
  1403     if {([string compare $arg1 -1.\#QNAN] == 0)
  1404 	|| ([string compare $arg1 -NAN] == 0)} {
  1405 	lappend result success
  1406     } else {
  1407 	lappend result failure
  1408     }
  1409 } {1 success}
  1410 test binary-40.4 {ScanNumber: floating point overflow} {nonPortable unixOnly} {
  1411     catch {unset arg1}
  1412     list [binary scan \xff\xff\xff\xff\xff\xff\xff\xff d1 arg1] $arg1
  1413 } {1 -NaN}
  1414 test binary-40.5 {ScanNumber: floating point overflow} {nonPortable macOnly} {
  1415     catch {unset arg1}
  1416     list [binary scan \xff\xff\xff\xff\xff\xff\xff\xff d1 arg1] $arg1
  1417 } {1 -NAN(255)}
  1418 test binary-40.6 {ScanNumber: floating point overflow} {nonPortable pcOnly} {
  1419     catch {unset arg1}
  1420     set result [binary scan \xff\xff\xff\xff\xff\xff\xff\xff d1 arg1]
  1421     if {([string compare $arg1 -1.\#QNAN] == 0)
  1422 	|| ([string compare $arg1 -NAN] == 0)} {
  1423 	lappend result success
  1424     } else {
  1425 	lappend result failure
  1426     }
  1427 } {1 success}
  1428 
  1429 test binary-41.1 {ScanNumber: word alignment} {
  1430     catch {unset arg1; unset arg2}
  1431     list [binary scan \x01\x01\x00 c1s1 arg1 arg2] $arg1 $arg2
  1432 } {2 1 1}
  1433 test binary-41.2 {ScanNumber: word alignment} {
  1434     catch {unset arg1; unset arg2}
  1435     list [binary scan \x01\x00\x01 c1S1 arg1 arg2] $arg1 $arg2
  1436 } {2 1 1}
  1437 test binary-41.3 {ScanNumber: word alignment} {
  1438     catch {unset arg1; unset arg2}
  1439     list [binary scan \x01\x01\x00\x00\x00 c1i1 arg1 arg2] $arg1 $arg2
  1440 } {2 1 1}
  1441 test binary-41.4 {ScanNumber: word alignment} {
  1442     catch {unset arg1; unset arg2}
  1443     list [binary scan \x01\x00\x00\x00\x01 c1I1 arg1 arg2] $arg1 $arg2
  1444 } {2 1 1}
  1445 test binary-41.5 {ScanNumber: word alignment} {nonPortable macOrUnix} {
  1446     catch {unset arg1; unset arg2}
  1447     list [binary scan \x01\x3f\xcc\xcc\xcd c1f1 arg1 arg2] $arg1 $arg2
  1448 } {2 1 1.60000002384}
  1449 test binary-41.6 {ScanNumber: word alignment} {nonPortable pcOnly} {
  1450     catch {unset arg1; unset arg2}
  1451     list [binary scan \x01\xcd\xcc\xcc\x3f c1f1 arg1 arg2] $arg1 $arg2
  1452 } {2 1 1.60000002384}
  1453 test binary-41.7 {ScanNumber: word alignment} {nonPortable macOrUnix} {
  1454     catch {unset arg1; unset arg2}
  1455     list [binary scan \x01\x3f\xf9\x99\x99\x99\x99\x99\x9a c1d1 arg1 arg2] $arg1 $arg2
  1456 } {2 1 1.6}
  1457 test binary-41.8 {ScanNumber: word alignment} {nonPortable pcOnly} {
  1458     catch {unset arg1; unset arg2}
  1459     list [binary scan \x01\x9a\x99\x99\x99\x99\x99\xf9\x3f c1d1 arg1 arg2] $arg1 $arg2
  1460 } {2 1 1.6}
  1461 
  1462 test binary-42.1 {Tcl_BinaryObjCmd: bad arguments} {} {
  1463     catch {binary ?} result
  1464     set result
  1465 } {bad option "?": must be format or scan}
  1466 
  1467 # Wide int (guaranteed at least 64-bit) handling
  1468 test binary-43.1 {Tcl_BinaryObjCmd: format wide int} {} {
  1469     binary format w 7810179016327718216
  1470 } HelloTcl
  1471 test binary-43.2 {Tcl_BinaryObjCmd: format wide int} {} {
  1472     binary format W 7810179016327718216
  1473 } lcTolleH
  1474 
  1475 test binary-44.1 {Tcl_BinaryObjCmd: scan wide int} {} {
  1476     binary scan HelloTcl W x
  1477     set x
  1478 } 5216694956358656876
  1479 test binary-44.2 {Tcl_BinaryObjCmd: scan wide int} {} {
  1480     binary scan lcTolleH w x
  1481     set x
  1482 } 5216694956358656876
  1483 test binary-44.3 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} {} {
  1484     binary scan [binary format w [expr {wide(3) << 31}]] w x
  1485     set x
  1486 } 6442450944
  1487 test binary-44.4 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} {} {
  1488     binary scan [binary format W [expr {wide(3) << 31}]] W x
  1489     set x
  1490 } 6442450944
  1491 
  1492 test binary-45.1 {Tcl_BinaryObjCmd: combined wide int handling} {
  1493     binary scan [binary format sws 16450 -1 19521] c* x
  1494     set x
  1495 } {66 64 -1 -1 -1 -1 -1 -1 -1 -1 65 76}
  1496 test binary-45.2 {Tcl_BinaryObjCmd: combined wide int handling} {
  1497     binary scan [binary format sWs 16450 0x7fffffff 19521] c* x
  1498     set x
  1499 } {66 64 0 0 0 0 127 -1 -1 -1 65 76}
  1500 
  1501 test binary-46.1 {Tcl_BinaryObjCmd: handling of non-ISO8859-1 chars} {
  1502     binary format a* \u20ac
  1503 } \u00ac
  1504 test binary-46.2 {Tcl_BinaryObjCmd: handling of non-ISO8859-1 chars} {
  1505     list [binary scan [binary format a* \u20ac\u20bd] s x] $x
  1506 } {1 -16980}
  1507 test binary-46.3 {Tcl_BinaryObjCmd: handling of non-ISO8859-1 chars} {
  1508     set x {}
  1509     set y {}
  1510     set z {}
  1511     list [binary scan [binary format a* \u20ac\u20bd] aaa x y z] $x $y $z
  1512 } "2 \u00ac \u00bd {}"
  1513 test binary-46.4 {Tcl_BinaryObjCmd: handling of non-ISO8859-1 chars} {
  1514     set x [encoding convertto iso8859-15 \u20ac]
  1515     set y [binary format a* $x]
  1516     list $x $y
  1517 } "\u00a4 \u00a4"
  1518 test binary-46.5 {Tcl_BinaryObjCmd: handling of non-ISO8859-1 chars} {
  1519     set x [binary scan \u00a4 a* y]
  1520     list $x $y [encoding convertfrom iso8859-15 $y]
  1521 } "1 \u00a4 \u20ac"
  1522 
  1523 test binary-47.1 {Tcl_BinaryObjCmd: number cache reference count handling} {
  1524     # This test is only reliable when memory debugging is turned on,
  1525     # but without even memory debugging it should still generate the
  1526     # expected answers and might therefore still pick up memory corruption
  1527     # caused by [Bug 851747].
  1528     list [binary scan aba ccc x x x] $x
  1529 } {3 97}
  1530 
  1531 # cleanup
  1532 ::tcltest::cleanupTests
  1533 return