home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tcl8.0 / tests / binary.test < prev    next >
Encoding:
Text File  |  1997-08-15  |  46.7 KB  |  1,381 lines  |  [TEXT/ALFA]

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