[25] | 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.32 2008/03/24 03:10:46 patthoyts Exp $ |
---|
| 14 | |
---|
| 15 | if {[lsearch [namespace children] ::tcltest] == -1} { |
---|
| 16 | package require tcltest |
---|
| 17 | namespace import -force ::tcltest::* |
---|
| 18 | } |
---|
| 19 | testConstraint bigEndian [expr {$tcl_platform(byteOrder) eq "bigEndian"}] |
---|
| 20 | testConstraint littleEndian [expr {$tcl_platform(byteOrder) eq "littleEndian"}] |
---|
| 21 | |
---|
| 22 | test binary-0.1 {DupByteArrayInternalRep} { |
---|
| 23 | set hdr [binary format cc 0 0316] |
---|
| 24 | set buf hellomatt |
---|
| 25 | |
---|
| 26 | set data $hdr |
---|
| 27 | append data $buf |
---|
| 28 | |
---|
| 29 | string length $data |
---|
| 30 | } 11 |
---|
| 31 | |
---|
| 32 | test binary-1.1 {Tcl_BinaryObjCmd: bad args} { |
---|
| 33 | list [catch {binary} msg] $msg |
---|
| 34 | } {1 {wrong # args: should be "binary option ?arg arg ...?"}} |
---|
| 35 | test binary-1.2 {Tcl_BinaryObjCmd: bad args} { |
---|
| 36 | list [catch {binary foo} msg] $msg |
---|
| 37 | } {1 {bad option "foo": must be format or scan}} |
---|
| 38 | |
---|
| 39 | test binary-1.3 {Tcl_BinaryObjCmd: format error} { |
---|
| 40 | list [catch {binary f} msg] $msg |
---|
| 41 | } {1 {wrong # args: should be "binary format formatString ?arg arg ...?"}} |
---|
| 42 | test binary-1.4 {Tcl_BinaryObjCmd: format} { |
---|
| 43 | binary format "" |
---|
| 44 | } {} |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | test binary-2.1 {Tcl_BinaryObjCmd: format} { |
---|
| 48 | list [catch {binary format a } msg] $msg |
---|
| 49 | } {1 {not enough arguments for all format specifiers}} |
---|
| 50 | test binary-2.2 {Tcl_BinaryObjCmd: format} { |
---|
| 51 | binary format a0 foo |
---|
| 52 | } {} |
---|
| 53 | test binary-2.3 {Tcl_BinaryObjCmd: format} { |
---|
| 54 | binary format a f |
---|
| 55 | } {f} |
---|
| 56 | test binary-2.4 {Tcl_BinaryObjCmd: format} { |
---|
| 57 | binary format a foo |
---|
| 58 | } {f} |
---|
| 59 | test binary-2.5 {Tcl_BinaryObjCmd: format} { |
---|
| 60 | binary format a3 foo |
---|
| 61 | } {foo} |
---|
| 62 | test binary-2.6 {Tcl_BinaryObjCmd: format} { |
---|
| 63 | binary format a5 foo |
---|
| 64 | } foo\x00\x00 |
---|
| 65 | test binary-2.7 {Tcl_BinaryObjCmd: format} { |
---|
| 66 | binary format a*a3 foobarbaz blat |
---|
| 67 | } foobarbazbla |
---|
| 68 | test binary-2.8 {Tcl_BinaryObjCmd: format} { |
---|
| 69 | binary format a*X3a2 foobar x |
---|
| 70 | } foox\x00r |
---|
| 71 | |
---|
| 72 | test binary-3.1 {Tcl_BinaryObjCmd: format} { |
---|
| 73 | list [catch {binary format A} msg] $msg |
---|
| 74 | } {1 {not enough arguments for all format specifiers}} |
---|
| 75 | test binary-3.2 {Tcl_BinaryObjCmd: format} { |
---|
| 76 | binary format A0 f |
---|
| 77 | } {} |
---|
| 78 | test binary-3.3 {Tcl_BinaryObjCmd: format} { |
---|
| 79 | binary format A f |
---|
| 80 | } {f} |
---|
| 81 | test binary-3.4 {Tcl_BinaryObjCmd: format} { |
---|
| 82 | binary format A foo |
---|
| 83 | } {f} |
---|
| 84 | test binary-3.5 {Tcl_BinaryObjCmd: format} { |
---|
| 85 | binary format A3 foo |
---|
| 86 | } {foo} |
---|
| 87 | test binary-3.6 {Tcl_BinaryObjCmd: format} { |
---|
| 88 | binary format A5 foo |
---|
| 89 | } {foo } |
---|
| 90 | test binary-3.7 {Tcl_BinaryObjCmd: format} { |
---|
| 91 | binary format A*A3 foobarbaz blat |
---|
| 92 | } foobarbazbla |
---|
| 93 | test binary-3.8 {Tcl_BinaryObjCmd: format} { |
---|
| 94 | binary format A*X3A2 foobar x |
---|
| 95 | } {foox r} |
---|
| 96 | |
---|
| 97 | test binary-4.1 {Tcl_BinaryObjCmd: format} { |
---|
| 98 | list [catch {binary format B} msg] $msg |
---|
| 99 | } {1 {not enough arguments for all format specifiers}} |
---|
| 100 | test binary-4.2 {Tcl_BinaryObjCmd: format} { |
---|
| 101 | binary format B0 1 |
---|
| 102 | } {} |
---|
| 103 | test binary-4.3 {Tcl_BinaryObjCmd: format} { |
---|
| 104 | binary format B 1 |
---|
| 105 | } \x80 |
---|
| 106 | test binary-4.4 {Tcl_BinaryObjCmd: format} { |
---|
| 107 | binary format B* 010011 |
---|
| 108 | } \x4c |
---|
| 109 | test binary-4.5 {Tcl_BinaryObjCmd: format} { |
---|
| 110 | binary format B8 01001101 |
---|
| 111 | } \x4d |
---|
| 112 | test binary-4.6 {Tcl_BinaryObjCmd: format} { |
---|
| 113 | binary format A2X2B9 oo 01001101 |
---|
| 114 | } \x4d\x00 |
---|
| 115 | test binary-4.7 {Tcl_BinaryObjCmd: format} { |
---|
| 116 | binary format B9 010011011010 |
---|
| 117 | } \x4d\x80 |
---|
| 118 | test binary-4.8 {Tcl_BinaryObjCmd: format} { |
---|
| 119 | binary format B2B3 10 010 |
---|
| 120 | } \x80\x40 |
---|
| 121 | test binary-4.9 {Tcl_BinaryObjCmd: format} { |
---|
| 122 | list [catch {binary format B1B5 1 foo} msg] $msg |
---|
| 123 | } {1 {expected binary string but got "foo" instead}} |
---|
| 124 | |
---|
| 125 | test binary-5.1 {Tcl_BinaryObjCmd: format} { |
---|
| 126 | list [catch {binary format b} msg] $msg |
---|
| 127 | } {1 {not enough arguments for all format specifiers}} |
---|
| 128 | test binary-5.2 {Tcl_BinaryObjCmd: format} { |
---|
| 129 | binary format b0 1 |
---|
| 130 | } {} |
---|
| 131 | test binary-5.3 {Tcl_BinaryObjCmd: format} { |
---|
| 132 | binary format b 1 |
---|
| 133 | } \x01 |
---|
| 134 | test binary-5.4 {Tcl_BinaryObjCmd: format} { |
---|
| 135 | binary format b* 010011 |
---|
| 136 | } 2 |
---|
| 137 | test binary-5.5 {Tcl_BinaryObjCmd: format} { |
---|
| 138 | binary format b8 01001101 |
---|
| 139 | } \xb2 |
---|
| 140 | test binary-5.6 {Tcl_BinaryObjCmd: format} { |
---|
| 141 | binary format A2X2b9 oo 01001101 |
---|
| 142 | } \xb2\x00 |
---|
| 143 | test binary-5.7 {Tcl_BinaryObjCmd: format} { |
---|
| 144 | binary format b9 010011011010 |
---|
| 145 | } \xb2\x01 |
---|
| 146 | test binary-5.8 {Tcl_BinaryObjCmd: format} { |
---|
| 147 | binary format b17 1 |
---|
| 148 | } \x01\00\00 |
---|
| 149 | test binary-5.9 {Tcl_BinaryObjCmd: format} { |
---|
| 150 | binary format b2b3 10 010 |
---|
| 151 | } \x01\x02 |
---|
| 152 | test binary-5.10 {Tcl_BinaryObjCmd: format} { |
---|
| 153 | list [catch {binary format b1b5 1 foo} msg] $msg |
---|
| 154 | } {1 {expected binary string but got "foo" instead}} |
---|
| 155 | |
---|
| 156 | test binary-6.1 {Tcl_BinaryObjCmd: format} { |
---|
| 157 | list [catch {binary format h} msg] $msg |
---|
| 158 | } {1 {not enough arguments for all format specifiers}} |
---|
| 159 | test binary-6.2 {Tcl_BinaryObjCmd: format} { |
---|
| 160 | binary format h0 1 |
---|
| 161 | } {} |
---|
| 162 | test binary-6.3 {Tcl_BinaryObjCmd: format} { |
---|
| 163 | binary format h 1 |
---|
| 164 | } \x01 |
---|
| 165 | test binary-6.4 {Tcl_BinaryObjCmd: format} { |
---|
| 166 | binary format h c |
---|
| 167 | } \x0c |
---|
| 168 | test binary-6.5 {Tcl_BinaryObjCmd: format} { |
---|
| 169 | binary format h* baadf00d |
---|
| 170 | } \xab\xda\x0f\xd0 |
---|
| 171 | test binary-6.6 {Tcl_BinaryObjCmd: format} { |
---|
| 172 | binary format h4 c410 |
---|
| 173 | } \x4c\x01 |
---|
| 174 | test binary-6.7 {Tcl_BinaryObjCmd: format} { |
---|
| 175 | binary format h6 c4102 |
---|
| 176 | } \x4c\x01\x02 |
---|
| 177 | test binary-6.8 {Tcl_BinaryObjCmd: format} { |
---|
| 178 | binary format h5 c41020304 |
---|
| 179 | } \x4c\x01\x02 |
---|
| 180 | test binary-6.9 {Tcl_BinaryObjCmd: format} { |
---|
| 181 | binary format a3X3h5 foo 2 |
---|
| 182 | } \x02\x00\x00 |
---|
| 183 | test binary-6.10 {Tcl_BinaryObjCmd: format} { |
---|
| 184 | binary format h2h3 23 456 |
---|
| 185 | } \x32\x54\x06 |
---|
| 186 | test binary-6.11 {Tcl_BinaryObjCmd: format} { |
---|
| 187 | list [catch {binary format h2 foo} msg] $msg |
---|
| 188 | } {1 {expected hexadecimal string but got "foo" instead}} |
---|
| 189 | |
---|
| 190 | test binary-7.1 {Tcl_BinaryObjCmd: format} { |
---|
| 191 | list [catch {binary format H} msg] $msg |
---|
| 192 | } {1 {not enough arguments for all format specifiers}} |
---|
| 193 | test binary-7.2 {Tcl_BinaryObjCmd: format} { |
---|
| 194 | binary format H0 1 |
---|
| 195 | } {} |
---|
| 196 | test binary-7.3 {Tcl_BinaryObjCmd: format} { |
---|
| 197 | binary format H 1 |
---|
| 198 | } \x10 |
---|
| 199 | test binary-7.4 {Tcl_BinaryObjCmd: format} { |
---|
| 200 | binary format H c |
---|
| 201 | } \xc0 |
---|
| 202 | test binary-7.5 {Tcl_BinaryObjCmd: format} { |
---|
| 203 | binary format H* baadf00d |
---|
| 204 | } \xba\xad\xf0\x0d |
---|
| 205 | test binary-7.6 {Tcl_BinaryObjCmd: format} { |
---|
| 206 | binary format H4 c410 |
---|
| 207 | } \xc4\x10 |
---|
| 208 | test binary-7.7 {Tcl_BinaryObjCmd: format} { |
---|
| 209 | binary format H6 c4102 |
---|
| 210 | } \xc4\x10\x20 |
---|
| 211 | test binary-7.8 {Tcl_BinaryObjCmd: format} { |
---|
| 212 | binary format H5 c41023304 |
---|
| 213 | } \xc4\x10\x20 |
---|
| 214 | test binary-7.9 {Tcl_BinaryObjCmd: format} { |
---|
| 215 | binary format a3X3H5 foo 2 |
---|
| 216 | } \x20\x00\x00 |
---|
| 217 | test binary-7.10 {Tcl_BinaryObjCmd: format} { |
---|
| 218 | binary format H2H3 23 456 |
---|
| 219 | } \x23\x45\x60 |
---|
| 220 | test binary-7.11 {Tcl_BinaryObjCmd: format} { |
---|
| 221 | list [catch {binary format H2 foo} msg] $msg |
---|
| 222 | } {1 {expected hexadecimal string but got "foo" instead}} |
---|
| 223 | |
---|
| 224 | test binary-8.1 {Tcl_BinaryObjCmd: format} { |
---|
| 225 | list [catch {binary format c} msg] $msg |
---|
| 226 | } {1 {not enough arguments for all format specifiers}} |
---|
| 227 | test binary-8.2 {Tcl_BinaryObjCmd: format} { |
---|
| 228 | list [catch {binary format c blat} msg] $msg |
---|
| 229 | } {1 {expected integer but got "blat"}} |
---|
| 230 | test binary-8.3 {Tcl_BinaryObjCmd: format} { |
---|
| 231 | binary format c0 0x50 |
---|
| 232 | } {} |
---|
| 233 | test binary-8.4 {Tcl_BinaryObjCmd: format} { |
---|
| 234 | binary format c 0x50 |
---|
| 235 | } P |
---|
| 236 | test binary-8.5 {Tcl_BinaryObjCmd: format} { |
---|
| 237 | binary format c 0x5052 |
---|
| 238 | } R |
---|
| 239 | test binary-8.6 {Tcl_BinaryObjCmd: format} { |
---|
| 240 | binary format c2 {0x50 0x52} |
---|
| 241 | } PR |
---|
| 242 | test binary-8.7 {Tcl_BinaryObjCmd: format} { |
---|
| 243 | binary format c2 {0x50 0x52 0x53} |
---|
| 244 | } PR |
---|
| 245 | test binary-8.8 {Tcl_BinaryObjCmd: format} { |
---|
| 246 | binary format c* {0x50 0x52} |
---|
| 247 | } PR |
---|
| 248 | test binary-8.9 {Tcl_BinaryObjCmd: format} { |
---|
| 249 | list [catch {binary format c2 {0x50}} msg] $msg |
---|
| 250 | } {1 {number of elements in list does not match count}} |
---|
| 251 | test binary-8.10 {Tcl_BinaryObjCmd: format} { |
---|
| 252 | set a {0x50 0x51} |
---|
| 253 | list [catch {binary format c $a} msg] $msg |
---|
| 254 | } [list 1 "expected integer but got \"0x50 0x51\""] |
---|
| 255 | test binary-8.11 {Tcl_BinaryObjCmd: format} { |
---|
| 256 | set a {0x50 0x51} |
---|
| 257 | binary format c1 $a |
---|
| 258 | } P |
---|
| 259 | |
---|
| 260 | test binary-9.1 {Tcl_BinaryObjCmd: format} { |
---|
| 261 | list [catch {binary format s} msg] $msg |
---|
| 262 | } {1 {not enough arguments for all format specifiers}} |
---|
| 263 | test binary-9.2 {Tcl_BinaryObjCmd: format} { |
---|
| 264 | list [catch {binary format s blat} msg] $msg |
---|
| 265 | } {1 {expected integer but got "blat"}} |
---|
| 266 | test binary-9.3 {Tcl_BinaryObjCmd: format} { |
---|
| 267 | binary format s0 0x50 |
---|
| 268 | } {} |
---|
| 269 | test binary-9.4 {Tcl_BinaryObjCmd: format} { |
---|
| 270 | binary format s 0x50 |
---|
| 271 | } P\x00 |
---|
| 272 | test binary-9.5 {Tcl_BinaryObjCmd: format} { |
---|
| 273 | binary format s 0x5052 |
---|
| 274 | } RP |
---|
| 275 | test binary-9.6 {Tcl_BinaryObjCmd: format} { |
---|
| 276 | binary format s 0x505251 0x53 |
---|
| 277 | } QR |
---|
| 278 | test binary-9.7 {Tcl_BinaryObjCmd: format} { |
---|
| 279 | binary format s2 {0x50 0x52} |
---|
| 280 | } P\x00R\x00 |
---|
| 281 | test binary-9.8 {Tcl_BinaryObjCmd: format} { |
---|
| 282 | binary format s* {0x5051 0x52} |
---|
| 283 | } QPR\x00 |
---|
| 284 | test binary-9.9 {Tcl_BinaryObjCmd: format} { |
---|
| 285 | binary format s2 {0x50 0x52 0x53} 0x54 |
---|
| 286 | } P\x00R\x00 |
---|
| 287 | test binary-9.10 {Tcl_BinaryObjCmd: format} { |
---|
| 288 | list [catch {binary format s2 {0x50}} msg] $msg |
---|
| 289 | } {1 {number of elements in list does not match count}} |
---|
| 290 | test binary-9.11 {Tcl_BinaryObjCmd: format} { |
---|
| 291 | set a {0x50 0x51} |
---|
| 292 | list [catch {binary format s $a} msg] $msg |
---|
| 293 | } [list 1 "expected integer but got \"0x50 0x51\""] |
---|
| 294 | test binary-9.12 {Tcl_BinaryObjCmd: format} { |
---|
| 295 | set a {0x50 0x51} |
---|
| 296 | binary format s1 $a |
---|
| 297 | } P\x00 |
---|
| 298 | |
---|
| 299 | test binary-10.1 {Tcl_BinaryObjCmd: format} { |
---|
| 300 | list [catch {binary format S} msg] $msg |
---|
| 301 | } {1 {not enough arguments for all format specifiers}} |
---|
| 302 | test binary-10.2 {Tcl_BinaryObjCmd: format} { |
---|
| 303 | list [catch {binary format S blat} msg] $msg |
---|
| 304 | } {1 {expected integer but got "blat"}} |
---|
| 305 | test binary-10.3 {Tcl_BinaryObjCmd: format} { |
---|
| 306 | binary format S0 0x50 |
---|
| 307 | } {} |
---|
| 308 | test binary-10.4 {Tcl_BinaryObjCmd: format} { |
---|
| 309 | binary format S 0x50 |
---|
| 310 | } \x00P |
---|
| 311 | test binary-10.5 {Tcl_BinaryObjCmd: format} { |
---|
| 312 | binary format S 0x5052 |
---|
| 313 | } PR |
---|
| 314 | test binary-10.6 {Tcl_BinaryObjCmd: format} { |
---|
| 315 | binary format S 0x505251 0x53 |
---|
| 316 | } RQ |
---|
| 317 | test binary-10.7 {Tcl_BinaryObjCmd: format} { |
---|
| 318 | binary format S2 {0x50 0x52} |
---|
| 319 | } \x00P\x00R |
---|
| 320 | test binary-10.8 {Tcl_BinaryObjCmd: format} { |
---|
| 321 | binary format S* {0x5051 0x52} |
---|
| 322 | } PQ\x00R |
---|
| 323 | test binary-10.9 {Tcl_BinaryObjCmd: format} { |
---|
| 324 | binary format S2 {0x50 0x52 0x53} 0x54 |
---|
| 325 | } \x00P\x00R |
---|
| 326 | test binary-10.10 {Tcl_BinaryObjCmd: format} { |
---|
| 327 | list [catch {binary format S2 {0x50}} msg] $msg |
---|
| 328 | } {1 {number of elements in list does not match count}} |
---|
| 329 | test binary-10.11 {Tcl_BinaryObjCmd: format} { |
---|
| 330 | set a {0x50 0x51} |
---|
| 331 | list [catch {binary format S $a} msg] $msg |
---|
| 332 | } [list 1 "expected integer but got \"0x50 0x51\""] |
---|
| 333 | test binary-10.12 {Tcl_BinaryObjCmd: format} { |
---|
| 334 | set a {0x50 0x51} |
---|
| 335 | binary format S1 $a |
---|
| 336 | } \x00P |
---|
| 337 | |
---|
| 338 | test binary-11.1 {Tcl_BinaryObjCmd: format} { |
---|
| 339 | list [catch {binary format i} msg] $msg |
---|
| 340 | } {1 {not enough arguments for all format specifiers}} |
---|
| 341 | test binary-11.2 {Tcl_BinaryObjCmd: format} { |
---|
| 342 | list [catch {binary format i blat} msg] $msg |
---|
| 343 | } {1 {expected integer but got "blat"}} |
---|
| 344 | test binary-11.3 {Tcl_BinaryObjCmd: format} { |
---|
| 345 | binary format i0 0x50 |
---|
| 346 | } {} |
---|
| 347 | test binary-11.4 {Tcl_BinaryObjCmd: format} { |
---|
| 348 | binary format i 0x50 |
---|
| 349 | } P\x00\x00\x00 |
---|
| 350 | test binary-11.5 {Tcl_BinaryObjCmd: format} { |
---|
| 351 | binary format i 0x5052 |
---|
| 352 | } RP\x00\x00 |
---|
| 353 | test binary-11.6 {Tcl_BinaryObjCmd: format} { |
---|
| 354 | binary format i 0x505251 0x53 |
---|
| 355 | } QRP\x00 |
---|
| 356 | test binary-11.7 {Tcl_BinaryObjCmd: format} { |
---|
| 357 | binary format i1 {0x505251 0x53} |
---|
| 358 | } QRP\x00 |
---|
| 359 | test binary-11.8 {Tcl_BinaryObjCmd: format} { |
---|
| 360 | binary format i 0x53525150 |
---|
| 361 | } PQRS |
---|
| 362 | test binary-11.9 {Tcl_BinaryObjCmd: format} { |
---|
| 363 | binary format i2 {0x50 0x52} |
---|
| 364 | } P\x00\x00\x00R\x00\x00\x00 |
---|
| 365 | test binary-11.10 {Tcl_BinaryObjCmd: format} { |
---|
| 366 | binary format i* {0x50515253 0x52} |
---|
| 367 | } SRQPR\x00\x00\x00 |
---|
| 368 | test binary-11.11 {Tcl_BinaryObjCmd: format} { |
---|
| 369 | list [catch {binary format i2 {0x50}} msg] $msg |
---|
| 370 | } {1 {number of elements in list does not match count}} |
---|
| 371 | test binary-11.12 {Tcl_BinaryObjCmd: format} { |
---|
| 372 | set a {0x50 0x51} |
---|
| 373 | list [catch {binary format i $a} msg] $msg |
---|
| 374 | } [list 1 "expected integer but got \"0x50 0x51\""] |
---|
| 375 | test binary-11.13 {Tcl_BinaryObjCmd: format} { |
---|
| 376 | set a {0x50 0x51} |
---|
| 377 | binary format i1 $a |
---|
| 378 | } P\x00\x00\x00 |
---|
| 379 | |
---|
| 380 | test binary-12.1 {Tcl_BinaryObjCmd: format} { |
---|
| 381 | list [catch {binary format I} msg] $msg |
---|
| 382 | } {1 {not enough arguments for all format specifiers}} |
---|
| 383 | test binary-12.2 {Tcl_BinaryObjCmd: format} { |
---|
| 384 | list [catch {binary format I blat} msg] $msg |
---|
| 385 | } {1 {expected integer but got "blat"}} |
---|
| 386 | test binary-12.3 {Tcl_BinaryObjCmd: format} { |
---|
| 387 | binary format I0 0x50 |
---|
| 388 | } {} |
---|
| 389 | test binary-12.4 {Tcl_BinaryObjCmd: format} { |
---|
| 390 | binary format I 0x50 |
---|
| 391 | } \x00\x00\x00P |
---|
| 392 | test binary-12.5 {Tcl_BinaryObjCmd: format} { |
---|
| 393 | binary format I 0x5052 |
---|
| 394 | } \x00\x00PR |
---|
| 395 | test binary-12.6 {Tcl_BinaryObjCmd: format} { |
---|
| 396 | binary format I 0x505251 0x53 |
---|
| 397 | } \x00PRQ |
---|
| 398 | test binary-12.7 {Tcl_BinaryObjCmd: format} { |
---|
| 399 | binary format I1 {0x505251 0x53} |
---|
| 400 | } \x00PRQ |
---|
| 401 | test binary-12.8 {Tcl_BinaryObjCmd: format} { |
---|
| 402 | binary format I 0x53525150 |
---|
| 403 | } SRQP |
---|
| 404 | test binary-12.9 {Tcl_BinaryObjCmd: format} { |
---|
| 405 | binary format I2 {0x50 0x52} |
---|
| 406 | } \x00\x00\x00P\x00\x00\x00R |
---|
| 407 | test binary-12.10 {Tcl_BinaryObjCmd: format} { |
---|
| 408 | binary format I* {0x50515253 0x52} |
---|
| 409 | } PQRS\x00\x00\x00R |
---|
| 410 | test binary-12.11 {Tcl_BinaryObjCmd: format} { |
---|
| 411 | list [catch {binary format i2 {0x50}} msg] $msg |
---|
| 412 | } {1 {number of elements in list does not match count}} |
---|
| 413 | test binary-12.12 {Tcl_BinaryObjCmd: format} { |
---|
| 414 | set a {0x50 0x51} |
---|
| 415 | list [catch {binary format I $a} msg] $msg |
---|
| 416 | } [list 1 "expected integer but got \"0x50 0x51\""] |
---|
| 417 | test binary-12.13 {Tcl_BinaryObjCmd: format} { |
---|
| 418 | set a {0x50 0x51} |
---|
| 419 | binary format I1 $a |
---|
| 420 | } \x00\x00\x00P |
---|
| 421 | |
---|
| 422 | test binary-13.1 {Tcl_BinaryObjCmd: format} { |
---|
| 423 | list [catch {binary format f} msg] $msg |
---|
| 424 | } {1 {not enough arguments for all format specifiers}} |
---|
| 425 | test binary-13.2 {Tcl_BinaryObjCmd: format} { |
---|
| 426 | list [catch {binary format f blat} msg] $msg |
---|
| 427 | } {1 {expected floating-point number but got "blat"}} |
---|
| 428 | test binary-13.3 {Tcl_BinaryObjCmd: format} { |
---|
| 429 | binary format f0 1.6 |
---|
| 430 | } {} |
---|
| 431 | test binary-13.4 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 432 | binary format f 1.6 |
---|
| 433 | } \x3f\xcc\xcc\xcd |
---|
| 434 | test binary-13.5 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 435 | binary format f 1.6 |
---|
| 436 | } \xcd\xcc\xcc\x3f |
---|
| 437 | test binary-13.6 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 438 | binary format f* {1.6 3.4} |
---|
| 439 | } \x3f\xcc\xcc\xcd\x40\x59\x99\x9a |
---|
| 440 | test binary-13.7 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 441 | binary format f* {1.6 3.4} |
---|
| 442 | } \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 |
---|
| 443 | test binary-13.8 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 444 | binary format f2 {1.6 3.4} |
---|
| 445 | } \x3f\xcc\xcc\xcd\x40\x59\x99\x9a |
---|
| 446 | test binary-13.9 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 447 | binary format f2 {1.6 3.4} |
---|
| 448 | } \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 |
---|
| 449 | test binary-13.10 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 450 | binary format f2 {1.6 3.4 5.6} |
---|
| 451 | } \x3f\xcc\xcc\xcd\x40\x59\x99\x9a |
---|
| 452 | test binary-13.11 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 453 | binary format f2 {1.6 3.4 5.6} |
---|
| 454 | } \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 |
---|
| 455 | test binary-13.12 {Tcl_BinaryObjCmd: float overflow} bigEndian { |
---|
| 456 | binary format f -3.402825e+38 |
---|
| 457 | } \xff\x7f\xff\xff |
---|
| 458 | test binary-13.13 {Tcl_BinaryObjCmd: float overflow} littleEndian { |
---|
| 459 | binary format f -3.402825e+38 |
---|
| 460 | } \xff\xff\x7f\xff |
---|
| 461 | test binary-13.14 {Tcl_BinaryObjCmd: float underflow} bigEndian { |
---|
| 462 | binary format f -3.402825e-100 |
---|
| 463 | } \x80\x00\x00\x00 |
---|
| 464 | test binary-13.15 {Tcl_BinaryObjCmd: float underflow} littleEndian { |
---|
| 465 | binary format f -3.402825e-100 |
---|
| 466 | } \x00\x00\x00\x80 |
---|
| 467 | test binary-13.16 {Tcl_BinaryObjCmd: format} { |
---|
| 468 | list [catch {binary format f2 {1.6}} msg] $msg |
---|
| 469 | } {1 {number of elements in list does not match count}} |
---|
| 470 | test binary-13.17 {Tcl_BinaryObjCmd: format} { |
---|
| 471 | set a {1.6 3.4} |
---|
| 472 | list [catch {binary format f $a} msg] $msg |
---|
| 473 | } [list 1 "expected floating-point number but got \"1.6 3.4\""] |
---|
| 474 | test binary-13.18 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 475 | set a {1.6 3.4} |
---|
| 476 | binary format f1 $a |
---|
| 477 | } \x3f\xcc\xcc\xcd |
---|
| 478 | test binary-13.19 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 479 | set a {1.6 3.4} |
---|
| 480 | binary format f1 $a |
---|
| 481 | } \xcd\xcc\xcc\x3f |
---|
| 482 | |
---|
| 483 | test binary-14.1 {Tcl_BinaryObjCmd: format} { |
---|
| 484 | list [catch {binary format d} msg] $msg |
---|
| 485 | } {1 {not enough arguments for all format specifiers}} |
---|
| 486 | test binary-14.2 {Tcl_BinaryObjCmd: format} { |
---|
| 487 | list [catch {binary format d blat} msg] $msg |
---|
| 488 | } {1 {expected floating-point number but got "blat"}} |
---|
| 489 | test binary-14.3 {Tcl_BinaryObjCmd: format} { |
---|
| 490 | binary format d0 1.6 |
---|
| 491 | } {} |
---|
| 492 | test binary-14.4 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 493 | binary format d 1.6 |
---|
| 494 | } \x3f\xf9\x99\x99\x99\x99\x99\x9a |
---|
| 495 | test binary-14.5 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 496 | binary format d 1.6 |
---|
| 497 | } \x9a\x99\x99\x99\x99\x99\xf9\x3f |
---|
| 498 | test binary-14.6 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 499 | binary format d* {1.6 3.4} |
---|
| 500 | } \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 |
---|
| 501 | test binary-14.7 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 502 | binary format d* {1.6 3.4} |
---|
| 503 | } \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 |
---|
| 504 | test binary-14.8 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 505 | binary format d2 {1.6 3.4} |
---|
| 506 | } \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 |
---|
| 507 | test binary-14.9 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 508 | binary format d2 {1.6 3.4} |
---|
| 509 | } \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 |
---|
| 510 | test binary-14.10 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 511 | binary format d2 {1.6 3.4 5.6} |
---|
| 512 | } \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 |
---|
| 513 | test binary-14.11 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 514 | binary format d2 {1.6 3.4 5.6} |
---|
| 515 | } \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 |
---|
| 516 | test binary-14.14 {Tcl_BinaryObjCmd: format} { |
---|
| 517 | list [catch {binary format d2 {1.6}} msg] $msg |
---|
| 518 | } {1 {number of elements in list does not match count}} |
---|
| 519 | test binary-14.15 {Tcl_BinaryObjCmd: format} { |
---|
| 520 | set a {1.6 3.4} |
---|
| 521 | list [catch {binary format d $a} msg] $msg |
---|
| 522 | } [list 1 "expected floating-point number but got \"1.6 3.4\""] |
---|
| 523 | test binary-14.16 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 524 | set a {1.6 3.4} |
---|
| 525 | binary format d1 $a |
---|
| 526 | } \x3f\xf9\x99\x99\x99\x99\x99\x9a |
---|
| 527 | test binary-14.17 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 528 | set a {1.6 3.4} |
---|
| 529 | binary format d1 $a |
---|
| 530 | } \x9a\x99\x99\x99\x99\x99\xf9\x3f |
---|
| 531 | test binary-14.18 {FormatNumber: Bug 1116542} { |
---|
| 532 | binary scan [binary format d 1.25] d w |
---|
| 533 | set w |
---|
| 534 | } 1.25 |
---|
| 535 | |
---|
| 536 | test binary-15.1 {Tcl_BinaryObjCmd: format} { |
---|
| 537 | list [catch {binary format ax*a "y" "z"} msg] $msg |
---|
| 538 | } {1 {cannot use "*" in format string with "x"}} |
---|
| 539 | test binary-15.2 {Tcl_BinaryObjCmd: format} { |
---|
| 540 | binary format axa "y" "z" |
---|
| 541 | } y\x00z |
---|
| 542 | test binary-15.3 {Tcl_BinaryObjCmd: format} { |
---|
| 543 | binary format ax3a "y" "z" |
---|
| 544 | } y\x00\x00\x00z |
---|
| 545 | test binary-15.4 {Tcl_BinaryObjCmd: format} { |
---|
| 546 | binary format a*X3x3a* "foo" "z" |
---|
| 547 | } \x00\x00\x00z |
---|
| 548 | test binary-15.5 {Tcl_BinaryObjCmd: format - bug #1923966} { |
---|
| 549 | binary format x0s 1 |
---|
| 550 | } \x01\x00 |
---|
| 551 | test binary-15.6 {Tcl_BinaryObjCmd: format - bug #1923966} { |
---|
| 552 | binary format x0ss 1 1 |
---|
| 553 | } \x01\x00\x01\x00 |
---|
| 554 | test binary-15.7 {Tcl_BinaryObjCmd: format - bug #1923966} { |
---|
| 555 | binary format x1s 1 |
---|
| 556 | } \x00\x01\x00 |
---|
| 557 | test binary-15.8 {Tcl_BinaryObjCmd: format - bug #1923966} { |
---|
| 558 | binary format x1ss 1 1 |
---|
| 559 | } \x00\x01\x00\x01\x00 |
---|
| 560 | |
---|
| 561 | test binary-16.1 {Tcl_BinaryObjCmd: format} { |
---|
| 562 | binary format a*X*a "foo" "z" |
---|
| 563 | } zoo |
---|
| 564 | test binary-16.2 {Tcl_BinaryObjCmd: format} { |
---|
| 565 | binary format aX3a "y" "z" |
---|
| 566 | } z |
---|
| 567 | test binary-16.3 {Tcl_BinaryObjCmd: format} { |
---|
| 568 | binary format a*Xa* "foo" "zy" |
---|
| 569 | } fozy |
---|
| 570 | test binary-16.4 {Tcl_BinaryObjCmd: format} { |
---|
| 571 | binary format a*X3a "foobar" "z" |
---|
| 572 | } foozar |
---|
| 573 | test binary-16.5 {Tcl_BinaryObjCmd: format} { |
---|
| 574 | binary format a*X3aX2a "foobar" "z" "b" |
---|
| 575 | } fobzar |
---|
| 576 | |
---|
| 577 | test binary-17.1 {Tcl_BinaryObjCmd: format} { |
---|
| 578 | binary format @1 |
---|
| 579 | } \x00 |
---|
| 580 | test binary-17.2 {Tcl_BinaryObjCmd: format} { |
---|
| 581 | binary format @5a2 "ab" |
---|
| 582 | } \x00\x00\x00\x00\x00\x61\x62 |
---|
| 583 | test binary-17.3 {Tcl_BinaryObjCmd: format} { |
---|
| 584 | binary format {a* @0 a2 @* a*} "foobar" "ab" "blat" |
---|
| 585 | } abobarblat |
---|
| 586 | |
---|
| 587 | test binary-18.1 {Tcl_BinaryObjCmd: format} { |
---|
| 588 | list [catch {binary format u0a3 abc abd} msg] $msg |
---|
| 589 | } {1 {bad field specifier "u"}} |
---|
| 590 | |
---|
| 591 | |
---|
| 592 | test binary-19.1 {Tcl_BinaryObjCmd: errors} { |
---|
| 593 | list [catch {binary s} msg] $msg |
---|
| 594 | } {1 {wrong # args: should be "binary scan value formatString ?varName varName ...?"}} |
---|
| 595 | test binary-19.2 {Tcl_BinaryObjCmd: errors} { |
---|
| 596 | list [catch {binary scan foo} msg] $msg |
---|
| 597 | } {1 {wrong # args: should be "binary scan value formatString ?varName varName ...?"}} |
---|
| 598 | test binary-19.3 {Tcl_BinaryObjCmd: scan} { |
---|
| 599 | binary scan {} {} |
---|
| 600 | } 0 |
---|
| 601 | |
---|
| 602 | test binary-20.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 603 | list [catch {binary scan abc a} msg] $msg |
---|
| 604 | } {1 {not enough arguments for all format specifiers}} |
---|
| 605 | test binary-20.2 {Tcl_BinaryObjCmd: scan} { |
---|
| 606 | catch {unset arg1} |
---|
| 607 | set arg1 1 |
---|
| 608 | list [catch {binary scan abc a arg1(a)} msg] $msg |
---|
| 609 | } {1 {can't set "arg1(a)": variable isn't array}} |
---|
| 610 | test binary-20.3 {Tcl_BinaryObjCmd: scan} { |
---|
| 611 | catch {unset arg1} |
---|
| 612 | set arg1 abc |
---|
| 613 | list [binary scan abc a0 arg1] $arg1 |
---|
| 614 | } {1 {}} |
---|
| 615 | test binary-20.4 {Tcl_BinaryObjCmd: scan} { |
---|
| 616 | catch {unset arg1} |
---|
| 617 | list [binary scan abc a* arg1] $arg1 |
---|
| 618 | } {1 abc} |
---|
| 619 | test binary-20.5 {Tcl_BinaryObjCmd: scan} { |
---|
| 620 | catch {unset arg1} |
---|
| 621 | list [binary scan abc a5 arg1] [info exists arg1] |
---|
| 622 | } {0 0} |
---|
| 623 | test binary-20.6 {Tcl_BinaryObjCmd: scan} { |
---|
| 624 | set arg1 foo |
---|
| 625 | list [binary scan abc a2 arg1] $arg1 |
---|
| 626 | } {1 ab} |
---|
| 627 | test binary-20.7 {Tcl_BinaryObjCmd: scan} { |
---|
| 628 | catch {unset arg1} |
---|
| 629 | catch {unset arg2} |
---|
| 630 | list [binary scan abcdef a2a2 arg1 arg2] $arg1 $arg2 |
---|
| 631 | } {2 ab cd} |
---|
| 632 | test binary-20.8 {Tcl_BinaryObjCmd: scan} { |
---|
| 633 | catch {unset arg1} |
---|
| 634 | list [binary scan abc a2 arg1(a)] $arg1(a) |
---|
| 635 | } {1 ab} |
---|
| 636 | test binary-20.9 {Tcl_BinaryObjCmd: scan} { |
---|
| 637 | catch {unset arg1} |
---|
| 638 | list [binary scan abc a arg1(a)] $arg1(a) |
---|
| 639 | } {1 a} |
---|
| 640 | |
---|
| 641 | test binary-21.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 642 | list [catch {binary scan abc A} msg] $msg |
---|
| 643 | } {1 {not enough arguments for all format specifiers}} |
---|
| 644 | test binary-21.2 {Tcl_BinaryObjCmd: scan} { |
---|
| 645 | catch {unset arg1} |
---|
| 646 | set arg1 1 |
---|
| 647 | list [catch {binary scan abc A arg1(a)} msg] $msg |
---|
| 648 | } {1 {can't set "arg1(a)": variable isn't array}} |
---|
| 649 | test binary-21.3 {Tcl_BinaryObjCmd: scan} { |
---|
| 650 | catch {unset arg1} |
---|
| 651 | set arg1 abc |
---|
| 652 | list [binary scan abc A0 arg1] $arg1 |
---|
| 653 | } {1 {}} |
---|
| 654 | test binary-21.4 {Tcl_BinaryObjCmd: scan} { |
---|
| 655 | catch {unset arg1} |
---|
| 656 | list [binary scan abc A* arg1] $arg1 |
---|
| 657 | } {1 abc} |
---|
| 658 | test binary-21.5 {Tcl_BinaryObjCmd: scan} { |
---|
| 659 | catch {unset arg1} |
---|
| 660 | list [binary scan abc A5 arg1] [info exists arg1] |
---|
| 661 | } {0 0} |
---|
| 662 | test binary-21.6 {Tcl_BinaryObjCmd: scan} { |
---|
| 663 | set arg1 foo |
---|
| 664 | list [binary scan abc A2 arg1] $arg1 |
---|
| 665 | } {1 ab} |
---|
| 666 | test binary-21.7 {Tcl_BinaryObjCmd: scan} { |
---|
| 667 | catch {unset arg1} |
---|
| 668 | catch {unset arg2} |
---|
| 669 | list [binary scan abcdef A2A2 arg1 arg2] $arg1 $arg2 |
---|
| 670 | } {2 ab cd} |
---|
| 671 | test binary-21.8 {Tcl_BinaryObjCmd: scan} { |
---|
| 672 | catch {unset arg1} |
---|
| 673 | list [binary scan abc A2 arg1(a)] $arg1(a) |
---|
| 674 | } {1 ab} |
---|
| 675 | test binary-21.9 {Tcl_BinaryObjCmd: scan} { |
---|
| 676 | catch {unset arg1} |
---|
| 677 | list [binary scan abc A2 arg1(a)] $arg1(a) |
---|
| 678 | } {1 ab} |
---|
| 679 | test binary-21.10 {Tcl_BinaryObjCmd: scan} { |
---|
| 680 | catch {unset arg1} |
---|
| 681 | list [binary scan abc A arg1(a)] $arg1(a) |
---|
| 682 | } {1 a} |
---|
| 683 | test binary-21.11 {Tcl_BinaryObjCmd: scan} { |
---|
| 684 | catch {unset arg1} |
---|
| 685 | list [binary scan "abc def \x00 " A* arg1] $arg1 |
---|
| 686 | } {1 {abc def}} |
---|
| 687 | test binary-21.12 {Tcl_BinaryObjCmd: scan} { |
---|
| 688 | catch {unset arg1} |
---|
| 689 | list [binary scan "abc def \x00ghi " A* arg1] $arg1 |
---|
| 690 | } [list 1 "abc def \x00ghi"] |
---|
| 691 | |
---|
| 692 | test binary-22.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 693 | list [catch {binary scan abc b} msg] $msg |
---|
| 694 | } {1 {not enough arguments for all format specifiers}} |
---|
| 695 | test binary-22.2 {Tcl_BinaryObjCmd: scan} { |
---|
| 696 | catch {unset arg1} |
---|
| 697 | list [binary scan \x52\x53 b* arg1] $arg1 |
---|
| 698 | } {1 0100101011001010} |
---|
| 699 | test binary-22.3 {Tcl_BinaryObjCmd: scan} { |
---|
| 700 | catch {unset arg1} |
---|
| 701 | list [binary scan \x82\x53 b arg1] $arg1 |
---|
| 702 | } {1 0} |
---|
| 703 | test binary-22.4 {Tcl_BinaryObjCmd: scan} { |
---|
| 704 | catch {unset arg1} |
---|
| 705 | list [binary scan \x82\x53 b1 arg1] $arg1 |
---|
| 706 | } {1 0} |
---|
| 707 | test binary-22.5 {Tcl_BinaryObjCmd: scan} { |
---|
| 708 | catch {unset arg1} |
---|
| 709 | list [binary scan \x82\x53 b0 arg1] $arg1 |
---|
| 710 | } {1 {}} |
---|
| 711 | test binary-22.6 {Tcl_BinaryObjCmd: scan} { |
---|
| 712 | catch {unset arg1} |
---|
| 713 | list [binary scan \x52\x53 b5 arg1] $arg1 |
---|
| 714 | } {1 01001} |
---|
| 715 | test binary-22.7 {Tcl_BinaryObjCmd: scan} { |
---|
| 716 | catch {unset arg1} |
---|
| 717 | list [binary scan \x52\x53 b8 arg1] $arg1 |
---|
| 718 | } {1 01001010} |
---|
| 719 | test binary-22.8 {Tcl_BinaryObjCmd: scan} { |
---|
| 720 | catch {unset arg1} |
---|
| 721 | list [binary scan \x52\x53 b14 arg1] $arg1 |
---|
| 722 | } {1 01001010110010} |
---|
| 723 | test binary-22.9 {Tcl_BinaryObjCmd: scan} { |
---|
| 724 | catch {unset arg1} |
---|
| 725 | set arg1 foo |
---|
| 726 | list [binary scan \x52 b14 arg1] $arg1 |
---|
| 727 | } {0 foo} |
---|
| 728 | test binary-22.10 {Tcl_BinaryObjCmd: scan} { |
---|
| 729 | catch {unset arg1} |
---|
| 730 | set arg1 1 |
---|
| 731 | list [catch {binary scan \x52\x53 b1 arg1(a)} msg] $msg |
---|
| 732 | } {1 {can't set "arg1(a)": variable isn't array}} |
---|
| 733 | test binary-22.11 {Tcl_BinaryObjCmd: scan} { |
---|
| 734 | catch {unset arg1 arg2} |
---|
| 735 | set arg1 foo |
---|
| 736 | set arg2 bar |
---|
| 737 | list [binary scan \x07\x87\x05 b5b* arg1 arg2] $arg1 $arg2 |
---|
| 738 | } {2 11100 1110000110100000} |
---|
| 739 | |
---|
| 740 | |
---|
| 741 | test binary-23.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 742 | list [catch {binary scan abc B} msg] $msg |
---|
| 743 | } {1 {not enough arguments for all format specifiers}} |
---|
| 744 | test binary-23.2 {Tcl_BinaryObjCmd: scan} { |
---|
| 745 | catch {unset arg1} |
---|
| 746 | list [binary scan \x52\x53 B* arg1] $arg1 |
---|
| 747 | } {1 0101001001010011} |
---|
| 748 | test binary-23.3 {Tcl_BinaryObjCmd: scan} { |
---|
| 749 | catch {unset arg1} |
---|
| 750 | list [binary scan \x82\x53 B arg1] $arg1 |
---|
| 751 | } {1 1} |
---|
| 752 | test binary-23.4 {Tcl_BinaryObjCmd: scan} { |
---|
| 753 | catch {unset arg1} |
---|
| 754 | list [binary scan \x82\x53 B1 arg1] $arg1 |
---|
| 755 | } {1 1} |
---|
| 756 | test binary-23.5 {Tcl_BinaryObjCmd: scan} { |
---|
| 757 | catch {unset arg1} |
---|
| 758 | list [binary scan \x52\x53 B0 arg1] $arg1 |
---|
| 759 | } {1 {}} |
---|
| 760 | test binary-23.6 {Tcl_BinaryObjCmd: scan} { |
---|
| 761 | catch {unset arg1} |
---|
| 762 | list [binary scan \x52\x53 B5 arg1] $arg1 |
---|
| 763 | } {1 01010} |
---|
| 764 | test binary-23.7 {Tcl_BinaryObjCmd: scan} { |
---|
| 765 | catch {unset arg1} |
---|
| 766 | list [binary scan \x52\x53 B8 arg1] $arg1 |
---|
| 767 | } {1 01010010} |
---|
| 768 | test binary-23.8 {Tcl_BinaryObjCmd: scan} { |
---|
| 769 | catch {unset arg1} |
---|
| 770 | list [binary scan \x52\x53 B14 arg1] $arg1 |
---|
| 771 | } {1 01010010010100} |
---|
| 772 | test binary-23.9 {Tcl_BinaryObjCmd: scan} { |
---|
| 773 | catch {unset arg1} |
---|
| 774 | set arg1 foo |
---|
| 775 | list [binary scan \x52 B14 arg1] $arg1 |
---|
| 776 | } {0 foo} |
---|
| 777 | test binary-23.10 {Tcl_BinaryObjCmd: scan} { |
---|
| 778 | catch {unset arg1} |
---|
| 779 | set arg1 1 |
---|
| 780 | list [catch {binary scan \x52\x53 B1 arg1(a)} msg] $msg |
---|
| 781 | } {1 {can't set "arg1(a)": variable isn't array}} |
---|
| 782 | test binary-23.11 {Tcl_BinaryObjCmd: scan} { |
---|
| 783 | catch {unset arg1 arg2} |
---|
| 784 | set arg1 foo |
---|
| 785 | set arg2 bar |
---|
| 786 | list [binary scan \x70\x87\x05 B5B* arg1 arg2] $arg1 $arg2 |
---|
| 787 | } {2 01110 1000011100000101} |
---|
| 788 | |
---|
| 789 | test binary-24.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 790 | list [catch {binary scan abc h} msg] $msg |
---|
| 791 | } {1 {not enough arguments for all format specifiers}} |
---|
| 792 | test binary-24.2 {Tcl_BinaryObjCmd: scan} { |
---|
| 793 | catch {unset arg1} |
---|
| 794 | list [binary scan \x52\xa3 h* arg1] $arg1 |
---|
| 795 | } {1 253a} |
---|
| 796 | test binary-24.3 {Tcl_BinaryObjCmd: scan} { |
---|
| 797 | catch {unset arg1} |
---|
| 798 | list [binary scan \xc2\xa3 h arg1] $arg1 |
---|
| 799 | } {1 2} |
---|
| 800 | test binary-24.4 {Tcl_BinaryObjCmd: scan} { |
---|
| 801 | catch {unset arg1} |
---|
| 802 | list [binary scan \x82\x53 h1 arg1] $arg1 |
---|
| 803 | } {1 2} |
---|
| 804 | test binary-24.5 {Tcl_BinaryObjCmd: scan} { |
---|
| 805 | catch {unset arg1} |
---|
| 806 | list [binary scan \x52\x53 h0 arg1] $arg1 |
---|
| 807 | } {1 {}} |
---|
| 808 | test binary-24.6 {Tcl_BinaryObjCmd: scan} { |
---|
| 809 | catch {unset arg1} |
---|
| 810 | list [binary scan \xf2\x53 h2 arg1] $arg1 |
---|
| 811 | } {1 2f} |
---|
| 812 | test binary-24.7 {Tcl_BinaryObjCmd: scan} { |
---|
| 813 | catch {unset arg1} |
---|
| 814 | list [binary scan \x52\x53 h3 arg1] $arg1 |
---|
| 815 | } {1 253} |
---|
| 816 | test binary-24.8 {Tcl_BinaryObjCmd: scan} { |
---|
| 817 | catch {unset arg1} |
---|
| 818 | set arg1 foo |
---|
| 819 | list [binary scan \x52 h3 arg1] $arg1 |
---|
| 820 | } {0 foo} |
---|
| 821 | test binary-24.9 {Tcl_BinaryObjCmd: scan} { |
---|
| 822 | catch {unset arg1} |
---|
| 823 | set arg1 1 |
---|
| 824 | list [catch {binary scan \x52\x53 h1 arg1(a)} msg] $msg |
---|
| 825 | } {1 {can't set "arg1(a)": variable isn't array}} |
---|
| 826 | test binary-24.10 {Tcl_BinaryObjCmd: scan} { |
---|
| 827 | catch {unset arg1 arg2} |
---|
| 828 | set arg1 foo |
---|
| 829 | set arg2 bar |
---|
| 830 | list [binary scan \x70\x87\x05 h2h* arg1 arg2] $arg1 $arg2 |
---|
| 831 | } {2 07 7850} |
---|
| 832 | |
---|
| 833 | test binary-25.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 834 | list [catch {binary scan abc H} msg] $msg |
---|
| 835 | } {1 {not enough arguments for all format specifiers}} |
---|
| 836 | test binary-25.2 {Tcl_BinaryObjCmd: scan} { |
---|
| 837 | catch {unset arg1} |
---|
| 838 | list [binary scan \x52\xa3 H* arg1] $arg1 |
---|
| 839 | } {1 52a3} |
---|
| 840 | test binary-25.3 {Tcl_BinaryObjCmd: scan} { |
---|
| 841 | catch {unset arg1} |
---|
| 842 | list [binary scan \xc2\xa3 H arg1] $arg1 |
---|
| 843 | } {1 c} |
---|
| 844 | test binary-25.4 {Tcl_BinaryObjCmd: scan} { |
---|
| 845 | catch {unset arg1} |
---|
| 846 | list [binary scan \x82\x53 H1 arg1] $arg1 |
---|
| 847 | } {1 8} |
---|
| 848 | test binary-25.5 {Tcl_BinaryObjCmd: scan} { |
---|
| 849 | catch {unset arg1} |
---|
| 850 | list [binary scan \x52\x53 H0 arg1] $arg1 |
---|
| 851 | } {1 {}} |
---|
| 852 | test binary-25.6 {Tcl_BinaryObjCmd: scan} { |
---|
| 853 | catch {unset arg1} |
---|
| 854 | list [binary scan \xf2\x53 H2 arg1] $arg1 |
---|
| 855 | } {1 f2} |
---|
| 856 | test binary-25.7 {Tcl_BinaryObjCmd: scan} { |
---|
| 857 | catch {unset arg1} |
---|
| 858 | list [binary scan \x52\x53 H3 arg1] $arg1 |
---|
| 859 | } {1 525} |
---|
| 860 | test binary-25.8 {Tcl_BinaryObjCmd: scan} { |
---|
| 861 | catch {unset arg1} |
---|
| 862 | set arg1 foo |
---|
| 863 | list [binary scan \x52 H3 arg1] $arg1 |
---|
| 864 | } {0 foo} |
---|
| 865 | test binary-25.9 {Tcl_BinaryObjCmd: scan} { |
---|
| 866 | catch {unset arg1} |
---|
| 867 | set arg1 1 |
---|
| 868 | list [catch {binary scan \x52\x53 H1 arg1(a)} msg] $msg |
---|
| 869 | } {1 {can't set "arg1(a)": variable isn't array}} |
---|
| 870 | test binary-25.10 {Tcl_BinaryObjCmd: scan} { |
---|
| 871 | catch {unset arg1 arg2} |
---|
| 872 | set arg1 foo |
---|
| 873 | set arg2 bar |
---|
| 874 | list [binary scan \x70\x87\x05 H2H* arg1 arg2] $arg1 $arg2 |
---|
| 875 | } {2 70 8705} |
---|
| 876 | |
---|
| 877 | test binary-26.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 878 | list [catch {binary scan abc c} msg] $msg |
---|
| 879 | } {1 {not enough arguments for all format specifiers}} |
---|
| 880 | test binary-26.2 {Tcl_BinaryObjCmd: scan} { |
---|
| 881 | catch {unset arg1} |
---|
| 882 | list [binary scan \x52\xa3 c* arg1] $arg1 |
---|
| 883 | } {1 {82 -93}} |
---|
| 884 | test binary-26.3 {Tcl_BinaryObjCmd: scan} { |
---|
| 885 | catch {unset arg1} |
---|
| 886 | list [binary scan \x52\xa3 c arg1] $arg1 |
---|
| 887 | } {1 82} |
---|
| 888 | test binary-26.4 {Tcl_BinaryObjCmd: scan} { |
---|
| 889 | catch {unset arg1} |
---|
| 890 | list [binary scan \x52\xa3 c1 arg1] $arg1 |
---|
| 891 | } {1 82} |
---|
| 892 | test binary-26.5 {Tcl_BinaryObjCmd: scan} { |
---|
| 893 | catch {unset arg1} |
---|
| 894 | list [binary scan \x52\xa3 c0 arg1] $arg1 |
---|
| 895 | } {1 {}} |
---|
| 896 | test binary-26.6 {Tcl_BinaryObjCmd: scan} { |
---|
| 897 | catch {unset arg1} |
---|
| 898 | list [binary scan \x52\xa3 c2 arg1] $arg1 |
---|
| 899 | } {1 {82 -93}} |
---|
| 900 | test binary-26.7 {Tcl_BinaryObjCmd: scan} { |
---|
| 901 | catch {unset arg1} |
---|
| 902 | list [binary scan \xff c arg1] $arg1 |
---|
| 903 | } {1 -1} |
---|
| 904 | test binary-26.8 {Tcl_BinaryObjCmd: scan} { |
---|
| 905 | catch {unset arg1} |
---|
| 906 | set arg1 foo |
---|
| 907 | list [binary scan \x52 c3 arg1] $arg1 |
---|
| 908 | } {0 foo} |
---|
| 909 | test binary-26.9 {Tcl_BinaryObjCmd: scan} { |
---|
| 910 | catch {unset arg1} |
---|
| 911 | set arg1 1 |
---|
| 912 | list [catch {binary scan \x52\x53 c1 arg1(a)} msg] $msg |
---|
| 913 | } {1 {can't set "arg1(a)": variable isn't array}} |
---|
| 914 | test binary-26.10 {Tcl_BinaryObjCmd: scan} { |
---|
| 915 | catch {unset arg1 arg2} |
---|
| 916 | set arg1 foo |
---|
| 917 | set arg2 bar |
---|
| 918 | list [binary scan \x70\x87\x05 c2c* arg1 arg2] $arg1 $arg2 |
---|
| 919 | } {2 {112 -121} 5} |
---|
| 920 | test binary-26.11 {Tcl_BinaryObjCmd: scan} { |
---|
| 921 | catch {unset arg1} |
---|
| 922 | list [binary scan \x52\xa3 cu* arg1] $arg1 |
---|
| 923 | } {1 {82 163}} |
---|
| 924 | test binary-26.12 {Tcl_BinaryObjCmd: scan} { |
---|
| 925 | catch {unset arg1} |
---|
| 926 | list [binary scan \x52\xa3 cu arg1] $arg1 |
---|
| 927 | } {1 82} |
---|
| 928 | test binary-26.13 {Tcl_BinaryObjCmd: scan} { |
---|
| 929 | catch {unset arg1} |
---|
| 930 | list [binary scan \xff cu arg1] $arg1 |
---|
| 931 | } {1 255} |
---|
| 932 | test binary-26.14 {Tcl_BinaryObjCmd: scan} { |
---|
| 933 | catch {unset arg1 arg2} |
---|
| 934 | set arg1 foo |
---|
| 935 | set arg2 bar |
---|
| 936 | list [binary scan \x80\x80 cuc arg1 arg2] $arg1 $arg2 |
---|
| 937 | } {2 128 -128} |
---|
| 938 | test binary-26.15 {Tcl_BinaryObjCmd: scan} { |
---|
| 939 | catch {unset arg1 arg2} |
---|
| 940 | set arg1 foo |
---|
| 941 | set arg2 bar |
---|
| 942 | list [binary scan \x80\x80 ccu arg1 arg2] $arg1 $arg2 |
---|
| 943 | } {2 -128 128} |
---|
| 944 | |
---|
| 945 | test binary-27.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 946 | list [catch {binary scan abc s} msg] $msg |
---|
| 947 | } {1 {not enough arguments for all format specifiers}} |
---|
| 948 | test binary-27.2 {Tcl_BinaryObjCmd: scan} { |
---|
| 949 | catch {unset arg1} |
---|
| 950 | list [binary scan \x52\xa3\x53\x54 s* arg1] $arg1 |
---|
| 951 | } {1 {-23726 21587}} |
---|
| 952 | test binary-27.3 {Tcl_BinaryObjCmd: scan} { |
---|
| 953 | catch {unset arg1} |
---|
| 954 | list [binary scan \x52\xa3\x53\x54 s arg1] $arg1 |
---|
| 955 | } {1 -23726} |
---|
| 956 | test binary-27.4 {Tcl_BinaryObjCmd: scan} { |
---|
| 957 | catch {unset arg1} |
---|
| 958 | list [binary scan \x52\xa3 s1 arg1] $arg1 |
---|
| 959 | } {1 -23726} |
---|
| 960 | test binary-27.5 {Tcl_BinaryObjCmd: scan} { |
---|
| 961 | catch {unset arg1} |
---|
| 962 | list [binary scan \x52\xa3 s0 arg1] $arg1 |
---|
| 963 | } {1 {}} |
---|
| 964 | test binary-27.6 {Tcl_BinaryObjCmd: scan} { |
---|
| 965 | catch {unset arg1} |
---|
| 966 | list [binary scan \x52\xa3\x53\x54 s2 arg1] $arg1 |
---|
| 967 | } {1 {-23726 21587}} |
---|
| 968 | test binary-27.7 {Tcl_BinaryObjCmd: scan} { |
---|
| 969 | catch {unset arg1} |
---|
| 970 | set arg1 foo |
---|
| 971 | list [binary scan \x52 s1 arg1] $arg1 |
---|
| 972 | } {0 foo} |
---|
| 973 | test binary-27.8 {Tcl_BinaryObjCmd: scan} { |
---|
| 974 | catch {unset arg1} |
---|
| 975 | set arg1 1 |
---|
| 976 | list [catch {binary scan \x52\x53 s1 arg1(a)} msg] $msg |
---|
| 977 | } {1 {can't set "arg1(a)": variable isn't array}} |
---|
| 978 | test binary-27.9 {Tcl_BinaryObjCmd: scan} { |
---|
| 979 | catch {unset arg1 arg2} |
---|
| 980 | set arg1 foo |
---|
| 981 | set arg2 bar |
---|
| 982 | list [binary scan \x52\xa3\x53\x54\x05 s2c* arg1 arg2] $arg1 $arg2 |
---|
| 983 | } {2 {-23726 21587} 5} |
---|
| 984 | test binary-27.10 {Tcl_BinaryObjCmd: scan} { |
---|
| 985 | catch {unset arg1} |
---|
| 986 | list [binary scan \x52\xa3\x53\x54 su* arg1] $arg1 |
---|
| 987 | } {1 {41810 21587}} |
---|
| 988 | test binary-27.11 {Tcl_BinaryObjCmd: scan} { |
---|
| 989 | catch {unset arg1 arg2} |
---|
| 990 | set arg1 foo |
---|
| 991 | set arg2 bar |
---|
| 992 | list [binary scan \xff\xff\xff\xff sus arg1 arg2] $arg1 $arg2 |
---|
| 993 | } {2 65535 -1} |
---|
| 994 | test binary-27.12 {Tcl_BinaryObjCmd: scan} { |
---|
| 995 | catch {unset arg1 arg2} |
---|
| 996 | set arg1 foo |
---|
| 997 | set arg2 bar |
---|
| 998 | list [binary scan \xff\xff\xff\xff ssu arg1 arg2] $arg1 $arg2 |
---|
| 999 | } {2 -1 65535} |
---|
| 1000 | |
---|
| 1001 | test binary-28.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 1002 | list [catch {binary scan abc S} msg] $msg |
---|
| 1003 | } {1 {not enough arguments for all format specifiers}} |
---|
| 1004 | test binary-28.2 {Tcl_BinaryObjCmd: scan} { |
---|
| 1005 | catch {unset arg1} |
---|
| 1006 | list [binary scan \x52\xa3\x53\x54 S* arg1] $arg1 |
---|
| 1007 | } {1 {21155 21332}} |
---|
| 1008 | test binary-28.3 {Tcl_BinaryObjCmd: scan} { |
---|
| 1009 | catch {unset arg1} |
---|
| 1010 | list [binary scan \x52\xa3\x53\x54 S arg1] $arg1 |
---|
| 1011 | } {1 21155} |
---|
| 1012 | test binary-28.4 {Tcl_BinaryObjCmd: scan} { |
---|
| 1013 | catch {unset arg1} |
---|
| 1014 | list [binary scan \x52\xa3 S1 arg1] $arg1 |
---|
| 1015 | } {1 21155} |
---|
| 1016 | test binary-28.5 {Tcl_BinaryObjCmd: scan} { |
---|
| 1017 | catch {unset arg1} |
---|
| 1018 | list [binary scan \x52\xa3 S0 arg1] $arg1 |
---|
| 1019 | } {1 {}} |
---|
| 1020 | test binary-28.6 {Tcl_BinaryObjCmd: scan} { |
---|
| 1021 | catch {unset arg1} |
---|
| 1022 | list [binary scan \x52\xa3\x53\x54 S2 arg1] $arg1 |
---|
| 1023 | } {1 {21155 21332}} |
---|
| 1024 | test binary-28.7 {Tcl_BinaryObjCmd: scan} { |
---|
| 1025 | catch {unset arg1} |
---|
| 1026 | set arg1 foo |
---|
| 1027 | list [binary scan \x52 S1 arg1] $arg1 |
---|
| 1028 | } {0 foo} |
---|
| 1029 | test binary-28.8 {Tcl_BinaryObjCmd: scan} { |
---|
| 1030 | catch {unset arg1} |
---|
| 1031 | set arg1 1 |
---|
| 1032 | list [catch {binary scan \x52\x53 S1 arg1(a)} msg] $msg |
---|
| 1033 | } {1 {can't set "arg1(a)": variable isn't array}} |
---|
| 1034 | test binary-28.9 {Tcl_BinaryObjCmd: scan} { |
---|
| 1035 | catch {unset arg1 arg2} |
---|
| 1036 | set arg1 foo |
---|
| 1037 | set arg2 bar |
---|
| 1038 | list [binary scan \x52\xa3\x53\x54\x05 S2c* arg1 arg2] $arg1 $arg2 |
---|
| 1039 | } {2 {21155 21332} 5} |
---|
| 1040 | test binary-28.10 {Tcl_BinaryObjCmd: scan} { |
---|
| 1041 | catch {unset arg1} |
---|
| 1042 | list [binary scan \x52\xa3\x53\x54 Su* arg1] $arg1 |
---|
| 1043 | } {1 {21155 21332}} |
---|
| 1044 | test binary-28.11 {Tcl_BinaryObjCmd: scan} { |
---|
| 1045 | catch {unset arg1} |
---|
| 1046 | list [binary scan \xa3\x52\x54\x53 Su* arg1] $arg1 |
---|
| 1047 | } {1 {41810 21587}} |
---|
| 1048 | |
---|
| 1049 | test binary-29.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 1050 | list [catch {binary scan abc i} msg] $msg |
---|
| 1051 | } {1 {not enough arguments for all format specifiers}} |
---|
| 1052 | test binary-29.2 {Tcl_BinaryObjCmd: scan} { |
---|
| 1053 | catch {unset arg1} |
---|
| 1054 | list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 i* arg1] $arg1 |
---|
| 1055 | } {1 {1414767442 67305985}} |
---|
| 1056 | test binary-29.3 {Tcl_BinaryObjCmd: scan} { |
---|
| 1057 | catch {unset arg1} |
---|
| 1058 | list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 i arg1] $arg1 |
---|
| 1059 | } {1 1414767442} |
---|
| 1060 | test binary-29.4 {Tcl_BinaryObjCmd: scan} { |
---|
| 1061 | catch {unset arg1} |
---|
| 1062 | list [binary scan \x52\xa3\x53\x54 i1 arg1] $arg1 |
---|
| 1063 | } {1 1414767442} |
---|
| 1064 | test binary-29.5 {Tcl_BinaryObjCmd: scan} { |
---|
| 1065 | catch {unset arg1} |
---|
| 1066 | list [binary scan \x52\xa3\x53 i0 arg1] $arg1 |
---|
| 1067 | } {1 {}} |
---|
| 1068 | test binary-29.6 {Tcl_BinaryObjCmd: scan} { |
---|
| 1069 | catch {unset arg1} |
---|
| 1070 | list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 i2 arg1] $arg1 |
---|
| 1071 | } {1 {1414767442 67305985}} |
---|
| 1072 | test binary-29.7 {Tcl_BinaryObjCmd: scan} { |
---|
| 1073 | catch {unset arg1} |
---|
| 1074 | set arg1 foo |
---|
| 1075 | list [binary scan \x52 i1 arg1] $arg1 |
---|
| 1076 | } {0 foo} |
---|
| 1077 | test binary-29.8 {Tcl_BinaryObjCmd: scan} { |
---|
| 1078 | catch {unset arg1} |
---|
| 1079 | set arg1 1 |
---|
| 1080 | list [catch {binary scan \x52\x53\x53\x54 i1 arg1(a)} msg] $msg |
---|
| 1081 | } {1 {can't set "arg1(a)": variable isn't array}} |
---|
| 1082 | test binary-29.9 {Tcl_BinaryObjCmd: scan} { |
---|
| 1083 | catch {unset arg1 arg2} |
---|
| 1084 | set arg1 foo |
---|
| 1085 | set arg2 bar |
---|
| 1086 | list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04\x05 i2c* arg1 arg2] $arg1 $arg2 |
---|
| 1087 | } {2 {1414767442 67305985} 5} |
---|
| 1088 | test binary-29.10 {Tcl_BinaryObjCmd: scan} { |
---|
| 1089 | catch {unset arg1 arg2} |
---|
| 1090 | list [binary scan \xff\xff\xff\xff\xff\xff\xff\xff iui arg1 arg2] $arg1 $arg2 |
---|
| 1091 | } {2 4294967295 -1} |
---|
| 1092 | test binary-29.11 {Tcl_BinaryObjCmd: scan} { |
---|
| 1093 | catch {unset arg1 arg2} |
---|
| 1094 | list [binary scan \xff\xff\xff\xff\xff\xff\xff\xff iiu arg1 arg2] $arg1 $arg2 |
---|
| 1095 | } {2 -1 4294967295} |
---|
| 1096 | test binary-29.12 {Tcl_BinaryObjCmd: scan} { |
---|
| 1097 | catch {unset arg1 arg2} |
---|
| 1098 | list [binary scan \x80\x00\x00\x00\x00\x00\x00\x80 iuiu arg1 arg2] $arg1 $arg2 |
---|
| 1099 | } {2 128 2147483648} |
---|
| 1100 | |
---|
| 1101 | test binary-30.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 1102 | list [catch {binary scan abc I} msg] $msg |
---|
| 1103 | } {1 {not enough arguments for all format specifiers}} |
---|
| 1104 | test binary-30.2 {Tcl_BinaryObjCmd: scan} { |
---|
| 1105 | catch {unset arg1} |
---|
| 1106 | list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 I* arg1] $arg1 |
---|
| 1107 | } {1 {1386435412 16909060}} |
---|
| 1108 | test binary-30.3 {Tcl_BinaryObjCmd: scan} { |
---|
| 1109 | catch {unset arg1} |
---|
| 1110 | list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 I arg1] $arg1 |
---|
| 1111 | } {1 1386435412} |
---|
| 1112 | test binary-30.4 {Tcl_BinaryObjCmd: scan} { |
---|
| 1113 | catch {unset arg1} |
---|
| 1114 | list [binary scan \x52\xa3\x53\x54 I1 arg1] $arg1 |
---|
| 1115 | } {1 1386435412} |
---|
| 1116 | test binary-30.5 {Tcl_BinaryObjCmd: scan} { |
---|
| 1117 | catch {unset arg1} |
---|
| 1118 | list [binary scan \x52\xa3\x53 I0 arg1] $arg1 |
---|
| 1119 | } {1 {}} |
---|
| 1120 | test binary-30.6 {Tcl_BinaryObjCmd: scan} { |
---|
| 1121 | catch {unset arg1} |
---|
| 1122 | list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 I2 arg1] $arg1 |
---|
| 1123 | } {1 {1386435412 16909060}} |
---|
| 1124 | test binary-30.7 {Tcl_BinaryObjCmd: scan} { |
---|
| 1125 | catch {unset arg1} |
---|
| 1126 | set arg1 foo |
---|
| 1127 | list [binary scan \x52 I1 arg1] $arg1 |
---|
| 1128 | } {0 foo} |
---|
| 1129 | test binary-30.8 {Tcl_BinaryObjCmd: scan} { |
---|
| 1130 | catch {unset arg1} |
---|
| 1131 | set arg1 1 |
---|
| 1132 | list [catch {binary scan \x52\x53\x53\x54 I1 arg1(a)} msg] $msg |
---|
| 1133 | } {1 {can't set "arg1(a)": variable isn't array}} |
---|
| 1134 | test binary-30.9 {Tcl_BinaryObjCmd: scan} { |
---|
| 1135 | catch {unset arg1 arg2} |
---|
| 1136 | set arg1 foo |
---|
| 1137 | set arg2 bar |
---|
| 1138 | list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04\x05 I2c* arg1 arg2] $arg1 $arg2 |
---|
| 1139 | } {2 {1386435412 16909060} 5} |
---|
| 1140 | test binary-30.10 {Tcl_BinaryObjCmd: scan} { |
---|
| 1141 | catch {unset arg1 arg2} |
---|
| 1142 | list [binary scan \xff\xff\xff\xff\xff\xff\xff\xff IuI arg1 arg2] $arg1 $arg2 |
---|
| 1143 | } {2 4294967295 -1} |
---|
| 1144 | test binary-30.11 {Tcl_BinaryObjCmd: scan} { |
---|
| 1145 | catch {unset arg1 arg2} |
---|
| 1146 | list [binary scan \xff\xff\xff\xff\xff\xff\xff\xff IIu arg1 arg2] $arg1 $arg2 |
---|
| 1147 | } {2 -1 4294967295} |
---|
| 1148 | test binary-30.12 {Tcl_BinaryObjCmd: scan} { |
---|
| 1149 | catch {unset arg1 arg2} |
---|
| 1150 | list [binary scan \x80\x00\x00\x00\x00\x00\x00\x80 IuIu arg1 arg2] $arg1 $arg2 |
---|
| 1151 | } {2 2147483648 128} |
---|
| 1152 | |
---|
| 1153 | test binary-31.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 1154 | list [catch {binary scan abc f} msg] $msg |
---|
| 1155 | } {1 {not enough arguments for all format specifiers}} |
---|
| 1156 | test binary-31.2 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 1157 | catch {unset arg1} |
---|
| 1158 | list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a f* arg1] $arg1 |
---|
| 1159 | } {1 {1.600000023841858 3.4000000953674316}} |
---|
| 1160 | test binary-31.3 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1161 | catch {unset arg1} |
---|
| 1162 | list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 f* arg1] $arg1 |
---|
| 1163 | } {1 {1.600000023841858 3.4000000953674316}} |
---|
| 1164 | test binary-31.4 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 1165 | catch {unset arg1} |
---|
| 1166 | list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a f arg1] $arg1 |
---|
| 1167 | } {1 1.600000023841858} |
---|
| 1168 | test binary-31.5 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1169 | catch {unset arg1} |
---|
| 1170 | list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 f arg1] $arg1 |
---|
| 1171 | } {1 1.600000023841858} |
---|
| 1172 | test binary-31.6 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 1173 | catch {unset arg1} |
---|
| 1174 | list [binary scan \x3f\xcc\xcc\xcd f1 arg1] $arg1 |
---|
| 1175 | } {1 1.600000023841858} |
---|
| 1176 | test binary-31.7 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1177 | catch {unset arg1} |
---|
| 1178 | list [binary scan \xcd\xcc\xcc\x3f f1 arg1] $arg1 |
---|
| 1179 | } {1 1.600000023841858} |
---|
| 1180 | test binary-31.8 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 1181 | catch {unset arg1} |
---|
| 1182 | list [binary scan \x3f\xcc\xcc\xcd f0 arg1] $arg1 |
---|
| 1183 | } {1 {}} |
---|
| 1184 | test binary-31.9 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1185 | catch {unset arg1} |
---|
| 1186 | list [binary scan \xcd\xcc\xcc\x3f f0 arg1] $arg1 |
---|
| 1187 | } {1 {}} |
---|
| 1188 | test binary-31.10 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 1189 | catch {unset arg1} |
---|
| 1190 | list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a f2 arg1] $arg1 |
---|
| 1191 | } {1 {1.600000023841858 3.4000000953674316}} |
---|
| 1192 | test binary-31.11 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1193 | catch {unset arg1} |
---|
| 1194 | list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 f2 arg1] $arg1 |
---|
| 1195 | } {1 {1.600000023841858 3.4000000953674316}} |
---|
| 1196 | test binary-31.12 {Tcl_BinaryObjCmd: scan} { |
---|
| 1197 | catch {unset arg1} |
---|
| 1198 | set arg1 foo |
---|
| 1199 | list [binary scan \x52 f1 arg1] $arg1 |
---|
| 1200 | } {0 foo} |
---|
| 1201 | test binary-31.13 {Tcl_BinaryObjCmd: scan} { |
---|
| 1202 | catch {unset arg1} |
---|
| 1203 | set arg1 1 |
---|
| 1204 | list [catch {binary scan \x3f\xcc\xcc\xcd f1 arg1(a)} msg] $msg |
---|
| 1205 | } {1 {can't set "arg1(a)": variable isn't array}} |
---|
| 1206 | test binary-31.14 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 1207 | catch {unset arg1 arg2} |
---|
| 1208 | set arg1 foo |
---|
| 1209 | set arg2 bar |
---|
| 1210 | list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a\x05 f2c* arg1 arg2] $arg1 $arg2 |
---|
| 1211 | } {2 {1.600000023841858 3.4000000953674316} 5} |
---|
| 1212 | test binary-31.15 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1213 | catch {unset arg1 arg2} |
---|
| 1214 | set arg1 foo |
---|
| 1215 | set arg2 bar |
---|
| 1216 | list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40\x05 f2c* arg1 arg2] $arg1 $arg2 |
---|
| 1217 | } {2 {1.600000023841858 3.4000000953674316} 5} |
---|
| 1218 | |
---|
| 1219 | test binary-32.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 1220 | list [catch {binary scan abc d} msg] $msg |
---|
| 1221 | } {1 {not enough arguments for all format specifiers}} |
---|
| 1222 | test binary-32.2 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 1223 | catch {unset arg1} |
---|
| 1224 | list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 d* arg1] $arg1 |
---|
| 1225 | } {1 {1.6 3.4}} |
---|
| 1226 | test binary-32.3 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1227 | catch {unset arg1} |
---|
| 1228 | list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 d* arg1] $arg1 |
---|
| 1229 | } {1 {1.6 3.4}} |
---|
| 1230 | test binary-32.4 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 1231 | catch {unset arg1} |
---|
| 1232 | list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 d arg1] $arg1 |
---|
| 1233 | } {1 1.6} |
---|
| 1234 | test binary-32.5 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1235 | catch {unset arg1} |
---|
| 1236 | list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 d arg1] $arg1 |
---|
| 1237 | } {1 1.6} |
---|
| 1238 | test binary-32.6 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 1239 | catch {unset arg1} |
---|
| 1240 | list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a d1 arg1] $arg1 |
---|
| 1241 | } {1 1.6} |
---|
| 1242 | test binary-32.7 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1243 | catch {unset arg1} |
---|
| 1244 | list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f d1 arg1] $arg1 |
---|
| 1245 | } {1 1.6} |
---|
| 1246 | test binary-32.8 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 1247 | catch {unset arg1} |
---|
| 1248 | list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a d0 arg1] $arg1 |
---|
| 1249 | } {1 {}} |
---|
| 1250 | test binary-32.9 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1251 | catch {unset arg1} |
---|
| 1252 | list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f d0 arg1] $arg1 |
---|
| 1253 | } {1 {}} |
---|
| 1254 | test binary-32.10 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 1255 | catch {unset arg1} |
---|
| 1256 | list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 d2 arg1] $arg1 |
---|
| 1257 | } {1 {1.6 3.4}} |
---|
| 1258 | test binary-32.11 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1259 | catch {unset arg1} |
---|
| 1260 | list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 d2 arg1] $arg1 |
---|
| 1261 | } {1 {1.6 3.4}} |
---|
| 1262 | test binary-32.12 {Tcl_BinaryObjCmd: scan} { |
---|
| 1263 | catch {unset arg1} |
---|
| 1264 | set arg1 foo |
---|
| 1265 | list [binary scan \x52 d1 arg1] $arg1 |
---|
| 1266 | } {0 foo} |
---|
| 1267 | test binary-32.13 {Tcl_BinaryObjCmd: scan} { |
---|
| 1268 | catch {unset arg1} |
---|
| 1269 | set arg1 1 |
---|
| 1270 | list [catch {binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a d1 arg1(a)} msg] $msg |
---|
| 1271 | } {1 {can't set "arg1(a)": variable isn't array}} |
---|
| 1272 | test binary-32.14 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 1273 | catch {unset arg1 arg2} |
---|
| 1274 | set arg1 foo |
---|
| 1275 | set arg2 bar |
---|
| 1276 | 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 |
---|
| 1277 | } {2 {1.6 3.4} 5} |
---|
| 1278 | test binary-32.15 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1279 | catch {unset arg1 arg2} |
---|
| 1280 | set arg1 foo |
---|
| 1281 | set arg2 bar |
---|
| 1282 | 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 |
---|
| 1283 | } {2 {1.6 3.4} 5} |
---|
| 1284 | |
---|
| 1285 | test binary-33.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 1286 | catch {unset arg1} |
---|
| 1287 | catch {unset arg2} |
---|
| 1288 | list [binary scan abcdefg a2xa3 arg1 arg2] $arg1 $arg2 |
---|
| 1289 | } {2 ab def} |
---|
| 1290 | test binary-33.2 {Tcl_BinaryObjCmd: scan} { |
---|
| 1291 | catch {unset arg1} |
---|
| 1292 | catch {unset arg2} |
---|
| 1293 | set arg2 foo |
---|
| 1294 | list [binary scan abcdefg a3x*a3 arg1 arg2] $arg1 $arg2 |
---|
| 1295 | } {1 abc foo} |
---|
| 1296 | test binary-33.3 {Tcl_BinaryObjCmd: scan} { |
---|
| 1297 | catch {unset arg1} |
---|
| 1298 | catch {unset arg2} |
---|
| 1299 | set arg2 foo |
---|
| 1300 | list [binary scan abcdefg a3x20a3 arg1 arg2] $arg1 $arg2 |
---|
| 1301 | } {1 abc foo} |
---|
| 1302 | test binary-33.4 {Tcl_BinaryObjCmd: scan} { |
---|
| 1303 | catch {unset arg1} |
---|
| 1304 | catch {unset arg2} |
---|
| 1305 | set arg2 foo |
---|
| 1306 | list [binary scan abc a3x20a3 arg1 arg2] $arg1 $arg2 |
---|
| 1307 | } {1 abc foo} |
---|
| 1308 | test binary-33.5 {Tcl_BinaryObjCmd: scan} { |
---|
| 1309 | catch {unset arg1} |
---|
| 1310 | list [binary scan abcdef x1a1 arg1] $arg1 |
---|
| 1311 | } {1 b} |
---|
| 1312 | test binary-33.6 {Tcl_BinaryObjCmd: scan} { |
---|
| 1313 | catch {unset arg1} |
---|
| 1314 | list [binary scan abcdef x5a1 arg1] $arg1 |
---|
| 1315 | } {1 f} |
---|
| 1316 | test binary-33.7 {Tcl_BinaryObjCmd: scan} { |
---|
| 1317 | catch {unset arg1} |
---|
| 1318 | list [binary scan abcdef x0a1 arg1] $arg1 |
---|
| 1319 | } {1 a} |
---|
| 1320 | |
---|
| 1321 | test binary-34.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 1322 | catch {unset arg1} |
---|
| 1323 | catch {unset arg2} |
---|
| 1324 | list [binary scan abcdefg a2Xa3 arg1 arg2] $arg1 $arg2 |
---|
| 1325 | } {2 ab bcd} |
---|
| 1326 | test binary-34.2 {Tcl_BinaryObjCmd: scan} { |
---|
| 1327 | catch {unset arg1} |
---|
| 1328 | catch {unset arg2} |
---|
| 1329 | set arg2 foo |
---|
| 1330 | list [binary scan abcdefg a3X*a3 arg1 arg2] $arg1 $arg2 |
---|
| 1331 | } {2 abc abc} |
---|
| 1332 | test binary-34.3 {Tcl_BinaryObjCmd: scan} { |
---|
| 1333 | catch {unset arg1} |
---|
| 1334 | catch {unset arg2} |
---|
| 1335 | set arg2 foo |
---|
| 1336 | list [binary scan abcdefg a3X20a3 arg1 arg2] $arg1 $arg2 |
---|
| 1337 | } {2 abc abc} |
---|
| 1338 | test binary-34.4 {Tcl_BinaryObjCmd: scan} { |
---|
| 1339 | catch {unset arg1} |
---|
| 1340 | list [binary scan abc X20a3 arg1] $arg1 |
---|
| 1341 | } {1 abc} |
---|
| 1342 | test binary-34.5 {Tcl_BinaryObjCmd: scan} { |
---|
| 1343 | catch {unset arg1} |
---|
| 1344 | list [binary scan abcdef x*X1a1 arg1] $arg1 |
---|
| 1345 | } {1 f} |
---|
| 1346 | test binary-34.6 {Tcl_BinaryObjCmd: scan} { |
---|
| 1347 | catch {unset arg1} |
---|
| 1348 | list [binary scan abcdef x*X5a1 arg1] $arg1 |
---|
| 1349 | } {1 b} |
---|
| 1350 | test binary-34.7 {Tcl_BinaryObjCmd: scan} { |
---|
| 1351 | catch {unset arg1} |
---|
| 1352 | list [binary scan abcdef x3X0a1 arg1] $arg1 |
---|
| 1353 | } {1 d} |
---|
| 1354 | |
---|
| 1355 | test binary-35.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 1356 | catch {unset arg1} |
---|
| 1357 | catch {unset arg2} |
---|
| 1358 | list [catch {binary scan abcdefg a2@a3 arg1 arg2} msg] $msg |
---|
| 1359 | } {1 {missing count for "@" field specifier}} |
---|
| 1360 | test binary-35.2 {Tcl_BinaryObjCmd: scan} { |
---|
| 1361 | catch {unset arg1} |
---|
| 1362 | catch {unset arg2} |
---|
| 1363 | set arg2 foo |
---|
| 1364 | list [binary scan abcdefg a3@*a3 arg1 arg2] $arg1 $arg2 |
---|
| 1365 | } {1 abc foo} |
---|
| 1366 | test binary-35.3 {Tcl_BinaryObjCmd: scan} { |
---|
| 1367 | catch {unset arg1} |
---|
| 1368 | catch {unset arg2} |
---|
| 1369 | set arg2 foo |
---|
| 1370 | list [binary scan abcdefg a3@20a3 arg1 arg2] $arg1 $arg2 |
---|
| 1371 | } {1 abc foo} |
---|
| 1372 | test binary-35.4 {Tcl_BinaryObjCmd: scan} { |
---|
| 1373 | catch {unset arg1} |
---|
| 1374 | list [binary scan abcdef @2a3 arg1] $arg1 |
---|
| 1375 | } {1 cde} |
---|
| 1376 | test binary-35.5 {Tcl_BinaryObjCmd: scan} { |
---|
| 1377 | catch {unset arg1} |
---|
| 1378 | list [binary scan abcdef x*@1a1 arg1] $arg1 |
---|
| 1379 | } {1 b} |
---|
| 1380 | test binary-35.6 {Tcl_BinaryObjCmd: scan} { |
---|
| 1381 | catch {unset arg1} |
---|
| 1382 | list [binary scan abcdef x*@0a1 arg1] $arg1 |
---|
| 1383 | } {1 a} |
---|
| 1384 | |
---|
| 1385 | test binary-36.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 1386 | list [catch {binary scan abcdef u0a3} msg] $msg |
---|
| 1387 | } {1 {bad field specifier "u"}} |
---|
| 1388 | |
---|
| 1389 | # GetFormatSpec is pretty thoroughly tested above, but there are a few |
---|
| 1390 | # cases we should text explicitly |
---|
| 1391 | |
---|
| 1392 | test binary-37.1 {GetFormatSpec: whitespace} { |
---|
| 1393 | binary format "a3 a5 a3" foo barblat baz |
---|
| 1394 | } foobarblbaz |
---|
| 1395 | test binary-37.2 {GetFormatSpec: whitespace} { |
---|
| 1396 | binary format " " foo |
---|
| 1397 | } {} |
---|
| 1398 | test binary-37.3 {GetFormatSpec: whitespace} { |
---|
| 1399 | binary format " a3" foo |
---|
| 1400 | } foo |
---|
| 1401 | test binary-37.4 {GetFormatSpec: whitespace} { |
---|
| 1402 | binary format "" foo |
---|
| 1403 | } {} |
---|
| 1404 | test binary-37.5 {GetFormatSpec: whitespace} { |
---|
| 1405 | binary format "" foo |
---|
| 1406 | } {} |
---|
| 1407 | test binary-37.6 {GetFormatSpec: whitespace} { |
---|
| 1408 | binary format " a3 " foo |
---|
| 1409 | } foo |
---|
| 1410 | test binary-37.7 {GetFormatSpec: numbers} { |
---|
| 1411 | list [catch {binary scan abcdef "x-1" foo} msg] $msg |
---|
| 1412 | } {1 {bad field specifier "-"}} |
---|
| 1413 | test binary-37.8 {GetFormatSpec: numbers} { |
---|
| 1414 | catch {unset arg1} |
---|
| 1415 | set arg1 foo |
---|
| 1416 | list [binary scan abcdef "a0x3" arg1] $arg1 |
---|
| 1417 | } {1 {}} |
---|
| 1418 | test binary-37.9 {GetFormatSpec: numbers} { |
---|
| 1419 | # test format of neg numbers |
---|
| 1420 | # bug report/fix provided by Harald Kirsch |
---|
| 1421 | set x [binary format f* {1 -1 2 -2 0}] |
---|
| 1422 | binary scan $x f* bla |
---|
| 1423 | set bla |
---|
| 1424 | } {1.0 -1.0 2.0 -2.0 0.0} |
---|
| 1425 | |
---|
| 1426 | test binary-38.1 {FormatNumber: word alignment} { |
---|
| 1427 | set x [binary format c1s1 1 1] |
---|
| 1428 | } \x01\x01\x00 |
---|
| 1429 | test binary-38.2 {FormatNumber: word alignment} { |
---|
| 1430 | set x [binary format c1S1 1 1] |
---|
| 1431 | } \x01\x00\x01 |
---|
| 1432 | test binary-38.3 {FormatNumber: word alignment} { |
---|
| 1433 | set x [binary format c1i1 1 1] |
---|
| 1434 | } \x01\x01\x00\x00\x00 |
---|
| 1435 | test binary-38.4 {FormatNumber: word alignment} { |
---|
| 1436 | set x [binary format c1I1 1 1] |
---|
| 1437 | } \x01\x00\x00\x00\x01 |
---|
| 1438 | test binary-38.5 {FormatNumber: word alignment} bigEndian { |
---|
| 1439 | set x [binary format c1d1 1 1.6] |
---|
| 1440 | } \x01\x3f\xf9\x99\x99\x99\x99\x99\x9a |
---|
| 1441 | test binary-38.6 {FormatNumber: word alignment} littleEndian { |
---|
| 1442 | set x [binary format c1d1 1 1.6] |
---|
| 1443 | } \x01\x9a\x99\x99\x99\x99\x99\xf9\x3f |
---|
| 1444 | test binary-38.7 {FormatNumber: word alignment} bigEndian { |
---|
| 1445 | set x [binary format c1f1 1 1.6] |
---|
| 1446 | } \x01\x3f\xcc\xcc\xcd |
---|
| 1447 | test binary-38.8 {FormatNumber: word alignment} littleEndian { |
---|
| 1448 | set x [binary format c1f1 1 1.6] |
---|
| 1449 | } \x01\xcd\xcc\xcc\x3f |
---|
| 1450 | |
---|
| 1451 | test binary-39.1 {ScanNumber: sign extension} { |
---|
| 1452 | catch {unset arg1} |
---|
| 1453 | list [binary scan \x52\xa3 c2 arg1] $arg1 |
---|
| 1454 | } {1 {82 -93}} |
---|
| 1455 | test binary-39.2 {ScanNumber: sign extension} { |
---|
| 1456 | catch {unset arg1} |
---|
| 1457 | list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 s4 arg1] $arg1 |
---|
| 1458 | } {1 {513 -32511 386 -32127}} |
---|
| 1459 | test binary-39.3 {ScanNumber: sign extension} { |
---|
| 1460 | catch {unset arg1} |
---|
| 1461 | list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 S4 arg1] $arg1 |
---|
| 1462 | } {1 {258 385 -32255 -32382}} |
---|
| 1463 | test binary-39.4 {ScanNumber: sign extension} { |
---|
| 1464 | catch {unset arg1} |
---|
| 1465 | 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 |
---|
| 1466 | } {1 {33620225 16843137 16876033 25297153 -2130640639}} |
---|
| 1467 | test binary-39.5 {ScanNumber: sign extension} { |
---|
| 1468 | catch {unset arg1} |
---|
| 1469 | 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 |
---|
| 1470 | } {1 {16843010 -2130640639 25297153 16876033 16843137}} |
---|
| 1471 | test binary-39.6 {ScanNumber: no sign extension} { |
---|
| 1472 | catch {unset arg1} |
---|
| 1473 | list [binary scan \x52\xa3 cu2 arg1] $arg1 |
---|
| 1474 | } {1 {82 163}} |
---|
| 1475 | test binary-39.7 {ScanNumber: no sign extension} { |
---|
| 1476 | catch {unset arg1} |
---|
| 1477 | list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 su4 arg1] $arg1 |
---|
| 1478 | } {1 {513 33025 386 33409}} |
---|
| 1479 | test binary-39.8 {ScanNumber: no sign extension} { |
---|
| 1480 | catch {unset arg1} |
---|
| 1481 | list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 Su4 arg1] $arg1 |
---|
| 1482 | } {1 {258 385 33281 33154}} |
---|
| 1483 | test binary-39.9 {ScanNumber: no sign extension} { |
---|
| 1484 | catch {unset arg1} |
---|
| 1485 | 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 |
---|
| 1486 | } {1 {33620225 16843137 16876033 25297153 2164326657}} |
---|
| 1487 | test binary-39.10 {ScanNumber: no sign extension} { |
---|
| 1488 | catch {unset arg1} |
---|
| 1489 | 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 |
---|
| 1490 | } {1 {16843010 2164326657 25297153 16876033 16843137}} |
---|
| 1491 | |
---|
| 1492 | test binary-40.3 {ScanNumber: NaN} \ |
---|
| 1493 | -body { |
---|
| 1494 | catch {unset arg1} |
---|
| 1495 | list [binary scan \xff\xff\xff\xff f1 arg1] $arg1 |
---|
| 1496 | } \ |
---|
| 1497 | -match glob \ |
---|
| 1498 | -result {1 -NaN*} |
---|
| 1499 | |
---|
| 1500 | test binary-40.4 {ScanNumber: NaN} \ |
---|
| 1501 | -body { |
---|
| 1502 | catch {unset arg1} |
---|
| 1503 | list [binary scan \xff\xff\xff\xff\xff\xff\xff\xff d arg1] $arg1 |
---|
| 1504 | } \ |
---|
| 1505 | -match glob \ |
---|
| 1506 | -result {1 -NaN*} |
---|
| 1507 | |
---|
| 1508 | test binary-41.1 {ScanNumber: word alignment} { |
---|
| 1509 | catch {unset arg1; unset arg2} |
---|
| 1510 | list [binary scan \x01\x01\x00 c1s1 arg1 arg2] $arg1 $arg2 |
---|
| 1511 | } {2 1 1} |
---|
| 1512 | test binary-41.2 {ScanNumber: word alignment} { |
---|
| 1513 | catch {unset arg1; unset arg2} |
---|
| 1514 | list [binary scan \x01\x00\x01 c1S1 arg1 arg2] $arg1 $arg2 |
---|
| 1515 | } {2 1 1} |
---|
| 1516 | test binary-41.3 {ScanNumber: word alignment} { |
---|
| 1517 | catch {unset arg1; unset arg2} |
---|
| 1518 | list [binary scan \x01\x01\x00\x00\x00 c1i1 arg1 arg2] $arg1 $arg2 |
---|
| 1519 | } {2 1 1} |
---|
| 1520 | test binary-41.4 {ScanNumber: word alignment} { |
---|
| 1521 | catch {unset arg1; unset arg2} |
---|
| 1522 | list [binary scan \x01\x00\x00\x00\x01 c1I1 arg1 arg2] $arg1 $arg2 |
---|
| 1523 | } {2 1 1} |
---|
| 1524 | test binary-41.5 {ScanNumber: word alignment} bigEndian { |
---|
| 1525 | catch {unset arg1; unset arg2} |
---|
| 1526 | list [binary scan \x01\x3f\xcc\xcc\xcd c1f1 arg1 arg2] $arg1 $arg2 |
---|
| 1527 | } {2 1 1.600000023841858} |
---|
| 1528 | test binary-41.6 {ScanNumber: word alignment} littleEndian { |
---|
| 1529 | catch {unset arg1; unset arg2} |
---|
| 1530 | list [binary scan \x01\xcd\xcc\xcc\x3f c1f1 arg1 arg2] $arg1 $arg2 |
---|
| 1531 | } {2 1 1.600000023841858} |
---|
| 1532 | test binary-41.7 {ScanNumber: word alignment} bigEndian { |
---|
| 1533 | catch {unset arg1; unset arg2} |
---|
| 1534 | list [binary scan \x01\x3f\xf9\x99\x99\x99\x99\x99\x9a c1d1 arg1 arg2] $arg1 $arg2 |
---|
| 1535 | } {2 1 1.6} |
---|
| 1536 | test binary-41.8 {ScanNumber: word alignment} littleEndian { |
---|
| 1537 | catch {unset arg1; unset arg2} |
---|
| 1538 | list [binary scan \x01\x9a\x99\x99\x99\x99\x99\xf9\x3f c1d1 arg1 arg2] $arg1 $arg2 |
---|
| 1539 | } {2 1 1.6} |
---|
| 1540 | |
---|
| 1541 | test binary-42.1 {Tcl_BinaryObjCmd: bad arguments} {} { |
---|
| 1542 | catch {binary ?} result |
---|
| 1543 | set result |
---|
| 1544 | } {bad option "?": must be format or scan} |
---|
| 1545 | |
---|
| 1546 | # Wide int (guaranteed at least 64-bit) handling |
---|
| 1547 | test binary-43.1 {Tcl_BinaryObjCmd: format wide int} {} { |
---|
| 1548 | binary format w 7810179016327718216 |
---|
| 1549 | } HelloTcl |
---|
| 1550 | test binary-43.2 {Tcl_BinaryObjCmd: format wide int} {} { |
---|
| 1551 | binary format W 7810179016327718216 |
---|
| 1552 | } lcTolleH |
---|
| 1553 | |
---|
| 1554 | test binary-44.1 {Tcl_BinaryObjCmd: scan wide int} {} { |
---|
| 1555 | binary scan HelloTcl W x |
---|
| 1556 | set x |
---|
| 1557 | } 5216694956358656876 |
---|
| 1558 | test binary-44.2 {Tcl_BinaryObjCmd: scan wide int} {} { |
---|
| 1559 | binary scan lcTolleH w x |
---|
| 1560 | set x |
---|
| 1561 | } 5216694956358656876 |
---|
| 1562 | test binary-44.3 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} {} { |
---|
| 1563 | binary scan [binary format w [expr {wide(3) << 31}]] w x |
---|
| 1564 | set x |
---|
| 1565 | } 6442450944 |
---|
| 1566 | test binary-44.4 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} {} { |
---|
| 1567 | binary scan [binary format W [expr {wide(3) << 31}]] W x |
---|
| 1568 | set x |
---|
| 1569 | } 6442450944 |
---|
| 1570 | test binary-43.5 {Tcl_BinaryObjCmd: scan wide int} {} { |
---|
| 1571 | catch {unset arg1} |
---|
| 1572 | list [binary scan \x80[string repeat \x00 7] W arg1] $arg1 |
---|
| 1573 | } {1 -9223372036854775808} |
---|
| 1574 | test binary-43.6 {Tcl_BinaryObjCmd: scan unsigned wide int} {} { |
---|
| 1575 | catch {unset arg1} |
---|
| 1576 | list [binary scan \x80[string repeat \x00 7] Wu arg1] $arg1 |
---|
| 1577 | } {1 9223372036854775808} |
---|
| 1578 | test binary-43.7 {Tcl_BinaryObjCmd: scan unsigned wide int} {} { |
---|
| 1579 | catch {unset arg1} |
---|
| 1580 | list [binary scan [string repeat \x00 7]\x80 wu arg1] $arg1 |
---|
| 1581 | } {1 9223372036854775808} |
---|
| 1582 | test binary-43.8 {Tcl_BinaryObjCmd: scan unsigned wide int} {} { |
---|
| 1583 | catch {unset arg1 arg2} |
---|
| 1584 | list [binary scan \x80[string repeat \x00 7]\x80[string repeat \x00 7] WuW arg1 arg2] $arg1 $arg2 |
---|
| 1585 | } {2 9223372036854775808 -9223372036854775808} |
---|
| 1586 | test binary-43.9 {Tcl_BinaryObjCmd: scan unsigned wide int} {} { |
---|
| 1587 | catch {unset arg1 arg2} |
---|
| 1588 | list [binary scan [string repeat \x00 7]\x80[string repeat \x00 7]\x80 wuw arg1 arg2] $arg1 $arg2 |
---|
| 1589 | } {2 9223372036854775808 -9223372036854775808} |
---|
| 1590 | |
---|
| 1591 | test binary-45.1 {Tcl_BinaryObjCmd: combined wide int handling} { |
---|
| 1592 | binary scan [binary format sws 16450 -1 19521] c* x |
---|
| 1593 | set x |
---|
| 1594 | } {66 64 -1 -1 -1 -1 -1 -1 -1 -1 65 76} |
---|
| 1595 | test binary-45.2 {Tcl_BinaryObjCmd: combined wide int handling} { |
---|
| 1596 | binary scan [binary format sWs 16450 0x7fffffff 19521] c* x |
---|
| 1597 | set x |
---|
| 1598 | } {66 64 0 0 0 0 127 -1 -1 -1 65 76} |
---|
| 1599 | |
---|
| 1600 | test binary-46.1 {Tcl_BinaryObjCmd: handling of non-ISO8859-1 chars} { |
---|
| 1601 | binary format a* \u20ac |
---|
| 1602 | } \u00ac |
---|
| 1603 | test binary-46.2 {Tcl_BinaryObjCmd: handling of non-ISO8859-1 chars} { |
---|
| 1604 | list [binary scan [binary format a* \u20ac\u20bd] s x] $x |
---|
| 1605 | } {1 -16980} |
---|
| 1606 | test binary-46.3 {Tcl_BinaryObjCmd: handling of non-ISO8859-1 chars} { |
---|
| 1607 | set x {} |
---|
| 1608 | set y {} |
---|
| 1609 | set z {} |
---|
| 1610 | list [binary scan [binary format a* \u20ac\u20bd] aaa x y z] $x $y $z |
---|
| 1611 | } "2 \u00ac \u00bd {}" |
---|
| 1612 | test binary-46.4 {Tcl_BinaryObjCmd: handling of non-ISO8859-1 chars} { |
---|
| 1613 | set x [encoding convertto iso8859-15 \u20ac] |
---|
| 1614 | set y [binary format a* $x] |
---|
| 1615 | list $x $y |
---|
| 1616 | } "\u00a4 \u00a4" |
---|
| 1617 | test binary-46.5 {Tcl_BinaryObjCmd: handling of non-ISO8859-1 chars} { |
---|
| 1618 | set x [binary scan \u00a4 a* y] |
---|
| 1619 | list $x $y [encoding convertfrom iso8859-15 $y] |
---|
| 1620 | } "1 \u00a4 \u20ac" |
---|
| 1621 | |
---|
| 1622 | test binary-47.1 {Tcl_BinaryObjCmd: number cache reference count handling} { |
---|
| 1623 | # This test is only reliable when memory debugging is turned on, |
---|
| 1624 | # but without even memory debugging it should still generate the |
---|
| 1625 | # expected answers and might therefore still pick up memory corruption |
---|
| 1626 | # caused by [Bug 851747]. |
---|
| 1627 | list [binary scan aba ccc x x x] $x |
---|
| 1628 | } {3 97} |
---|
| 1629 | |
---|
| 1630 | ### TIP#129: endian specifiers ---- |
---|
| 1631 | |
---|
| 1632 | # format t |
---|
| 1633 | test binary-48.1 {Tcl_BinaryObjCmd: format} { |
---|
| 1634 | list [catch {binary format t} msg] $msg |
---|
| 1635 | } {1 {not enough arguments for all format specifiers}} |
---|
| 1636 | test binary-48.2 {Tcl_BinaryObjCmd: format} { |
---|
| 1637 | list [catch {binary format t blat} msg] $msg |
---|
| 1638 | } {1 {expected integer but got "blat"}} |
---|
| 1639 | test binary-48.3 {Tcl_BinaryObjCmd: format} { |
---|
| 1640 | binary format S0 0x50 |
---|
| 1641 | } {} |
---|
| 1642 | test binary-48.4 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 1643 | binary format t 0x50 |
---|
| 1644 | } \x00P |
---|
| 1645 | test binary-48.5 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 1646 | binary format t 0x50 |
---|
| 1647 | } P\x00 |
---|
| 1648 | test binary-48.6 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 1649 | binary format t 0x5052 |
---|
| 1650 | } PR |
---|
| 1651 | test binary-48.7 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 1652 | binary format t 0x5052 |
---|
| 1653 | } RP |
---|
| 1654 | test binary-48.8 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 1655 | binary format t 0x505251 0x53 |
---|
| 1656 | } RQ |
---|
| 1657 | test binary-48.9 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 1658 | binary format t 0x505251 0x53 |
---|
| 1659 | } QR |
---|
| 1660 | test binary-48.10 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 1661 | binary format t2 {0x50 0x52} |
---|
| 1662 | } \x00P\x00R |
---|
| 1663 | test binary-48.11 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 1664 | binary format t2 {0x50 0x52} |
---|
| 1665 | } P\x00R\x00 |
---|
| 1666 | test binary-48.12 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 1667 | binary format t* {0x5051 0x52} |
---|
| 1668 | } PQ\x00R |
---|
| 1669 | test binary-48.13 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 1670 | binary format t* {0x5051 0x52} |
---|
| 1671 | } QPR\x00 |
---|
| 1672 | test binary-48.14 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 1673 | binary format t2 {0x50 0x52 0x53} 0x54 |
---|
| 1674 | } \x00P\x00R |
---|
| 1675 | test binary-48.15 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 1676 | binary format t2 {0x50 0x52 0x53} 0x54 |
---|
| 1677 | } P\x00R\x00 |
---|
| 1678 | test binary-48.16 {Tcl_BinaryObjCmd: format} { |
---|
| 1679 | list [catch {binary format t2 {0x50}} msg] $msg |
---|
| 1680 | } {1 {number of elements in list does not match count}} |
---|
| 1681 | test binary-48.17 {Tcl_BinaryObjCmd: format} { |
---|
| 1682 | set a {0x50 0x51} |
---|
| 1683 | list [catch {binary format t $a} msg] $msg |
---|
| 1684 | } [list 1 "expected integer but got \"0x50 0x51\""] |
---|
| 1685 | test binary-48.18 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 1686 | set a {0x50 0x51} |
---|
| 1687 | binary format t1 $a |
---|
| 1688 | } \x00P |
---|
| 1689 | test binary-48.19 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 1690 | set a {0x50 0x51} |
---|
| 1691 | binary format t1 $a |
---|
| 1692 | } P\x00 |
---|
| 1693 | |
---|
| 1694 | # format n |
---|
| 1695 | test binary-49.1 {Tcl_BinaryObjCmd: format} { |
---|
| 1696 | list [catch {binary format n} msg] $msg |
---|
| 1697 | } {1 {not enough arguments for all format specifiers}} |
---|
| 1698 | test binary-49.2 {Tcl_BinaryObjCmd: format} { |
---|
| 1699 | list [catch {binary format n blat} msg] $msg |
---|
| 1700 | } {1 {expected integer but got "blat"}} |
---|
| 1701 | test binary-49.3 {Tcl_BinaryObjCmd: format} { |
---|
| 1702 | binary format n0 0x50 |
---|
| 1703 | } {} |
---|
| 1704 | test binary-49.4 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 1705 | binary format n 0x50 |
---|
| 1706 | } P\x00\x00\x00 |
---|
| 1707 | test binary-49.5 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 1708 | binary format n 0x5052 |
---|
| 1709 | } RP\x00\x00 |
---|
| 1710 | test binary-49.6 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 1711 | binary format n 0x505251 0x53 |
---|
| 1712 | } QRP\x00 |
---|
| 1713 | test binary-49.7 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 1714 | binary format i1 {0x505251 0x53} |
---|
| 1715 | } QRP\x00 |
---|
| 1716 | test binary-49.8 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 1717 | binary format n 0x53525150 |
---|
| 1718 | } PQRS |
---|
| 1719 | test binary-49.9 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 1720 | binary format n2 {0x50 0x52} |
---|
| 1721 | } P\x00\x00\x00R\x00\x00\x00 |
---|
| 1722 | test binary-49.10 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 1723 | binary format n* {0x50515253 0x52} |
---|
| 1724 | } SRQPR\x00\x00\x00 |
---|
| 1725 | test binary-49.11 {Tcl_BinaryObjCmd: format} { |
---|
| 1726 | list [catch {binary format n2 {0x50}} msg] $msg |
---|
| 1727 | } {1 {number of elements in list does not match count}} |
---|
| 1728 | test binary-49.12 {Tcl_BinaryObjCmd: format} { |
---|
| 1729 | set a {0x50 0x51} |
---|
| 1730 | list [catch {binary format n $a} msg] $msg |
---|
| 1731 | } [list 1 "expected integer but got \"0x50 0x51\""] |
---|
| 1732 | test binary-49.13 {Tcl_BinaryObjCmd: format} littleEndian { |
---|
| 1733 | set a {0x50 0x51} |
---|
| 1734 | binary format n1 $a |
---|
| 1735 | } P\x00\x00\x00 |
---|
| 1736 | test binary-49.14 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 1737 | binary format n 0x50 |
---|
| 1738 | } \x00\x00\x00P |
---|
| 1739 | test binary-49.15 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 1740 | binary format n 0x5052 |
---|
| 1741 | } \x00\x00PR |
---|
| 1742 | test binary-49.16 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 1743 | binary format n 0x505251 0x53 |
---|
| 1744 | } \x00PRQ |
---|
| 1745 | test binary-49.17 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 1746 | binary format i1 {0x505251 0x53} |
---|
| 1747 | } QRP\x00 |
---|
| 1748 | test binary-49.18 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 1749 | binary format n 0x53525150 |
---|
| 1750 | } SRQP |
---|
| 1751 | test binary-49.19 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 1752 | binary format n2 {0x50 0x52} |
---|
| 1753 | } \x00\x00\x00P\x00\x00\x00R |
---|
| 1754 | test binary-49.20 {Tcl_BinaryObjCmd: format} bigEndian { |
---|
| 1755 | binary format n* {0x50515253 0x52} |
---|
| 1756 | } PQRS\x00\x00\x00R |
---|
| 1757 | |
---|
| 1758 | # format m |
---|
| 1759 | test binary-50.1 {Tcl_BinaryObjCmd: format wide int} littleEndian { |
---|
| 1760 | binary format m 7810179016327718216 |
---|
| 1761 | } HelloTcl |
---|
| 1762 | test binary-50.2 {Tcl_BinaryObjCmd: format wide int} bigEndian { |
---|
| 1763 | binary format m 7810179016327718216 |
---|
| 1764 | } lcTolleH |
---|
| 1765 | test binary-50.3 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} littleEndian { |
---|
| 1766 | binary scan [binary format m [expr {wide(3) << 31}]] w x |
---|
| 1767 | set x |
---|
| 1768 | } 6442450944 |
---|
| 1769 | test binary-50.4 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} bigEndian { |
---|
| 1770 | binary scan [binary format m [expr {wide(3) << 31}]] W x |
---|
| 1771 | set x |
---|
| 1772 | } 6442450944 |
---|
| 1773 | |
---|
| 1774 | |
---|
| 1775 | # format Q/q |
---|
| 1776 | test binary-51.1 {Tcl_BinaryObjCmd: format} { |
---|
| 1777 | list [catch {binary format Q} msg] $msg |
---|
| 1778 | } {1 {not enough arguments for all format specifiers}} |
---|
| 1779 | test binary-51.2 {Tcl_BinaryObjCmd: format} { |
---|
| 1780 | list [catch {binary format q blat} msg] $msg |
---|
| 1781 | } {1 {expected floating-point number but got "blat"}} |
---|
| 1782 | test binary-51.3 {Tcl_BinaryObjCmd: format} { |
---|
| 1783 | binary format q0 1.6 |
---|
| 1784 | } {} |
---|
| 1785 | test binary-51.4 {Tcl_BinaryObjCmd: format} {} { |
---|
| 1786 | binary format Q 1.6 |
---|
| 1787 | } \x3f\xf9\x99\x99\x99\x99\x99\x9a |
---|
| 1788 | test binary-51.5 {Tcl_BinaryObjCmd: format} {} { |
---|
| 1789 | binary format q 1.6 |
---|
| 1790 | } \x9a\x99\x99\x99\x99\x99\xf9\x3f |
---|
| 1791 | test binary-51.6 {Tcl_BinaryObjCmd: format} {} { |
---|
| 1792 | binary format Q* {1.6 3.4} |
---|
| 1793 | } \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 |
---|
| 1794 | test binary-51.7 {Tcl_BinaryObjCmd: format} {} { |
---|
| 1795 | binary format q* {1.6 3.4} |
---|
| 1796 | } \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 |
---|
| 1797 | test binary-51.8 {Tcl_BinaryObjCmd: format} {} { |
---|
| 1798 | binary format Q2 {1.6 3.4} |
---|
| 1799 | } \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 |
---|
| 1800 | test binary-51.9 {Tcl_BinaryObjCmd: format} {} { |
---|
| 1801 | binary format q2 {1.6 3.4} |
---|
| 1802 | } \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 |
---|
| 1803 | test binary-51.10 {Tcl_BinaryObjCmd: format} {} { |
---|
| 1804 | binary format Q2 {1.6 3.4 5.6} |
---|
| 1805 | } \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 |
---|
| 1806 | test binary-51.11 {Tcl_BinaryObjCmd: format} {} { |
---|
| 1807 | binary format q2 {1.6 3.4 5.6} |
---|
| 1808 | } \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 |
---|
| 1809 | test binary-51.14 {Tcl_BinaryObjCmd: format} { |
---|
| 1810 | list [catch {binary format q2 {1.6}} msg] $msg |
---|
| 1811 | } {1 {number of elements in list does not match count}} |
---|
| 1812 | test binary-51.15 {Tcl_BinaryObjCmd: format} { |
---|
| 1813 | set a {1.6 3.4} |
---|
| 1814 | list [catch {binary format q $a} msg] $msg |
---|
| 1815 | } [list 1 "expected floating-point number but got \"1.6 3.4\""] |
---|
| 1816 | test binary-51.16 {Tcl_BinaryObjCmd: format} {} { |
---|
| 1817 | set a {1.6 3.4} |
---|
| 1818 | binary format Q1 $a |
---|
| 1819 | } \x3f\xf9\x99\x99\x99\x99\x99\x9a |
---|
| 1820 | test binary-51.17 {Tcl_BinaryObjCmd: format} {} { |
---|
| 1821 | set a {1.6 3.4} |
---|
| 1822 | binary format q1 $a |
---|
| 1823 | } \x9a\x99\x99\x99\x99\x99\xf9\x3f |
---|
| 1824 | |
---|
| 1825 | # format R/r |
---|
| 1826 | test binary-53.1 {Tcl_BinaryObjCmd: format} { |
---|
| 1827 | list [catch {binary format r} msg] $msg |
---|
| 1828 | } {1 {not enough arguments for all format specifiers}} |
---|
| 1829 | test binary-53.2 {Tcl_BinaryObjCmd: format} { |
---|
| 1830 | list [catch {binary format r blat} msg] $msg |
---|
| 1831 | } {1 {expected floating-point number but got "blat"}} |
---|
| 1832 | test binary-53.3 {Tcl_BinaryObjCmd: format} { |
---|
| 1833 | binary format f0 1.6 |
---|
| 1834 | } {} |
---|
| 1835 | test binary-53.4 {Tcl_BinaryObjCmd: format} {} { |
---|
| 1836 | binary format R 1.6 |
---|
| 1837 | } \x3f\xcc\xcc\xcd |
---|
| 1838 | test binary-53.5 {Tcl_BinaryObjCmd: format} {} { |
---|
| 1839 | binary format r 1.6 |
---|
| 1840 | } \xcd\xcc\xcc\x3f |
---|
| 1841 | test binary-53.6 {Tcl_BinaryObjCmd: format} {} { |
---|
| 1842 | binary format R* {1.6 3.4} |
---|
| 1843 | } \x3f\xcc\xcc\xcd\x40\x59\x99\x9a |
---|
| 1844 | test binary-53.7 {Tcl_BinaryObjCmd: format} {} { |
---|
| 1845 | binary format r* {1.6 3.4} |
---|
| 1846 | } \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 |
---|
| 1847 | test binary-53.8 {Tcl_BinaryObjCmd: format} {} { |
---|
| 1848 | binary format R2 {1.6 3.4} |
---|
| 1849 | } \x3f\xcc\xcc\xcd\x40\x59\x99\x9a |
---|
| 1850 | test binary-53.9 {Tcl_BinaryObjCmd: format} {} { |
---|
| 1851 | binary format r2 {1.6 3.4} |
---|
| 1852 | } \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 |
---|
| 1853 | test binary-53.10 {Tcl_BinaryObjCmd: format} {} { |
---|
| 1854 | binary format R2 {1.6 3.4 5.6} |
---|
| 1855 | } \x3f\xcc\xcc\xcd\x40\x59\x99\x9a |
---|
| 1856 | test binary-53.11 {Tcl_BinaryObjCmd: format} {} { |
---|
| 1857 | binary format r2 {1.6 3.4 5.6} |
---|
| 1858 | } \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 |
---|
| 1859 | test binary-53.12 {Tcl_BinaryObjCmd: float overflow} {} { |
---|
| 1860 | binary format R -3.402825e+38 |
---|
| 1861 | } \xff\x7f\xff\xff |
---|
| 1862 | test binary-53.13 {Tcl_BinaryObjCmd: float overflow} {} { |
---|
| 1863 | binary format r -3.402825e+38 |
---|
| 1864 | } \xff\xff\x7f\xff |
---|
| 1865 | test binary-53.14 {Tcl_BinaryObjCmd: float underflow} {} { |
---|
| 1866 | binary format R -3.402825e-100 |
---|
| 1867 | } \x80\x00\x00\x00 |
---|
| 1868 | test binary-53.15 {Tcl_BinaryObjCmd: float underflow} {} { |
---|
| 1869 | binary format r -3.402825e-100 |
---|
| 1870 | } \x00\x00\x00\x80 |
---|
| 1871 | test binary-53.16 {Tcl_BinaryObjCmd: format} { |
---|
| 1872 | list [catch {binary format r2 {1.6}} msg] $msg |
---|
| 1873 | } {1 {number of elements in list does not match count}} |
---|
| 1874 | test binary-53.17 {Tcl_BinaryObjCmd: format} { |
---|
| 1875 | set a {1.6 3.4} |
---|
| 1876 | list [catch {binary format r $a} msg] $msg |
---|
| 1877 | } [list 1 "expected floating-point number but got \"1.6 3.4\""] |
---|
| 1878 | test binary-53.18 {Tcl_BinaryObjCmd: format} {} { |
---|
| 1879 | set a {1.6 3.4} |
---|
| 1880 | binary format R1 $a |
---|
| 1881 | } \x3f\xcc\xcc\xcd |
---|
| 1882 | test binary-53.19 {Tcl_BinaryObjCmd: format} {} { |
---|
| 1883 | set a {1.6 3.4} |
---|
| 1884 | binary format r1 $a |
---|
| 1885 | } \xcd\xcc\xcc\x3f |
---|
| 1886 | |
---|
| 1887 | # scan t (s) |
---|
| 1888 | test binary-54.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 1889 | list [catch {binary scan abc t} msg] $msg |
---|
| 1890 | } {1 {not enough arguments for all format specifiers}} |
---|
| 1891 | test binary-54.2 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1892 | catch {unset arg1} |
---|
| 1893 | list [binary scan \x52\xa3\x53\x54 t* arg1] $arg1 |
---|
| 1894 | } {1 {-23726 21587}} |
---|
| 1895 | test binary-54.3 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1896 | catch {unset arg1} |
---|
| 1897 | list [binary scan \x52\xa3\x53\x54 t arg1] $arg1 |
---|
| 1898 | } {1 -23726} |
---|
| 1899 | test binary-54.4 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1900 | catch {unset arg1} |
---|
| 1901 | list [binary scan \x52\xa3 t1 arg1] $arg1 |
---|
| 1902 | } {1 -23726} |
---|
| 1903 | test binary-54.5 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1904 | catch {unset arg1} |
---|
| 1905 | list [binary scan \x52\xa3 t0 arg1] $arg1 |
---|
| 1906 | } {1 {}} |
---|
| 1907 | test binary-54.6 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1908 | catch {unset arg1} |
---|
| 1909 | list [binary scan \x52\xa3\x53\x54 t2 arg1] $arg1 |
---|
| 1910 | } {1 {-23726 21587}} |
---|
| 1911 | test binary-54.7 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1912 | catch {unset arg1} |
---|
| 1913 | set arg1 foo |
---|
| 1914 | list [binary scan \x52 t1 arg1] $arg1 |
---|
| 1915 | } {0 foo} |
---|
| 1916 | test binary-54.8 {Tcl_BinaryObjCmd: scan} {} { |
---|
| 1917 | catch {unset arg1} |
---|
| 1918 | set arg1 1 |
---|
| 1919 | list [catch {binary scan \x52\x53 t1 arg1(a)} msg] $msg |
---|
| 1920 | } {1 {can't set "arg1(a)": variable isn't array}} |
---|
| 1921 | test binary-54.9 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1922 | catch {unset arg1 arg2} |
---|
| 1923 | set arg1 foo |
---|
| 1924 | set arg2 bar |
---|
| 1925 | list [binary scan \x52\xa3\x53\x54\x05 t2c* arg1 arg2] $arg1 $arg2 |
---|
| 1926 | } {2 {-23726 21587} 5} |
---|
| 1927 | test binary-54.10 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1928 | catch {unset arg1 arg2} |
---|
| 1929 | set arg1 foo |
---|
| 1930 | set arg2 bar |
---|
| 1931 | list [binary scan \x00\x80\x00\x80 tut arg1 arg2] $arg1 $arg2 |
---|
| 1932 | } {2 32768 -32768} |
---|
| 1933 | test binary-54.11 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1934 | catch {unset arg1 arg2} |
---|
| 1935 | set arg1 foo |
---|
| 1936 | set arg2 bar |
---|
| 1937 | list [binary scan \x00\x80\x00\x80 ttu arg1 arg2] $arg1 $arg2 |
---|
| 1938 | } {2 -32768 32768} |
---|
| 1939 | |
---|
| 1940 | # scan t (b) |
---|
| 1941 | test binary-55.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 1942 | list [catch {binary scan abc t} msg] $msg |
---|
| 1943 | } {1 {not enough arguments for all format specifiers}} |
---|
| 1944 | test binary-55.2 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 1945 | catch {unset arg1} |
---|
| 1946 | list [binary scan \x52\xa3\x53\x54 t* arg1] $arg1 |
---|
| 1947 | } {1 {21155 21332}} |
---|
| 1948 | test binary-55.3 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 1949 | catch {unset arg1} |
---|
| 1950 | list [binary scan \x52\xa3\x53\x54 t arg1] $arg1 |
---|
| 1951 | } {1 21155} |
---|
| 1952 | test binary-55.4 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 1953 | catch {unset arg1} |
---|
| 1954 | list [binary scan \x52\xa3 t1 arg1] $arg1 |
---|
| 1955 | } {1 21155} |
---|
| 1956 | test binary-55.5 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 1957 | catch {unset arg1} |
---|
| 1958 | list [binary scan \x52\xa3 t0 arg1] $arg1 |
---|
| 1959 | } {1 {}} |
---|
| 1960 | test binary-55.6 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 1961 | catch {unset arg1} |
---|
| 1962 | list [binary scan \x52\xa3\x53\x54 t2 arg1] $arg1 |
---|
| 1963 | } {1 {21155 21332}} |
---|
| 1964 | test binary-55.7 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 1965 | catch {unset arg1} |
---|
| 1966 | set arg1 foo |
---|
| 1967 | list [binary scan \x52 t1 arg1] $arg1 |
---|
| 1968 | } {0 foo} |
---|
| 1969 | test binary-55.8 {Tcl_BinaryObjCmd: scan} { |
---|
| 1970 | catch {unset arg1} |
---|
| 1971 | set arg1 1 |
---|
| 1972 | list [catch {binary scan \x52\x53 t1 arg1(a)} msg] $msg |
---|
| 1973 | } {1 {can't set "arg1(a)": variable isn't array}} |
---|
| 1974 | test binary-55.9 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 1975 | catch {unset arg1 arg2} |
---|
| 1976 | set arg1 foo |
---|
| 1977 | set arg2 bar |
---|
| 1978 | list [binary scan \x52\xa3\x53\x54\x05 t2c* arg1 arg2] $arg1 $arg2 |
---|
| 1979 | } {2 {21155 21332} 5} |
---|
| 1980 | test binary-55.10 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 1981 | catch {unset arg1 arg2} |
---|
| 1982 | set arg1 foo |
---|
| 1983 | set arg2 bar |
---|
| 1984 | list [binary scan \x80\x00\x80\x00 tut arg1 arg2] $arg1 $arg2 |
---|
| 1985 | } {2 32768 -32768} |
---|
| 1986 | test binary-55.11 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 1987 | catch {unset arg1 arg2} |
---|
| 1988 | set arg1 foo |
---|
| 1989 | set arg2 bar |
---|
| 1990 | list [binary scan \x80\x00\x80\x00 ttu arg1 arg2] $arg1 $arg2 |
---|
| 1991 | } {2 -32768 32768} |
---|
| 1992 | |
---|
| 1993 | # scan n (s) |
---|
| 1994 | test binary-56.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 1995 | list [catch {binary scan abc n} msg] $msg |
---|
| 1996 | } {1 {not enough arguments for all format specifiers}} |
---|
| 1997 | test binary-56.2 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 1998 | catch {unset arg1} |
---|
| 1999 | list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 n* arg1] $arg1 |
---|
| 2000 | } {1 {1414767442 67305985}} |
---|
| 2001 | test binary-56.3 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 2002 | catch {unset arg1} |
---|
| 2003 | list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 n arg1] $arg1 |
---|
| 2004 | } {1 1414767442} |
---|
| 2005 | test binary-56.4 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 2006 | catch {unset arg1} |
---|
| 2007 | list [binary scan \x52\xa3\x53\x54 n1 arg1] $arg1 |
---|
| 2008 | } {1 1414767442} |
---|
| 2009 | test binary-56.5 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 2010 | catch {unset arg1} |
---|
| 2011 | list [binary scan \x52\xa3\x53 n0 arg1] $arg1 |
---|
| 2012 | } {1 {}} |
---|
| 2013 | test binary-56.6 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 2014 | catch {unset arg1} |
---|
| 2015 | list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 n2 arg1] $arg1 |
---|
| 2016 | } {1 {1414767442 67305985}} |
---|
| 2017 | test binary-56.7 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 2018 | catch {unset arg1} |
---|
| 2019 | set arg1 foo |
---|
| 2020 | list [binary scan \x52 n1 arg1] $arg1 |
---|
| 2021 | } {0 foo} |
---|
| 2022 | test binary-56.8 {Tcl_BinaryObjCmd: scan} { |
---|
| 2023 | catch {unset arg1} |
---|
| 2024 | set arg1 1 |
---|
| 2025 | list [catch {binary scan \x52\x53\x53\x54 n1 arg1(a)} msg] $msg |
---|
| 2026 | } {1 {can't set "arg1(a)": variable isn't array}} |
---|
| 2027 | test binary-56.9 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 2028 | catch {unset arg1 arg2} |
---|
| 2029 | set arg1 foo |
---|
| 2030 | set arg2 bar |
---|
| 2031 | list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04\x05 n2c* arg1 arg2] $arg1 $arg2 |
---|
| 2032 | } {2 {1414767442 67305985} 5} |
---|
| 2033 | test binary-56.10 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 2034 | catch {unset arg1 arg2} |
---|
| 2035 | set arg1 foo |
---|
| 2036 | set arg2 bar |
---|
| 2037 | list [binary scan \x80\x00\x00\x00\x80\x00\x00\x00 nun arg1 arg2] $arg1 $arg2 |
---|
| 2038 | } {2 128 128} |
---|
| 2039 | test binary-56.11 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 2040 | catch {unset arg1 arg2} |
---|
| 2041 | set arg1 foo |
---|
| 2042 | set arg2 bar |
---|
| 2043 | list [binary scan \x00\x00\x00\x80\x00\x00\x00\x80 nun arg1 arg2] $arg1 $arg2 |
---|
| 2044 | } {2 2147483648 -2147483648} |
---|
| 2045 | |
---|
| 2046 | # scan n (b) |
---|
| 2047 | test binary-57.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 2048 | list [catch {binary scan abc n} msg] $msg |
---|
| 2049 | } {1 {not enough arguments for all format specifiers}} |
---|
| 2050 | test binary-57.2 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 2051 | catch {unset arg1} |
---|
| 2052 | list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 n* arg1] $arg1 |
---|
| 2053 | } {1 {1386435412 16909060}} |
---|
| 2054 | test binary-57.3 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 2055 | catch {unset arg1} |
---|
| 2056 | list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 n arg1] $arg1 |
---|
| 2057 | } {1 1386435412} |
---|
| 2058 | test binary-57.4 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 2059 | catch {unset arg1} |
---|
| 2060 | list [binary scan \x52\xa3\x53\x54 n1 arg1] $arg1 |
---|
| 2061 | } {1 1386435412} |
---|
| 2062 | test binary-57.5 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 2063 | catch {unset arg1} |
---|
| 2064 | list [binary scan \x52\xa3\x53 n0 arg1] $arg1 |
---|
| 2065 | } {1 {}} |
---|
| 2066 | test binary-57.6 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 2067 | catch {unset arg1} |
---|
| 2068 | list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 n2 arg1] $arg1 |
---|
| 2069 | } {1 {1386435412 16909060}} |
---|
| 2070 | test binary-57.7 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 2071 | catch {unset arg1} |
---|
| 2072 | set arg1 foo |
---|
| 2073 | list [binary scan \x52 n1 arg1] $arg1 |
---|
| 2074 | } {0 foo} |
---|
| 2075 | test binary-57.8 {Tcl_BinaryObjCmd: scan} { |
---|
| 2076 | catch {unset arg1} |
---|
| 2077 | set arg1 1 |
---|
| 2078 | list [catch {binary scan \x52\x53\x53\x54 n1 arg1(a)} msg] $msg |
---|
| 2079 | } {1 {can't set "arg1(a)": variable isn't array}} |
---|
| 2080 | test binary-57.9 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 2081 | catch {unset arg1 arg2} |
---|
| 2082 | set arg1 foo |
---|
| 2083 | set arg2 bar |
---|
| 2084 | list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04\x05 n2c* arg1 arg2] $arg1 $arg2 |
---|
| 2085 | } {2 {1386435412 16909060} 5} |
---|
| 2086 | test binary-57.10 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 2087 | catch {unset arg1 arg2} |
---|
| 2088 | set arg1 foo |
---|
| 2089 | set arg2 bar |
---|
| 2090 | list [binary scan \x80\x00\x00\x00\x80\x00\x00\x00 nun arg1 arg2] $arg1 $arg2 |
---|
| 2091 | } {2 2147483648 -2147483648} |
---|
| 2092 | test binary-57.11 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 2093 | catch {unset arg1 arg2} |
---|
| 2094 | set arg1 foo |
---|
| 2095 | set arg2 bar |
---|
| 2096 | list [binary scan \x00\x00\x00\x80\x00\x00\x00\x80 nun arg1 arg2] $arg1 $arg2 |
---|
| 2097 | } {2 128 128} |
---|
| 2098 | |
---|
| 2099 | # scan Q/q |
---|
| 2100 | test binary-58.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 2101 | list [catch {binary scan abc q} msg] $msg |
---|
| 2102 | } {1 {not enough arguments for all format specifiers}} |
---|
| 2103 | test binary-58.2 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 2104 | catch {unset arg1} |
---|
| 2105 | list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 Q* arg1] $arg1 |
---|
| 2106 | } {1 {1.6 3.4}} |
---|
| 2107 | test binary-58.3 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 2108 | catch {unset arg1} |
---|
| 2109 | list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 q* arg1] $arg1 |
---|
| 2110 | } {1 {1.6 3.4}} |
---|
| 2111 | test binary-58.4 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 2112 | catch {unset arg1} |
---|
| 2113 | list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 Q arg1] $arg1 |
---|
| 2114 | } {1 1.6} |
---|
| 2115 | test binary-58.5 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 2116 | catch {unset arg1} |
---|
| 2117 | list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 q arg1] $arg1 |
---|
| 2118 | } {1 1.6} |
---|
| 2119 | test binary-58.6 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 2120 | catch {unset arg1} |
---|
| 2121 | list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a Q1 arg1] $arg1 |
---|
| 2122 | } {1 1.6} |
---|
| 2123 | test binary-58.7 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 2124 | catch {unset arg1} |
---|
| 2125 | list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f q1 arg1] $arg1 |
---|
| 2126 | } {1 1.6} |
---|
| 2127 | test binary-58.8 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 2128 | catch {unset arg1} |
---|
| 2129 | list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a Q0 arg1] $arg1 |
---|
| 2130 | } {1 {}} |
---|
| 2131 | test binary-58.9 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 2132 | catch {unset arg1} |
---|
| 2133 | list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f q0 arg1] $arg1 |
---|
| 2134 | } {1 {}} |
---|
| 2135 | test binary-58.10 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 2136 | catch {unset arg1} |
---|
| 2137 | list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 Q2 arg1] $arg1 |
---|
| 2138 | } {1 {1.6 3.4}} |
---|
| 2139 | test binary-58.11 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 2140 | catch {unset arg1} |
---|
| 2141 | list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 q2 arg1] $arg1 |
---|
| 2142 | } {1 {1.6 3.4}} |
---|
| 2143 | test binary-58.12 {Tcl_BinaryObjCmd: scan} { |
---|
| 2144 | catch {unset arg1} |
---|
| 2145 | set arg1 foo |
---|
| 2146 | list [binary scan \x52 q1 arg1] $arg1 |
---|
| 2147 | } {0 foo} |
---|
| 2148 | test binary-58.13 {Tcl_BinaryObjCmd: scan} { |
---|
| 2149 | catch {unset arg1} |
---|
| 2150 | set arg1 1 |
---|
| 2151 | list [catch {binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a q1 arg1(a)} msg] $msg |
---|
| 2152 | } {1 {can't set "arg1(a)": variable isn't array}} |
---|
| 2153 | test binary-58.14 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 2154 | catch {unset arg1 arg2} |
---|
| 2155 | set arg1 foo |
---|
| 2156 | set arg2 bar |
---|
| 2157 | 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 |
---|
| 2158 | } {2 {1.6 3.4} 5} |
---|
| 2159 | test binary-58.15 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 2160 | catch {unset arg1 arg2} |
---|
| 2161 | set arg1 foo |
---|
| 2162 | set arg2 bar |
---|
| 2163 | 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 |
---|
| 2164 | } {2 {1.6 3.4} 5} |
---|
| 2165 | |
---|
| 2166 | # scan R/r |
---|
| 2167 | test binary-59.1 {Tcl_BinaryObjCmd: scan} { |
---|
| 2168 | list [catch {binary scan abc r} msg] $msg |
---|
| 2169 | } {1 {not enough arguments for all format specifiers}} |
---|
| 2170 | test binary-59.2 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 2171 | catch {unset arg1} |
---|
| 2172 | list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a R* arg1] $arg1 |
---|
| 2173 | } {1 {1.600000023841858 3.4000000953674316}} |
---|
| 2174 | test binary-59.3 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 2175 | catch {unset arg1} |
---|
| 2176 | list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 r* arg1] $arg1 |
---|
| 2177 | } {1 {1.600000023841858 3.4000000953674316}} |
---|
| 2178 | test binary-59.4 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 2179 | catch {unset arg1} |
---|
| 2180 | list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a R arg1] $arg1 |
---|
| 2181 | } {1 1.600000023841858} |
---|
| 2182 | test binary-59.5 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 2183 | catch {unset arg1} |
---|
| 2184 | list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 r arg1] $arg1 |
---|
| 2185 | } {1 1.600000023841858} |
---|
| 2186 | test binary-59.6 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 2187 | catch {unset arg1} |
---|
| 2188 | list [binary scan \x3f\xcc\xcc\xcd R1 arg1] $arg1 |
---|
| 2189 | } {1 1.600000023841858} |
---|
| 2190 | test binary-59.7 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 2191 | catch {unset arg1} |
---|
| 2192 | list [binary scan \xcd\xcc\xcc\x3f r1 arg1] $arg1 |
---|
| 2193 | } {1 1.600000023841858} |
---|
| 2194 | test binary-59.8 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 2195 | catch {unset arg1} |
---|
| 2196 | list [binary scan \x3f\xcc\xcc\xcd R0 arg1] $arg1 |
---|
| 2197 | } {1 {}} |
---|
| 2198 | test binary-59.9 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 2199 | catch {unset arg1} |
---|
| 2200 | list [binary scan \xcd\xcc\xcc\x3f r0 arg1] $arg1 |
---|
| 2201 | } {1 {}} |
---|
| 2202 | test binary-59.10 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 2203 | catch {unset arg1} |
---|
| 2204 | list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a R2 arg1] $arg1 |
---|
| 2205 | } {1 {1.600000023841858 3.4000000953674316}} |
---|
| 2206 | test binary-59.11 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 2207 | catch {unset arg1} |
---|
| 2208 | list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 r2 arg1] $arg1 |
---|
| 2209 | } {1 {1.600000023841858 3.4000000953674316}} |
---|
| 2210 | test binary-59.12 {Tcl_BinaryObjCmd: scan} { |
---|
| 2211 | catch {unset arg1} |
---|
| 2212 | set arg1 foo |
---|
| 2213 | list [binary scan \x52 r1 arg1] $arg1 |
---|
| 2214 | } {0 foo} |
---|
| 2215 | test binary-59.13 {Tcl_BinaryObjCmd: scan} { |
---|
| 2216 | catch {unset arg1} |
---|
| 2217 | set arg1 1 |
---|
| 2218 | list [catch {binary scan \x3f\xcc\xcc\xcd r1 arg1(a)} msg] $msg |
---|
| 2219 | } {1 {can't set "arg1(a)": variable isn't array}} |
---|
| 2220 | test binary-59.14 {Tcl_BinaryObjCmd: scan} bigEndian { |
---|
| 2221 | catch {unset arg1 arg2} |
---|
| 2222 | set arg1 foo |
---|
| 2223 | set arg2 bar |
---|
| 2224 | list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a\x05 R2c* arg1 arg2] $arg1 $arg2 |
---|
| 2225 | } {2 {1.600000023841858 3.4000000953674316} 5} |
---|
| 2226 | test binary-59.15 {Tcl_BinaryObjCmd: scan} littleEndian { |
---|
| 2227 | catch {unset arg1 arg2} |
---|
| 2228 | set arg1 foo |
---|
| 2229 | set arg2 bar |
---|
| 2230 | list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40\x05 r2c* arg1 arg2] $arg1 $arg2 |
---|
| 2231 | } {2 {1.600000023841858 3.4000000953674316} 5} |
---|
| 2232 | |
---|
| 2233 | test binary-60.1 {[binary format] with NaN} -body { |
---|
| 2234 | binary scan [binary format dqQfrR NaN NaN NaN NaN NaN NaN] dqQfrR \ |
---|
| 2235 | v1 v2 v3 v4 v5 v6 |
---|
| 2236 | list $v1 $v2 $v3 $v4 $v5 $v6 |
---|
| 2237 | } -match regexp -result {NaN(\([[:xdigit:]]+\))? NaN(\([[:xdigit:]]+\))? NaN(\([[:xdigit:]]+\))? NaN(\([[:xdigit:]]+\))? NaN(\([[:xdigit:]]+\))? NaN(\([[:xdigit:]]+\))?} |
---|
| 2238 | |
---|
| 2239 | # scan m |
---|
| 2240 | test binary-61.1 {Tcl_BinaryObjCmd: scan wide int} bigEndian { |
---|
| 2241 | binary scan HelloTcl m x |
---|
| 2242 | set x |
---|
| 2243 | } 5216694956358656876 |
---|
| 2244 | test binary-61.2 {Tcl_BinaryObjCmd: scan wide int} littleEndian { |
---|
| 2245 | binary scan lcTolleH m x |
---|
| 2246 | set x |
---|
| 2247 | } 5216694956358656876 |
---|
| 2248 | test binary-61.3 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} littleEndian { |
---|
| 2249 | binary scan [binary format w [expr {wide(3) << 31}]] m x |
---|
| 2250 | set x |
---|
| 2251 | } 6442450944 |
---|
| 2252 | test binary-61.4 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} bigEndian { |
---|
| 2253 | binary scan [binary format W [expr {wide(3) << 31}]] m x |
---|
| 2254 | set x |
---|
| 2255 | } 6442450944 |
---|
| 2256 | |
---|
| 2257 | # Big test for correct ordering of data in [expr] |
---|
| 2258 | |
---|
| 2259 | proc testIEEE {} { |
---|
| 2260 | variable ieeeValues |
---|
| 2261 | binary scan [binary format dd -1.0 1.0] c* c |
---|
| 2262 | switch -exact -- $c { |
---|
| 2263 | {0 0 0 0 0 0 -16 -65 0 0 0 0 0 0 -16 63} { |
---|
| 2264 | # little endian |
---|
| 2265 | binary scan \x00\x00\x00\x00\x00\x00\xf0\xff d \ |
---|
| 2266 | ieeeValues(-Infinity) |
---|
| 2267 | binary scan \x00\x00\x00\x00\x00\x00\xf0\xbf d \ |
---|
| 2268 | ieeeValues(-Normal) |
---|
| 2269 | binary scan \x00\x00\x00\x00\x00\x00\x08\x80 d \ |
---|
| 2270 | ieeeValues(-Subnormal) |
---|
| 2271 | binary scan \x00\x00\x00\x00\x00\x00\x00\x80 d \ |
---|
| 2272 | ieeeValues(-0) |
---|
| 2273 | binary scan \x00\x00\x00\x00\x00\x00\x00\x00 d \ |
---|
| 2274 | ieeeValues(+0) |
---|
| 2275 | binary scan \x00\x00\x00\x00\x00\x00\x08\x00 d \ |
---|
| 2276 | ieeeValues(+Subnormal) |
---|
| 2277 | binary scan \x00\x00\x00\x00\x00\x00\xf0\x3f d \ |
---|
| 2278 | ieeeValues(+Normal) |
---|
| 2279 | binary scan \x00\x00\x00\x00\x00\x00\xf0\x7f d \ |
---|
| 2280 | ieeeValues(+Infinity) |
---|
| 2281 | binary scan \x00\x00\x00\x00\x00\x00\xf8\x7f d \ |
---|
| 2282 | ieeeValues(NaN) |
---|
| 2283 | set ieeeValues(littleEndian) 1 |
---|
| 2284 | return 1 |
---|
| 2285 | } |
---|
| 2286 | {-65 -16 0 0 0 0 0 0 63 -16 0 0 0 0 0 0} { |
---|
| 2287 | binary scan \xff\xf0\x00\x00\x00\x00\x00\x00 d \ |
---|
| 2288 | ieeeValues(-Infinity) |
---|
| 2289 | binary scan \xbf\xf0\x00\x00\x00\x00\x00\x00 d \ |
---|
| 2290 | ieeeValues(-Normal) |
---|
| 2291 | binary scan \x80\x08\x00\x00\x00\x00\x00\x00 d \ |
---|
| 2292 | ieeeValues(-Subnormal) |
---|
| 2293 | binary scan \x80\x00\x00\x00\x00\x00\x00\x00 d \ |
---|
| 2294 | ieeeValues(-0) |
---|
| 2295 | binary scan \x00\x00\x00\x00\x00\x00\x00\x00 d \ |
---|
| 2296 | ieeeValues(+0) |
---|
| 2297 | binary scan \x00\x08\x00\x00\x00\x00\x00\x00 d \ |
---|
| 2298 | ieeeValues(+Subnormal) |
---|
| 2299 | binary scan \x3f\xf0\x00\x00\x00\x00\x00\x00 d \ |
---|
| 2300 | ieeeValues(+Normal) |
---|
| 2301 | binary scan \x7f\xf0\x00\x00\x00\x00\x00\x00 d \ |
---|
| 2302 | ieeeValues(+Infinity) |
---|
| 2303 | binary scan \x7f\xf8\x00\x00\x00\x00\x00\x00 d \ |
---|
| 2304 | ieeeValues(NaN) |
---|
| 2305 | set ieeeValues(littleEndian) 0 |
---|
| 2306 | return 1 |
---|
| 2307 | } |
---|
| 2308 | default { |
---|
| 2309 | return 0 |
---|
| 2310 | } |
---|
| 2311 | } |
---|
| 2312 | } |
---|
| 2313 | |
---|
| 2314 | testConstraint ieeeFloatingPoint [testIEEE] |
---|
| 2315 | |
---|
| 2316 | # scan/format infinities |
---|
| 2317 | |
---|
| 2318 | test binary-62.1 {infinity} ieeeFloatingPoint { |
---|
| 2319 | binary scan [binary format q Infinity] w w |
---|
| 2320 | format 0x%016lx $w |
---|
| 2321 | } 0x7ff0000000000000 |
---|
| 2322 | test binary-62.2 {infinity} ieeeFloatingPoint { |
---|
| 2323 | binary scan [binary format q -Infinity] w w |
---|
| 2324 | format 0x%016lx $w |
---|
| 2325 | } 0xfff0000000000000 |
---|
| 2326 | test binary-62.3 {infinity} ieeeFloatingPoint { |
---|
| 2327 | binary scan [binary format q Inf] w w |
---|
| 2328 | format 0x%016lx $w |
---|
| 2329 | } 0x7ff0000000000000 |
---|
| 2330 | test binary-62.4 {infinity} ieeeFloatingPoint { |
---|
| 2331 | binary scan [binary format q -Infinity] w w |
---|
| 2332 | format 0x%016lx $w |
---|
| 2333 | } 0xfff0000000000000 |
---|
| 2334 | test binary-62.5 {infinity} ieeeFloatingPoint { |
---|
| 2335 | binary scan [binary format w 0x7ff0000000000000] q d |
---|
| 2336 | set d |
---|
| 2337 | } Inf |
---|
| 2338 | test binary-62.6 {infinity} ieeeFloatingPoint { |
---|
| 2339 | binary scan [binary format w 0xfff0000000000000] q d |
---|
| 2340 | set d |
---|
| 2341 | } -Inf |
---|
| 2342 | |
---|
| 2343 | # scan/format Not-a-Number |
---|
| 2344 | |
---|
| 2345 | test binary-63.1 {NaN} ieeeFloatingPoint { |
---|
| 2346 | binary scan [binary format q NaN] w w |
---|
| 2347 | format 0x%016lx [expr {$w & 0xfff3ffffffffffff}] |
---|
| 2348 | } 0x7ff0000000000000 |
---|
| 2349 | test binary-63.2 {NaN} ieeeFloatingPoint { |
---|
| 2350 | binary scan [binary format q -NaN] w w |
---|
| 2351 | format 0x%016lx [expr {$w & 0xfff3ffffffffffff}] |
---|
| 2352 | } 0xfff0000000000000 |
---|
| 2353 | test binary-63.3 {NaN} ieeeFloatingPoint { |
---|
| 2354 | binary scan [binary format q NaN(3123456789aBc)] w w |
---|
| 2355 | format 0x%016lx [expr {$w & 0xfff3ffffffffffff}] |
---|
| 2356 | } 0x7ff3123456789abc |
---|
| 2357 | test binary-63.4 {NaN} ieeeFloatingPoint { |
---|
| 2358 | binary scan [binary format q {NaN( 3123456789aBc)}] w w |
---|
| 2359 | format 0x%016lx [expr {$w & 0xfff3ffffffffffff}] |
---|
| 2360 | } 0x7ff3123456789abc |
---|
| 2361 | test binary-64.1 {NaN} \ |
---|
| 2362 | -constraints ieeeFloatingPoint \ |
---|
| 2363 | -body { |
---|
| 2364 | binary scan [binary format w 0x7ff8000000000000] q d |
---|
| 2365 | set d |
---|
| 2366 | } \ |
---|
| 2367 | -match glob -result NaN* |
---|
| 2368 | test binary-64.2 {NaN} \ |
---|
| 2369 | -constraints ieeeFloatingPoint \ |
---|
| 2370 | -body { |
---|
| 2371 | binary scan [binary format w 0x7ff0123456789aBc] q d |
---|
| 2372 | set d |
---|
| 2373 | } \ |
---|
| 2374 | -match glob -result NaN(*123456789abc) |
---|
| 2375 | |
---|
| 2376 | test binary-65.1 {largest significand} ieeeFloatingPoint { |
---|
| 2377 | binary scan [binary format w 0x3fcfffffffffffff] q d |
---|
| 2378 | set d |
---|
| 2379 | } 0.24999999999999997 |
---|
| 2380 | test binary-65.2 {smallest significand} ieeeFloatingPoint { |
---|
| 2381 | binary scan [binary format w 0x3fd0000000000000] q d |
---|
| 2382 | set d |
---|
| 2383 | } 0.25 |
---|
| 2384 | test binary-65.3 {largest significand} ieeeFloatingPoint { |
---|
| 2385 | binary scan [binary format w 0x3fdfffffffffffff] q d |
---|
| 2386 | set d |
---|
| 2387 | } 0.49999999999999994 |
---|
| 2388 | test binary-65.4 {smallest significand} ieeeFloatingPoint { |
---|
| 2389 | binary scan [binary format w 0x3fe0000000000000] q d |
---|
| 2390 | set d |
---|
| 2391 | } 0.5 |
---|
| 2392 | test binary-65.5 {largest significand} ieeeFloatingPoint { |
---|
| 2393 | binary scan [binary format w 0x3fffffffffffffff] q d |
---|
| 2394 | set d |
---|
| 2395 | } 1.9999999999999998 |
---|
| 2396 | test binary-65.6 {smallest significand} ieeeFloatingPoint { |
---|
| 2397 | binary scan [binary format w 0x4000000000000000] q d |
---|
| 2398 | set d |
---|
| 2399 | } 2.0 |
---|
| 2400 | test binary-65.7 {smallest significand} ieeeFloatingPoint { |
---|
| 2401 | binary scan [binary format w 0x434fffffffffffff] q d |
---|
| 2402 | set d |
---|
| 2403 | } 18014398509481982.0 |
---|
| 2404 | test binary-65.8 {largest significand} ieeeFloatingPoint { |
---|
| 2405 | binary scan [binary format w 0x4350000000000000] q d |
---|
| 2406 | set d |
---|
| 2407 | } 18014398509481984.0 |
---|
| 2408 | test binary-65.9 {largest significand} ieeeFloatingPoint { |
---|
| 2409 | binary scan [binary format w 0x4350000000000001] q d |
---|
| 2410 | set d |
---|
| 2411 | } 18014398509481988.0 |
---|
| 2412 | |
---|
| 2413 | # cleanup |
---|
| 2414 | ::tcltest::cleanupTests |
---|
| 2415 | return |
---|
| 2416 | |
---|
| 2417 | # Local Variables: |
---|
| 2418 | # mode: tcl |
---|
| 2419 | # End: |
---|