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