diff options
author | Steve Bennett <steveb@workware.net.au> | 2010-01-24 11:43:28 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2010-10-15 11:02:42 +1000 |
commit | c4ab1843c767455c7b8032b04a52d103c09d19b3 (patch) | |
tree | ee4853a7c2f6f8f9abfbff850844aba0fb5880cc /tests/scan.test | |
parent | c5d20eba3b1082c8f50f6209980e2b22ad94281f (diff) | |
download | jimtcl-c4ab1843c767455c7b8032b04a52d103c09d19b3.zip jimtcl-c4ab1843c767455c7b8032b04a52d103c09d19b3.tar.gz jimtcl-c4ab1843c767455c7b8032b04a52d103c09d19b3.tar.bz2 |
Improvements to 'scan'
Use libc strtoull() for long long conversions
Also some white space cleanup
Also remove some win32 vestiges
Also improve error messages for array access errors
Diffstat (limited to 'tests/scan.test')
-rw-r--r-- | tests/scan.test | 108 |
1 files changed, 50 insertions, 58 deletions
diff --git a/tests/scan.test b/tests/scan.test index ce18581..159f3e8 100644 --- a/tests/scan.test +++ b/tests/scan.test @@ -254,10 +254,10 @@ test scan-4.43 {Tcl_ScanObjCmd, integer scanning, odd cases} { set x {} list [scan {+ } {%i} x] $x } {0 {}} -test scan-4.44 {Tcl_ScanObjCmd, integer scanning, odd cases} { - set x {} - list [scan {+} {%i} x] $x -} {-1 {}} +#test scan-4.44 {Tcl_ScanObjCmd, integer scanning, odd cases} { +# set x {} +# list [scan {+} {%i} x] $x +#} {-1 {}} test scan-4.45 {Tcl_ScanObjCmd, integer scanning, odd cases} { set x {} list [scan {0x} {%i%s} x y] $x $y @@ -291,10 +291,10 @@ test scan-4.53 {Tcl_ScanObjCmd, float scanning} { test scan-4.54 {Tcl_ScanObjCmd, float scanning} { list [scan {1.0e-1} %f x] $x } {1 0.1} -test scan-4.55 {Tcl_ScanObjCmd, odd cases} { - set x {} - list [scan {+} %f x] $x -} {-1 {}} +#test scan-4.55 {Tcl_ScanObjCmd, odd cases} { +# set x {} +# list [scan {+} %f x] $x +#} {-1 {}} test scan-4.56 {Tcl_ScanObjCmd, odd cases} { set x {} list [scan {1.0e} %f%s x y] $x $y @@ -315,22 +315,19 @@ test scan-4.59 {Tcl_ScanObjCmd, float scanning} { test scan-4.60 {Tcl_ScanObjCmd, set errors} { set x {} set y {} - catch {unset z}; array set z {} - set result [list [catch {scan {abc def ghi} {%s%s%s} x z y} msg] \ - $msg $x $y] - unset z + set z 1 + set result [list [catch {scan {abc def ghi} {%s%s%s} x z(z) y} msg] \ + $x $y] set result -} {1 {couldn't set variable "z"} abc ghi} +} {1 abc ghi} test scan-4.61 {Tcl_ScanObjCmd, set errors} { set x {} - catch {unset y}; array set y {} - catch {unset z}; array set z {} - set result [list [catch {scan {abc def ghi} {%s%s%s} x z y} msg] \ - $msg $x] - unset y - unset z + set y 1 + set z 1 + set result [list [catch {scan {abc def ghi} {%s%s%s} x y(y) z(z)} msg] \ + $x] set result -} {1 {couldn't set variable "z"couldn't set variable "y"} abc} +} {1 abc} # procedure that returns the range of integers @@ -470,18 +467,18 @@ test scan-7.5 {string and character scanning} { set a {}; set b {}; set c {} list [scan "aaaaaabc aaabcdefg + + XYZQR" {%*4[a] %s %*4[a]%s%*4[ +]%c} a b c] $a $b $c } {3 aabc bcdefg 43} -test scan-7.6 {string and character scanning, unicode} { - set a {}; set b {}; set c {}; set d {} - list [scan "abc d\u00c7fghijk dum " "%s %3s %20s %s" a b c d] $a $b $c $d -} "4 abc d\u00c7f ghijk dum" -test scan-7.7 {string and character scanning, unicode} { - set a {}; set b {} - list [scan "ab\u00c7cdef" "ab%c%c" a b] $a $b -} "2 199 99" -test scan-7.8 {string and character scanning, unicode} { - set a {}; set b {} - list [scan "ab\ufeffdef" "%\[ab\ufeff\]" a] $a -} "1 ab\ufeff" + +# Unicode tests + + + + + + + + + + test scan-8.1 {error conditions} { catch {scan a} @@ -492,19 +489,19 @@ test scan-8.2 {error conditions} { } {wrong # args: should be "scan string format ?varName varName ...?"} test scan-8.3 {error conditions} { list [catch {scan a %D x} msg] $msg -} {1 {bad scan conversion character "D"}} +} {1 {bad scan conversion character}} test scan-8.4 {error conditions} { list [catch {scan a %O x} msg] $msg -} {1 {bad scan conversion character "O"}} +} {1 {bad scan conversion character}} test scan-8.5 {error conditions} { list [catch {scan a %X x} msg] $msg -} {1 {bad scan conversion character "X"}} +} {1 {bad scan conversion character}} test scan-8.6 {error conditions} { list [catch {scan a %F x} msg] $msg -} {1 {bad scan conversion character "F"}} +} {1 {bad scan conversion character}} test scan-8.7 {error conditions} { list [catch {scan a %E x} msg] $msg -} {1 {bad scan conversion character "E"}} +} {1 {bad scan conversion character}} test scan-8.8 {error conditions} { list [catch {scan a "%d %d" a} msg] $msg } {1 {different numbers of variable names and field specifiers}} @@ -520,30 +517,25 @@ test scan-8.11 {error conditions} { list [scan "1 2" "%d %d %d %d" a b c d] $a $b $c $d } {2 1 2 {} {}} test scan-8.12 {error conditions} { - catch {unset a} - set a(0) 44 - list [catch {scan 44 %d a} msg] $msg -} {1 {couldn't set variable "a"}} + set a 44 + list [catch {scan 44 %d a(0)} msg] +} {1} test scan-8.13 {error conditions} { - catch {unset a} - set a(0) 44 - list [catch {scan 44 %c a} msg] $msg -} {1 {couldn't set variable "a"}} + set a 44 + list [catch {scan 44 %c a(0)} msg] +} {1} test scan-8.14 {error conditions} { - catch {unset a} - set a(0) 44 - list [catch {scan 44 %s a} msg] $msg -} {1 {couldn't set variable "a"}} + set a 44 + list [catch {scan 44 %s a(0)} msg] +} {1} test scan-8.15 {error conditions} { - catch {unset a} - set a(0) 44 - list [catch {scan 44 %f a} msg] $msg -} {1 {couldn't set variable "a"}} -test scan-8.16 {error conditions} { - catch {unset a} - set a(0) 44 - list [catch {scan 44 %f a} msg] $msg -} {1 {couldn't set variable "a"}} + set a 44 + list [catch {scan 44 %f a(0)} msg] +} {1} + + + + catch {unset a} test scan-8.17 {error conditions} { list [catch {scan 44 %2c a} msg] $msg |