diff options
Diffstat (limited to 'tests/scan.test')
-rw-r--r-- | tests/scan.test | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/tests/scan.test b/tests/scan.test index 63e9751..0614d56 100644 --- a/tests/scan.test +++ b/tests/scan.test @@ -1,5 +1,3 @@ -source testing.tcl - # Commands covered: scan # # This file contains a collection of tests for one or more of the Tcl @@ -15,10 +13,14 @@ source testing.tcl # # RCS: @(#) $Id: scan.test,v 1.10.2.2 2002/02/07 01:54:04 hobbs Exp $ +source [file dirname [info script]]/testing.tcl + +needs cmd scan + test scan-1.1 {BuildCharSet, CharInSet} { list [scan foo {%[^o]} x] $x } {1 f} -test scan-1.2 {BuildCharSet, CharInSet} { +test scan-1.2 {BuildCharSet, CharInSet} jim { list [scan \]foo {%[]f]} x] $x } {1 {]f}} test scan-1.3 {BuildCharSet, CharInSet} { @@ -67,7 +69,7 @@ test scan-3.4 {ValidateFormat} { test scan-3.5 {ValidateFormat} { list [catch {scan {} {%10c} a} msg] $msg } {1 {field width may not be specified in %c conversion}} -test scan-3.6 {ValidateFormat} { +test scan-3.6 {ValidateFormat} jim { list [catch {scan {} {%*1$d} a} msg] $msg } {1 {bad scan conversion character}} test scan-3.7 {ValidateFormat} { @@ -92,10 +94,10 @@ test scan-3.13 {ValidateFormat} { list [catch {scan {} {%[^]a} x} msg] $msg } {1 {unmatched [ in format string}} -test scan-4.1 {Tcl_ScanObjCmd, argument checks} { +test scan-4.1 {Tcl_ScanObjCmd, argument checks} jim { list [catch {scan} msg] $msg } {1 {wrong # args: should be "scan string format ?varName varName ...?"}} -test scan-4.2 {Tcl_ScanObjCmd, argument checks} { +test scan-4.2 {Tcl_ScanObjCmd, argument checks} jim { list [catch {scan string} msg] $msg } {1 {wrong # args: should be "scan string format ?varName varName ...?"}} test scan-4.3 {Tcl_ScanObjCmd, argument checks} { @@ -331,6 +333,7 @@ test scan-4.61 {Tcl_ScanObjCmd, set errors} { # procedure that returns the range of integers +# On Tcl with bignum, these won't produce a result! proc int_range {} { for { set MIN_INT 1 } { $MIN_INT > 0 } {} { set MIN_INT [expr { $MIN_INT << 1 }] @@ -339,13 +342,13 @@ proc int_range {} { return [list $MIN_INT $MAX_INT] } -test scan-4.62 {scanning of large and negative octal integers} { +test scan-4.62 {scanning of large and negative octal integers} jim { foreach { MIN_INT MAX_INT } [int_range] {} set scanstring [format {%o %o %o} -1 $MIN_INT $MAX_INT] list [scan $scanstring {%o %o %o} a b c] \ [expr { $a == -1 }] [expr { $b == $MIN_INT }] [expr { $c == $MAX_INT }] } {3 1 1 1} -test scan-4.63 {scanning of large and negative hex integers} { +test scan-4.63 {scanning of large and negative hex integers} jim { foreach { MIN_INT MAX_INT } [int_range] {} set scanstring [format {%x %x %x} -1 $MIN_INT $MAX_INT] list [scan $scanstring {%x %x %x} a b c] \ @@ -434,7 +437,7 @@ test scan-6.5 {floating-point scanning} { set a {}; set b {}; set c {}; set d {} list [scan "4.6 99999.7 876.43e-1 118" "%f %f %f %e" a b c d] $a $b $c $d } {4 4.6 99999.7 87.643 118.0} -test scan-6.6 {floating-point scanning} { +test scan-6.6 {floating-point scanning} jim { set a {}; set b {}; set c {}; set d {} list [scan "1.2345 697.0e-3 124 .00005" "%f %e %f %e" a b c d] $a $b $c $d } {4 1.2345 0.697 124.0 5e-05} @@ -467,41 +470,38 @@ 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} -ifutf8 { - 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" -} - +test scan-7.6 {string and character scanning, unicode} utf8 { + 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} utf8 { + 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} utf8 { + set a {}; set b {} + list [scan "ab\ufeffdef" "%\[ab\ufeff\]" a] $a +} "1 ab\ufeff" test scan-8.1 {error conditions} { catch {scan a} } 1 -test scan-8.2 {error conditions} { +test scan-8.2 {error conditions} jim { catch {scan a} msg set msg } {wrong # args: should be "scan string format ?varName varName ...?"} -test scan-8.3 {error conditions} { +test scan-8.3 {error conditions} jim { list [catch {scan a %D x} msg] $msg } {1 {bad scan conversion character}} -test scan-8.4 {error conditions} { +test scan-8.4 {error conditions} jim { list [catch {scan a %O x} msg] $msg } {1 {bad scan conversion character}} -test scan-8.5 {error conditions} { +test scan-8.5 {error conditions} jim { list [catch {scan a %X x} msg] $msg } {1 {bad scan conversion character}} -test scan-8.6 {error conditions} { +test scan-8.6 {error conditions} jim { list [catch {scan a %F x} msg] $msg } {1 {bad scan conversion character}} -test scan-8.7 {error conditions} { +test scan-8.7 {error conditions} jim { list [catch {scan a %E x} msg] $msg } {1 {bad scan conversion character}} test scan-8.8 {error conditions} { |