Initial check-in of openocd-0.7.0 as it can be downloaded from http://sourceforge.net/projects/openocd/files/openocd/0.7.0/ Any modifications will follow. Change-Id: I6949beaefd589e046395ea0cb80f4e1ab1654d55
1100 lines
38 KiB
Plaintext
1100 lines
38 KiB
Plaintext
# This file tests the tclBinary.c file and the "binary" Tcl command.
|
|
#
|
|
# This file contains a collection of tests for one or more of the Tcl built-in
|
|
# commands. Sourcing this file into Tcl runs the tests and generates output
|
|
# for errors. No output means no errors were found.
|
|
#
|
|
# Copyright (c) 1997 by Sun Microsystems, Inc.
|
|
# Copyright (c) 1998-1999 by Scriptics Corporation.
|
|
#
|
|
# See the file "license.terms" for information on usage and redistribution of
|
|
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
#
|
|
# RCS: @(#) $Id: binary.test,v 1.38 2008/12/15 17:11:34 ferrieux Exp $
|
|
|
|
source [file dirname [info script]]/testing.tcl
|
|
|
|
needs cmd binary
|
|
testConstraint bigEndian [expr {$tcl_platform(byteOrder) eq "bigEndian"}]
|
|
testConstraint littleEndian [expr {$tcl_platform(byteOrder) eq "littleEndian"}]
|
|
|
|
test binary-19.1 {Tcl_BinaryObjCmd: errors} -returnCodes error -body {
|
|
binary s
|
|
} -match glob -result {*}
|
|
test binary-19.2 {Tcl_BinaryObjCmd: errors} -returnCodes error -body {
|
|
binary scan foo
|
|
} -result {wrong # args: should be "binary scan value formatString ?varName ...?"}
|
|
test binary-19.3 {Tcl_BinaryObjCmd: scan} {
|
|
binary scan {} {}
|
|
} 0
|
|
|
|
test binary-20.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
|
|
binary scan abc a
|
|
} -result {not enough arguments for all format specifiers}
|
|
test binary-20.2 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -returnCodes error -body {
|
|
set arg1 1
|
|
binary scan abc a arg1(a)
|
|
} -result {can't set "arg1(a)": variable isn't array}
|
|
test binary-20.3 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -body {
|
|
set arg1 abc
|
|
list [binary scan abc a0 arg1] $arg1
|
|
} -result {1 {}}
|
|
test binary-20.4 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -body {
|
|
list [binary scan abc a* arg1] $arg1
|
|
} -result {1 abc}
|
|
test binary-20.5 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -body {
|
|
list [binary scan abc a5 arg1] [info exists arg1]
|
|
} -result {0 0}
|
|
test binary-20.6 {Tcl_BinaryObjCmd: scan} {
|
|
set arg1 foo
|
|
list [binary scan abc a2 arg1] $arg1
|
|
} {1 ab}
|
|
test binary-20.7 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
unset -nocomplain arg2
|
|
} -body {
|
|
list [binary scan abcdef a2a2 arg1 arg2] $arg1 $arg2
|
|
} -result {2 ab cd}
|
|
test binary-20.8 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -body {
|
|
list [binary scan abc a2 arg1(a)] $arg1(a)
|
|
} -result {1 ab}
|
|
test binary-20.9 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -body {
|
|
list [binary scan abc a arg1(a)] $arg1(a)
|
|
} -result {1 a}
|
|
|
|
# As soon as a conversion runs out of bytes, scan should stop
|
|
test binary-20.10 {Tcl_BinaryObjCmd: scan, too few bytes} -setup {
|
|
unset -nocomplain arg1 arg2
|
|
} -body {
|
|
list [binary scan abc a5a2 arg1 arg2] [info exists arg1] [info exists arg2]
|
|
} -result {0 0 0}
|
|
|
|
test binary-21.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
|
|
binary scan abc A
|
|
} -result {not enough arguments for all format specifiers}
|
|
test binary-21.2 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -returnCodes error -body {
|
|
set arg1 1
|
|
binary scan abc A arg1(a)
|
|
} -result {can't set "arg1(a)": variable isn't array}
|
|
test binary-21.3 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -body {
|
|
set arg1 abc
|
|
list [binary scan abc A0 arg1] $arg1
|
|
} -result {1 {}}
|
|
test binary-21.4 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -body {
|
|
list [binary scan abc A* arg1] $arg1
|
|
} -result {1 abc}
|
|
test binary-21.5 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -body {
|
|
list [binary scan abc A5 arg1] [info exists arg1]
|
|
} -result {0 0}
|
|
test binary-21.6 {Tcl_BinaryObjCmd: scan} {
|
|
set arg1 foo
|
|
list [binary scan abc A2 arg1] $arg1
|
|
} {1 ab}
|
|
test binary-21.7 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
unset -nocomplain arg2
|
|
} -body {
|
|
list [binary scan abcdef A2A2 arg1 arg2] $arg1 $arg2
|
|
} -result {2 ab cd}
|
|
test binary-21.8 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -body {
|
|
list [binary scan abc A2 arg1(a)] $arg1(a)
|
|
} -result {1 ab}
|
|
test binary-21.9 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -body {
|
|
list [binary scan abc A2 arg1(a)] $arg1(a)
|
|
} -result {1 ab}
|
|
test binary-21.10 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -body {
|
|
list [binary scan abc A arg1(a)] $arg1(a)
|
|
} -result {1 a}
|
|
test binary-21.11 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -body {
|
|
list [binary scan "abc def \x00 " A* arg1] $arg1
|
|
} -result {1 {abc def}}
|
|
test binary-21.12 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -body {
|
|
list [binary scan "abc def \x00ghi " A* arg1] $arg1
|
|
} -result [list 1 "abc def \x00ghi"]
|
|
|
|
test binary-22.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
|
|
binary scan abc b
|
|
} -result {not enough arguments for all format specifiers}
|
|
test binary-22.2 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\x53 b* arg1] $arg1
|
|
} {1 0100101011001010}
|
|
test binary-22.3 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x82\x53 b arg1] $arg1
|
|
} {1 0}
|
|
test binary-22.4 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x82\x53 b1 arg1] $arg1
|
|
} {1 0}
|
|
test binary-22.5 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x82\x53 b0 arg1] $arg1
|
|
} {1 {}}
|
|
test binary-22.6 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\x53 b5 arg1] $arg1
|
|
} {1 01001}
|
|
test binary-22.7 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\x53 b8 arg1] $arg1
|
|
} {1 01001010}
|
|
test binary-22.8 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\x53 b14 arg1] $arg1
|
|
} {1 01001010110010}
|
|
test binary-22.9 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
set arg1 foo
|
|
list [binary scan \x52 b14 arg1] $arg1
|
|
} {0 foo}
|
|
test binary-22.10 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -returnCodes error -body {
|
|
set arg1 1
|
|
binary scan \x52\x53 b1 arg1(a)
|
|
} -result {can't set "arg1(a)": variable isn't array}
|
|
test binary-22.11 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1 arg2
|
|
} -body {
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x07\x87\x05 b5b* arg1 arg2] $arg1 $arg2
|
|
} -result {2 11100 1110000110100000}
|
|
|
|
# As soon as a conversion runs out of bytes, scan should stop
|
|
test binary-20.12 {Tcl_BinaryObjCmd: scan, too few bytes} {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x52 b14b8 arg1 arg2] $arg1 $arg2
|
|
} {0 foo bar}
|
|
|
|
test binary-23.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
|
|
binary scan abc B
|
|
} -result {not enough arguments for all format specifiers}
|
|
test binary-23.2 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\x53 B* arg1] $arg1
|
|
} {1 0101001001010011}
|
|
test binary-23.3 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x82\x53 B arg1] $arg1
|
|
} {1 1}
|
|
test binary-23.4 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x82\x53 B1 arg1] $arg1
|
|
} {1 1}
|
|
test binary-23.5 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\x53 B0 arg1] $arg1
|
|
} {1 {}}
|
|
test binary-23.6 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\x53 B5 arg1] $arg1
|
|
} {1 01010}
|
|
test binary-23.7 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\x53 B8 arg1] $arg1
|
|
} {1 01010010}
|
|
test binary-23.8 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\x53 B14 arg1] $arg1
|
|
} {1 01010010010100}
|
|
test binary-23.9 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
set arg1 foo
|
|
list [binary scan \x52 B14 arg1] $arg1
|
|
} {0 foo}
|
|
test binary-23.10 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -returnCodes error -body {
|
|
set arg1 1
|
|
binary scan \x52\x53 B1 arg1(a)
|
|
} -result {can't set "arg1(a)": variable isn't array}
|
|
test binary-23.11 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1 arg2
|
|
} -body {
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x70\x87\x05 B5B* arg1 arg2] $arg1 $arg2
|
|
} -result {2 01110 1000011100000101}
|
|
|
|
test binary-24.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
|
|
binary scan abc h
|
|
} -result {not enough arguments for all format specifiers}
|
|
test binary-24.2 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3 h* arg1] $arg1
|
|
} {1 253a}
|
|
test binary-24.3 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \xc2\xa3 h arg1] $arg1
|
|
} {1 2}
|
|
test binary-24.4 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x82\x53 h1 arg1] $arg1
|
|
} {1 2}
|
|
test binary-24.5 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\x53 h0 arg1] $arg1
|
|
} {1 {}}
|
|
test binary-24.6 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \xf2\x53 h2 arg1] $arg1
|
|
} {1 2f}
|
|
test binary-24.7 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\x53 h3 arg1] $arg1
|
|
} {1 253}
|
|
test binary-24.8 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
set arg1 foo
|
|
list [binary scan \x52 h3 arg1] $arg1
|
|
} {0 foo}
|
|
test binary-24.9 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -returnCodes error -body {
|
|
set arg1 1
|
|
binary scan \x52\x53 h1 arg1(a)
|
|
} -result {can't set "arg1(a)": variable isn't array}
|
|
test binary-24.10 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1 arg2
|
|
} -body {
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x70\x87\x05 h2h* arg1 arg2] $arg1 $arg2
|
|
} -result {2 07 7850}
|
|
|
|
test binary-25.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
|
|
binary scan abc H
|
|
} -result {not enough arguments for all format specifiers}
|
|
test binary-25.2 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3 H* arg1] $arg1
|
|
} {1 52a3}
|
|
test binary-25.3 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \xc2\xa3 H arg1] $arg1
|
|
} {1 c}
|
|
test binary-25.4 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x82\x53 H1 arg1] $arg1
|
|
} {1 8}
|
|
test binary-25.5 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\x53 H0 arg1] $arg1
|
|
} {1 {}}
|
|
test binary-25.6 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \xf2\x53 H2 arg1] $arg1
|
|
} {1 f2}
|
|
test binary-25.7 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\x53 H3 arg1] $arg1
|
|
} {1 525}
|
|
test binary-25.8 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
set arg1 foo
|
|
list [binary scan \x52 H3 arg1] $arg1
|
|
} {0 foo}
|
|
test binary-25.9 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -returnCodes error -body {
|
|
set arg1 1
|
|
binary scan \x52\x53 H1 arg1(a)
|
|
} -result {can't set "arg1(a)": variable isn't array}
|
|
test binary-25.10 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x70\x87\x05 H2H* arg1 arg2] $arg1 $arg2
|
|
} {2 70 8705}
|
|
|
|
test binary-26.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
|
|
binary scan abc c
|
|
} -result {not enough arguments for all format specifiers}
|
|
test binary-26.2 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3 c* arg1] $arg1
|
|
} {1 {82 -93}}
|
|
test binary-26.3 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3 c arg1] $arg1
|
|
} {1 82}
|
|
test binary-26.4 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3 c1 arg1] $arg1
|
|
} {1 82}
|
|
test binary-26.5 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3 c0 arg1] $arg1
|
|
} {1 {}}
|
|
test binary-26.6 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3 c2 arg1] $arg1
|
|
} {1 {82 -93}}
|
|
test binary-26.7 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \xff c arg1] $arg1
|
|
} {1 -1}
|
|
test binary-26.8 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
set arg1 foo
|
|
list [binary scan \x52 c3 arg1] $arg1
|
|
} {0 foo}
|
|
test binary-26.9 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -returnCodes error -body {
|
|
set arg1 1
|
|
binary scan \x52\x53 c1 arg1(a)
|
|
} -result {can't set "arg1(a)": variable isn't array}
|
|
test binary-26.10 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x70\x87\x05 c2c* arg1 arg2] $arg1 $arg2
|
|
} {2 {112 -121} 5}
|
|
test binary-26.11 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3 cu* arg1] $arg1
|
|
} {1 {82 163}}
|
|
test binary-26.12 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3 cu arg1] $arg1
|
|
} {1 82}
|
|
test binary-26.13 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \xff cu arg1] $arg1
|
|
} {1 255}
|
|
test binary-26.14 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x80\x80 cuc arg1 arg2] $arg1 $arg2
|
|
} {2 128 -128}
|
|
test binary-26.15 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x80\x80 ccu arg1 arg2] $arg1 $arg2
|
|
} {2 -128 128}
|
|
|
|
test binary-27.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
|
|
binary scan abc s
|
|
} -result {not enough arguments for all format specifiers}
|
|
test binary-27.2 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54 s* arg1] $arg1
|
|
} {1 {-23726 21587}}
|
|
test binary-27.3 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54 s arg1] $arg1
|
|
} {1 -23726}
|
|
test binary-27.4 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3 s1 arg1] $arg1
|
|
} {1 -23726}
|
|
test binary-27.5 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3 s0 arg1] $arg1
|
|
} {1 {}}
|
|
test binary-27.6 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54 s2 arg1] $arg1
|
|
} {1 {-23726 21587}}
|
|
test binary-27.7 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
set arg1 foo
|
|
list [binary scan \x52 s1 arg1] $arg1
|
|
} {0 foo}
|
|
test binary-27.8 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -returnCodes error -body {
|
|
set arg1 1
|
|
binary scan \x52\x53 s1 arg1(a)
|
|
} -result {can't set "arg1(a)": variable isn't array}
|
|
test binary-27.9 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x52\xa3\x53\x54\x05 s2c* arg1 arg2] $arg1 $arg2
|
|
} {2 {-23726 21587} 5}
|
|
test binary-27.10 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54 su* arg1] $arg1
|
|
} {1 {41810 21587}}
|
|
test binary-27.11 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \xff\xff\xff\xff sus arg1 arg2] $arg1 $arg2
|
|
} {2 65535 -1}
|
|
test binary-27.12 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \xff\xff\xff\xff ssu arg1 arg2] $arg1 $arg2
|
|
} {2 -1 65535}
|
|
|
|
test binary-28.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
|
|
binary scan abc S
|
|
} -result {not enough arguments for all format specifiers}
|
|
test binary-28.2 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54 S* arg1] $arg1
|
|
} {1 {21155 21332}}
|
|
test binary-28.3 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54 S arg1] $arg1
|
|
} {1 21155}
|
|
test binary-28.4 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3 S1 arg1] $arg1
|
|
} {1 21155}
|
|
test binary-28.5 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3 S0 arg1] $arg1
|
|
} {1 {}}
|
|
test binary-28.6 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54 S2 arg1] $arg1
|
|
} {1 {21155 21332}}
|
|
test binary-28.7 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
set arg1 foo
|
|
list [binary scan \x52 S1 arg1] $arg1
|
|
} {0 foo}
|
|
test binary-28.8 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -returnCodes error -body {
|
|
set arg1 1
|
|
binary scan \x52\x53 S1 arg1(a)
|
|
} -result {can't set "arg1(a)": variable isn't array}
|
|
test binary-28.9 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x52\xa3\x53\x54\x05 S2c* arg1 arg2] $arg1 $arg2
|
|
} {2 {21155 21332} 5}
|
|
test binary-28.10 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54 Su* arg1] $arg1
|
|
} {1 {21155 21332}}
|
|
test binary-28.11 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \xa3\x52\x54\x53 Su* arg1] $arg1
|
|
} {1 {41810 21587}}
|
|
|
|
test binary-29.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
|
|
binary scan abc i
|
|
} -result {not enough arguments for all format specifiers}
|
|
test binary-29.2 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 i* arg1] $arg1
|
|
} {1 {1414767442 67305985}}
|
|
test binary-29.3 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 i arg1] $arg1
|
|
} {1 1414767442}
|
|
test binary-29.4 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54 i1 arg1] $arg1
|
|
} {1 1414767442}
|
|
test binary-29.5 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53 i0 arg1] $arg1
|
|
} {1 {}}
|
|
test binary-29.6 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 i2 arg1] $arg1
|
|
} {1 {1414767442 67305985}}
|
|
test binary-29.7 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
set arg1 foo
|
|
list [binary scan \x52 i1 arg1] $arg1
|
|
} {0 foo}
|
|
test binary-29.8 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -returnCodes error -body {
|
|
set arg1 1
|
|
binary scan \x52\x53\x53\x54 i1 arg1(a)
|
|
} -result {can't set "arg1(a)": variable isn't array}
|
|
test binary-29.9 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04\x05 i2c* arg1 arg2] $arg1 $arg2
|
|
} {2 {1414767442 67305985} 5}
|
|
test binary-29.10 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1 arg2
|
|
list [binary scan \xff\xff\xff\xff\xff\xff\xff\xff iui arg1 arg2] $arg1 $arg2
|
|
} {2 4294967295 -1}
|
|
test binary-29.11 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1 arg2
|
|
list [binary scan \xff\xff\xff\xff\xff\xff\xff\xff iiu arg1 arg2] $arg1 $arg2
|
|
} {2 -1 4294967295}
|
|
test binary-29.12 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1 arg2
|
|
list [binary scan \x80\x00\x00\x00\x00\x00\x00\x80 iuiu arg1 arg2] $arg1 $arg2
|
|
} {2 128 2147483648}
|
|
|
|
test binary-30.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
|
|
binary scan abc I
|
|
} -result {not enough arguments for all format specifiers}
|
|
test binary-30.2 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 I* arg1] $arg1
|
|
} {1 {1386435412 16909060}}
|
|
test binary-30.3 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 I arg1] $arg1
|
|
} {1 1386435412}
|
|
test binary-30.4 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54 I1 arg1] $arg1
|
|
} {1 1386435412}
|
|
test binary-30.5 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53 I0 arg1] $arg1
|
|
} {1 {}}
|
|
test binary-30.6 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 I2 arg1] $arg1
|
|
} {1 {1386435412 16909060}}
|
|
test binary-30.7 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
set arg1 foo
|
|
list [binary scan \x52 I1 arg1] $arg1
|
|
} {0 foo}
|
|
test binary-30.8 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -returnCodes error -body {
|
|
set arg1 1
|
|
binary scan \x52\x53\x53\x54 I1 arg1(a)
|
|
} -result {can't set "arg1(a)": variable isn't array}
|
|
test binary-30.9 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04\x05 I2c* arg1 arg2] $arg1 $arg2
|
|
} {2 {1386435412 16909060} 5}
|
|
test binary-30.10 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1 arg2
|
|
list [binary scan \xff\xff\xff\xff\xff\xff\xff\xff IuI arg1 arg2] $arg1 $arg2
|
|
} {2 4294967295 -1}
|
|
test binary-30.11 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1 arg2
|
|
list [binary scan \xff\xff\xff\xff\xff\xff\xff\xff IIu arg1 arg2] $arg1 $arg2
|
|
} {2 -1 4294967295}
|
|
test binary-30.12 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1 arg2
|
|
list [binary scan \x80\x00\x00\x00\x00\x00\x00\x80 IuIu arg1 arg2] $arg1 $arg2
|
|
} {2 2147483648 128}
|
|
|
|
test binary-33.1 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
unset -nocomplain arg2
|
|
list [binary scan abcdefg a2xa3 arg1 arg2] $arg1 $arg2
|
|
} {2 ab def}
|
|
test binary-33.2 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
unset -nocomplain arg2
|
|
set arg2 foo
|
|
list [binary scan abcdefg a3x*a3 arg1 arg2] $arg1 $arg2
|
|
} {1 abc foo}
|
|
test binary-33.3 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
unset -nocomplain arg2
|
|
set arg2 foo
|
|
list [binary scan abcdefg a3x20a3 arg1 arg2] $arg1 $arg2
|
|
} {1 abc foo}
|
|
test binary-33.4 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
unset -nocomplain arg2
|
|
set arg2 foo
|
|
list [binary scan abc a3x20a3 arg1 arg2] $arg1 $arg2
|
|
} {1 abc foo}
|
|
test binary-33.5 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan abcdef x1a1 arg1] $arg1
|
|
} {1 b}
|
|
test binary-33.6 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan abcdef x5a1 arg1] $arg1
|
|
} {1 f}
|
|
test binary-33.7 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan abcdef x0a1 arg1] $arg1
|
|
} {1 a}
|
|
|
|
test binary-34.1 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
unset -nocomplain arg2
|
|
list [binary scan abcdefg a2Xa3 arg1 arg2] $arg1 $arg2
|
|
} {2 ab bcd}
|
|
test binary-34.2 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
unset -nocomplain arg2
|
|
set arg2 foo
|
|
list [binary scan abcdefg a3X*a3 arg1 arg2] $arg1 $arg2
|
|
} {2 abc abc}
|
|
test binary-34.3 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
unset -nocomplain arg2
|
|
set arg2 foo
|
|
list [binary scan abcdefg a3X20a3 arg1 arg2] $arg1 $arg2
|
|
} {2 abc abc}
|
|
test binary-34.4 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan abc X20a3 arg1] $arg1
|
|
} {1 abc}
|
|
test binary-34.5 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan abcdef x*X1a1 arg1] $arg1
|
|
} {1 f}
|
|
test binary-34.6 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan abcdef x*X5a1 arg1] $arg1
|
|
} {1 b}
|
|
test binary-34.7 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan abcdef x3X0a1 arg1] $arg1
|
|
} {1 d}
|
|
|
|
test binary-35.1 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
unset -nocomplain arg2
|
|
} -returnCodes error -body {
|
|
binary scan abcdefg a2@a3 arg1 arg2
|
|
} -result {missing count for "@" field specifier}
|
|
test binary-35.2 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
unset -nocomplain arg2
|
|
set arg2 foo
|
|
list [binary scan abcdefg a3@*a3 arg1 arg2] $arg1 $arg2
|
|
} {1 abc foo}
|
|
test binary-35.3 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
unset -nocomplain arg2
|
|
set arg2 foo
|
|
list [binary scan abcdefg a3@20a3 arg1 arg2] $arg1 $arg2
|
|
} {1 abc foo}
|
|
test binary-35.4 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan abcdef @2a3 arg1] $arg1
|
|
} {1 cde}
|
|
test binary-35.5 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan abcdef x*@1a1 arg1] $arg1
|
|
} {1 b}
|
|
test binary-35.6 {Tcl_BinaryObjCmd: scan} {
|
|
unset -nocomplain arg1
|
|
list [binary scan abcdef x*@0a1 arg1] $arg1
|
|
} {1 a}
|
|
|
|
test binary-36.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
|
|
binary scan abcdef u0a3
|
|
} -result {bad field specifier "u"}
|
|
# Jim doesn't bother to throw errors on extra chars in the format spec
|
|
test binary-37.7 {GetFormatSpec: numbers} -returnCodes error -constraints tcl -body {
|
|
binary scan abcdef "x-1" foo
|
|
} -result {bad field specifier "-"}
|
|
test binary-37.8 {GetFormatSpec: numbers} {
|
|
unset -nocomplain arg1
|
|
set arg1 foo
|
|
list [binary scan abcdef "a0x3" arg1] $arg1
|
|
} {1 {}}
|
|
|
|
test binary-39.1 {ScanNumber: sign extension} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3 c2 arg1] $arg1
|
|
} {1 {82 -93}}
|
|
test binary-39.2 {ScanNumber: sign extension} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 s4 arg1] $arg1
|
|
} {1 {513 -32511 386 -32127}}
|
|
test binary-39.3 {ScanNumber: sign extension} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 S4 arg1] $arg1
|
|
} {1 {258 385 -32255 -32382}}
|
|
test binary-39.4 {ScanNumber: sign extension} {
|
|
unset -nocomplain arg1
|
|
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
|
|
} {1 {33620225 16843137 16876033 25297153 -2130640639}}
|
|
test binary-39.5 {ScanNumber: sign extension} {
|
|
unset -nocomplain arg1
|
|
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
|
|
} {1 {16843010 -2130640639 25297153 16876033 16843137}}
|
|
test binary-39.6 {ScanNumber: no sign extension} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3 cu2 arg1] $arg1
|
|
} {1 {82 163}}
|
|
test binary-39.7 {ScanNumber: no sign extension} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 su4 arg1] $arg1
|
|
} {1 {513 33025 386 33409}}
|
|
test binary-39.8 {ScanNumber: no sign extension} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 Su4 arg1] $arg1
|
|
} {1 {258 385 33281 33154}}
|
|
test binary-39.9 {ScanNumber: no sign extension} {
|
|
unset -nocomplain arg1
|
|
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
|
|
} {1 {33620225 16843137 16876033 25297153 2164326657}}
|
|
test binary-39.10 {ScanNumber: no sign extension} {
|
|
unset -nocomplain arg1
|
|
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
|
|
} {1 {16843010 2164326657 25297153 16876033 16843137}}
|
|
|
|
test binary-41.1 {ScanNumber: word alignment} {
|
|
unset -nocomplain arg1; unset arg2
|
|
list [binary scan \x01\x01\x00 c1s1 arg1 arg2] $arg1 $arg2
|
|
} {2 1 1}
|
|
test binary-41.2 {ScanNumber: word alignment} {
|
|
unset -nocomplain arg1; unset arg2
|
|
list [binary scan \x01\x00\x01 c1S1 arg1 arg2] $arg1 $arg2
|
|
} {2 1 1}
|
|
test binary-41.3 {ScanNumber: word alignment} {
|
|
unset -nocomplain arg1; unset arg2
|
|
list [binary scan \x01\x01\x00\x00\x00 c1i1 arg1 arg2] $arg1 $arg2
|
|
} {2 1 1}
|
|
test binary-41.4 {ScanNumber: word alignment} {
|
|
unset -nocomplain arg1; unset arg2
|
|
list [binary scan \x01\x00\x00\x00\x01 c1I1 arg1 arg2] $arg1 $arg2
|
|
} {2 1 1}
|
|
|
|
test binary-42.1 {Tcl_BinaryObjCmd: bad arguments} -constraints {} -body {
|
|
binary ?
|
|
} -returnCodes error -match glob -result {*}
|
|
|
|
test binary-44.1 {Tcl_BinaryObjCmd: scan wide int} {} {
|
|
binary scan HelloTcl W x
|
|
set x
|
|
} 5216694956358656876
|
|
test binary-44.2 {Tcl_BinaryObjCmd: scan wide int} {} {
|
|
binary scan lcTolleH w x
|
|
set x
|
|
} 5216694956358656876
|
|
test binary-44.3 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} {} {
|
|
binary scan [binary format w [expr {3 << 31}]] w x
|
|
set x
|
|
} 6442450944
|
|
test binary-44.4 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} {} {
|
|
binary scan [binary format W [expr {3 << 31}]] W x
|
|
set x
|
|
} 6442450944
|
|
test binary-43.5 {Tcl_BinaryObjCmd: scan wide int} {} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x80[string repeat \x00 7] W arg1] $arg1
|
|
} {1 -9223372036854775808}
|
|
# Note that Jim doesn't have unsigned 64 bit ints
|
|
test binary-43.6 {Tcl_BinaryObjCmd: scan unsigned wide int} {tcl} {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x80[string repeat \x00 7] Wu arg1] $arg1
|
|
} {1 9223372036854775808}
|
|
test binary-43.7 {Tcl_BinaryObjCmd: scan unsigned wide int} {tcl} {
|
|
unset -nocomplain arg1
|
|
list [binary scan [string repeat \x00 7]\x80 wu arg1] $arg1
|
|
} {1 9223372036854775808}
|
|
test binary-43.8 {Tcl_BinaryObjCmd: scan unsigned wide int} {tcl} {
|
|
unset -nocomplain arg1 arg2
|
|
list [binary scan \x80[string repeat \x00 7]\x80[string repeat \x00 7] WuW arg1 arg2] $arg1 $arg2
|
|
} {2 9223372036854775808 -9223372036854775808}
|
|
test binary-43.9 {Tcl_BinaryObjCmd: scan unsigned wide int} {tcl} {
|
|
unset -nocomplain arg1 arg2
|
|
list [binary scan [string repeat \x00 7]\x80[string repeat \x00 7]\x80 wuw arg1 arg2] $arg1 $arg2
|
|
} {2 9223372036854775808 -9223372036854775808}
|
|
|
|
test binary-45.1 {Tcl_BinaryObjCmd: combined wide int handling} {
|
|
binary scan [binary format sws 16450 -1 19521] c* x
|
|
set x
|
|
} {66 64 -1 -1 -1 -1 -1 -1 -1 -1 65 76}
|
|
test binary-45.2 {Tcl_BinaryObjCmd: combined wide int handling} {
|
|
binary scan [binary format sWs 16450 0x7fffffff 19521] c* x
|
|
set x
|
|
} {66 64 0 0 0 0 127 -1 -1 -1 65 76}
|
|
|
|
test binary-47.1 {Tcl_BinaryObjCmd: number cache reference count handling} {
|
|
# This test is only reliable when memory debugging is turned on, but
|
|
# without even memory debugging it should still generate the expected
|
|
# answers and might therefore still pick up memory corruption caused by
|
|
# [Bug 851747].
|
|
list [binary scan aba ccc x x x] $x
|
|
} {3 97}
|
|
|
|
test binary-50.3 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} littleEndian {
|
|
binary scan [binary format m [expr {3 << 31}]] w x
|
|
set x
|
|
} 6442450944
|
|
test binary-50.4 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} bigEndian {
|
|
binary scan [binary format m [expr {3 << 31}]] W x
|
|
set x
|
|
} 6442450944
|
|
|
|
# scan t (s)
|
|
test binary-54.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
|
|
binary scan abc t
|
|
} -result {not enough arguments for all format specifiers}
|
|
test binary-54.2 {Tcl_BinaryObjCmd: scan} littleEndian {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54 t* arg1] $arg1
|
|
} {1 {-23726 21587}}
|
|
test binary-54.3 {Tcl_BinaryObjCmd: scan} littleEndian {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54 t arg1] $arg1
|
|
} {1 -23726}
|
|
test binary-54.4 {Tcl_BinaryObjCmd: scan} littleEndian {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3 t1 arg1] $arg1
|
|
} {1 -23726}
|
|
test binary-54.5 {Tcl_BinaryObjCmd: scan} littleEndian {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3 t0 arg1] $arg1
|
|
} {1 {}}
|
|
test binary-54.6 {Tcl_BinaryObjCmd: scan} littleEndian {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54 t2 arg1] $arg1
|
|
} {1 {-23726 21587}}
|
|
test binary-54.7 {Tcl_BinaryObjCmd: scan} littleEndian {
|
|
unset -nocomplain arg1
|
|
set arg1 foo
|
|
list [binary scan \x52 t1 arg1] $arg1
|
|
} {0 foo}
|
|
test binary-54.8 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -returnCodes error -body {
|
|
set arg1 1
|
|
binary scan \x52\x53 t1 arg1(a)
|
|
} -result {can't set "arg1(a)": variable isn't array}
|
|
test binary-54.9 {Tcl_BinaryObjCmd: scan} littleEndian {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x52\xa3\x53\x54\x05 t2c* arg1 arg2] $arg1 $arg2
|
|
} {2 {-23726 21587} 5}
|
|
test binary-54.10 {Tcl_BinaryObjCmd: scan} littleEndian {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x00\x80\x00\x80 tut arg1 arg2] $arg1 $arg2
|
|
} {2 32768 -32768}
|
|
test binary-54.11 {Tcl_BinaryObjCmd: scan} littleEndian {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x00\x80\x00\x80 ttu arg1 arg2] $arg1 $arg2
|
|
} {2 -32768 32768}
|
|
|
|
# scan t (b)
|
|
test binary-55.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
|
|
binary scan abc t
|
|
} -result {not enough arguments for all format specifiers}
|
|
test binary-55.2 {Tcl_BinaryObjCmd: scan} bigEndian {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54 t* arg1] $arg1
|
|
} {1 {21155 21332}}
|
|
test binary-55.3 {Tcl_BinaryObjCmd: scan} bigEndian {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54 t arg1] $arg1
|
|
} {1 21155}
|
|
test binary-55.4 {Tcl_BinaryObjCmd: scan} bigEndian {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3 t1 arg1] $arg1
|
|
} {1 21155}
|
|
test binary-55.5 {Tcl_BinaryObjCmd: scan} bigEndian {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3 t0 arg1] $arg1
|
|
} {1 {}}
|
|
test binary-55.6 {Tcl_BinaryObjCmd: scan} bigEndian {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54 t2 arg1] $arg1
|
|
} {1 {21155 21332}}
|
|
test binary-55.7 {Tcl_BinaryObjCmd: scan} bigEndian {
|
|
unset -nocomplain arg1
|
|
set arg1 foo
|
|
list [binary scan \x52 t1 arg1] $arg1
|
|
} {0 foo}
|
|
test binary-55.8 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -returnCodes error -body {
|
|
set arg1 1
|
|
binary scan \x52\x53 t1 arg1(a)
|
|
} -result {can't set "arg1(a)": variable isn't array}
|
|
test binary-55.9 {Tcl_BinaryObjCmd: scan} bigEndian {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x52\xa3\x53\x54\x05 t2c* arg1 arg2] $arg1 $arg2
|
|
} {2 {21155 21332} 5}
|
|
test binary-55.10 {Tcl_BinaryObjCmd: scan} bigEndian {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x80\x00\x80\x00 tut arg1 arg2] $arg1 $arg2
|
|
} {2 32768 -32768}
|
|
test binary-55.11 {Tcl_BinaryObjCmd: scan} bigEndian {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x80\x00\x80\x00 ttu arg1 arg2] $arg1 $arg2
|
|
} {2 -32768 32768}
|
|
|
|
# scan n (s)
|
|
test binary-56.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
|
|
binary scan abc n
|
|
} -result {not enough arguments for all format specifiers}
|
|
test binary-56.2 {Tcl_BinaryObjCmd: scan} littleEndian {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 n* arg1] $arg1
|
|
} {1 {1414767442 67305985}}
|
|
test binary-56.3 {Tcl_BinaryObjCmd: scan} littleEndian {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 n arg1] $arg1
|
|
} {1 1414767442}
|
|
test binary-56.4 {Tcl_BinaryObjCmd: scan} littleEndian {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54 n1 arg1] $arg1
|
|
} {1 1414767442}
|
|
test binary-56.5 {Tcl_BinaryObjCmd: scan} littleEndian {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53 n0 arg1] $arg1
|
|
} {1 {}}
|
|
test binary-56.6 {Tcl_BinaryObjCmd: scan} littleEndian {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 n2 arg1] $arg1
|
|
} {1 {1414767442 67305985}}
|
|
test binary-56.7 {Tcl_BinaryObjCmd: scan} littleEndian {
|
|
unset -nocomplain arg1
|
|
set arg1 foo
|
|
list [binary scan \x52 n1 arg1] $arg1
|
|
} {0 foo}
|
|
test binary-56.8 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -returnCodes error -body {
|
|
set arg1 1
|
|
binary scan \x52\x53\x53\x54 n1 arg1(a)
|
|
} -result {can't set "arg1(a)": variable isn't array}
|
|
test binary-56.9 {Tcl_BinaryObjCmd: scan} littleEndian {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04\x05 n2c* arg1 arg2] $arg1 $arg2
|
|
} {2 {1414767442 67305985} 5}
|
|
test binary-56.10 {Tcl_BinaryObjCmd: scan} littleEndian {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x80\x00\x00\x00\x80\x00\x00\x00 nun arg1 arg2] $arg1 $arg2
|
|
} {2 128 128}
|
|
test binary-56.11 {Tcl_BinaryObjCmd: scan} littleEndian {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x00\x00\x00\x80\x00\x00\x00\x80 nun arg1 arg2] $arg1 $arg2
|
|
} {2 2147483648 -2147483648}
|
|
|
|
# scan n (b)
|
|
test binary-57.1 {Tcl_BinaryObjCmd: scan} -returnCodes error -body {
|
|
binary scan abc n
|
|
} -result {not enough arguments for all format specifiers}
|
|
test binary-57.2 {Tcl_BinaryObjCmd: scan} bigEndian {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 n* arg1] $arg1
|
|
} {1 {1386435412 16909060}}
|
|
test binary-57.3 {Tcl_BinaryObjCmd: scan} bigEndian {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 n arg1] $arg1
|
|
} {1 1386435412}
|
|
test binary-57.4 {Tcl_BinaryObjCmd: scan} bigEndian {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54 n1 arg1] $arg1
|
|
} {1 1386435412}
|
|
test binary-57.5 {Tcl_BinaryObjCmd: scan} bigEndian {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53 n0 arg1] $arg1
|
|
} {1 {}}
|
|
test binary-57.6 {Tcl_BinaryObjCmd: scan} bigEndian {
|
|
unset -nocomplain arg1
|
|
list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 n2 arg1] $arg1
|
|
} {1 {1386435412 16909060}}
|
|
test binary-57.7 {Tcl_BinaryObjCmd: scan} bigEndian {
|
|
unset -nocomplain arg1
|
|
set arg1 foo
|
|
list [binary scan \x52 n1 arg1] $arg1
|
|
} {0 foo}
|
|
test binary-57.8 {Tcl_BinaryObjCmd: scan} -setup {
|
|
unset -nocomplain arg1
|
|
} -returnCodes error -body {
|
|
set arg1 1
|
|
binary scan \x52\x53\x53\x54 n1 arg1(a)
|
|
} -result {can't set "arg1(a)": variable isn't array}
|
|
test binary-57.9 {Tcl_BinaryObjCmd: scan} bigEndian {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04\x05 n2c* arg1 arg2] $arg1 $arg2
|
|
} {2 {1386435412 16909060} 5}
|
|
test binary-57.10 {Tcl_BinaryObjCmd: scan} bigEndian {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x80\x00\x00\x00\x80\x00\x00\x00 nun arg1 arg2] $arg1 $arg2
|
|
} {2 2147483648 -2147483648}
|
|
test binary-57.11 {Tcl_BinaryObjCmd: scan} bigEndian {
|
|
unset -nocomplain arg1 arg2
|
|
set arg1 foo
|
|
set arg2 bar
|
|
list [binary scan \x00\x00\x00\x80\x00\x00\x00\x80 nun arg1 arg2] $arg1 $arg2
|
|
} {2 128 128}
|
|
|
|
# scan m
|
|
test binary-61.1 {Tcl_BinaryObjCmd: scan wide int} bigEndian {
|
|
binary scan HelloTcl m x
|
|
set x
|
|
} 5216694956358656876
|
|
test binary-61.2 {Tcl_BinaryObjCmd: scan wide int} littleEndian {
|
|
binary scan lcTolleH m x
|
|
set x
|
|
} 5216694956358656876
|
|
test binary-61.3 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} littleEndian {
|
|
binary scan [binary format w [expr {3 << 31}]] m x
|
|
set x
|
|
} 6442450944
|
|
test binary-61.4 {Tcl_BinaryObjCmd: scan wide int with bit 31 set} bigEndian {
|
|
binary scan [binary format W [expr {3 << 31}]] m x
|
|
set x
|
|
} 6442450944
|
|
|
|
testreport
|