summaryrefslogtreecommitdiff
path: root/contrib/tcl/tests/scan.test
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/tcl/tests/scan.test')
-rw-r--r--contrib/tcl/tests/scan.test56
1 files changed, 25 insertions, 31 deletions
diff --git a/contrib/tcl/tests/scan.test b/contrib/tcl/tests/scan.test
index 0b2da90cda12b..9f73bf13ecfb5 100644
--- a/contrib/tcl/tests/scan.test
+++ b/contrib/tcl/tests/scan.test
@@ -5,12 +5,12 @@
# generates output for errors. No output means no errors were found.
#
# Copyright (c) 1991-1994 The Regents of the University of California.
-# Copyright (c) 1994 Sun Microsystems, Inc.
+# Copyright (c) 1994-1997 Sun Microsystems, Inc.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# SCCS: @(#) scan.test 1.23 96/02/16 08:56:24
+# SCCS: @(#) scan.test 1.25 97/01/21 21:16:03
if {[string compare test [info procs test]] == 1} then {source defs}
@@ -55,6 +55,11 @@ test scan-1.10 {integer scanning} {
set a {}; set b {}; set c {}; set d {}
list [scan "1 2 " "%hd %d %d %d" a b c d] $a $b $c $d
} {2 1 2 {} {}}
+#
+# The behavior for scaning intergers larger than MAX_INT is
+# not defined by the ANSI spec. Some implementations wrap the
+# input (-16) some return MAX_INT.
+#
test scan-1.11 {integer scanning} {nonPortable} {
set a {}; set b {};
list [scan "4294967280 4294967280" "%u %d" a b] $a $b
@@ -62,35 +67,44 @@ test scan-1.11 {integer scanning} {nonPortable} {
test scan-2.1 {floating-point scanning} {
set a {}; set b {}; set c {}; set d {}
- list [scan "2.1 -3.0e8 .99962 a" "%f%g%e%f" a b c d] $a $b $c $d
+ list [scan "2.1 -3.0e8 .99962 a" "%f%g%e%f" a b c d] \
+ [format %.6g $a] [format %.6g $b] [format %.6g $c] $d
} {3 2.1 -3e+08 0.99962 {}}
test scan-2.2 {floating-point scanning} {
set a {}; set b {}; set c {}; set d {}
- list [scan "-1.2345 +8.2 9" "%3e %3lf %f %f" a b c d] $a $b $c $d
-} {4 -1.0 234.0 5.0 8.2}
+ list [scan "-1.2345 +8.2 9" "%3e %3lf %f %f" a b c d] \
+ [format %.6g $a] [format %.6g $b] [format %.6g $c] [format %.6g $d]
+} {4 -1 234 5 8.2}
test scan-2.3 {floating-point scanning} {
set a {}; set b {}; set c {}
list [scan "1e00004 332E-4 3e+4" "%Lf %*2e %f %f" a b c] $a $c
} {3 10000.0 30000.0}
+#
+# Some libc implementations consider 3.e- bad input. The ANSI
+# spec states that digits must follow the - sign.
+#
test scan-2.4 {floating-point scanning} {nonPortable} {
set a {}; set b {}; set c {}
list [scan "1. 47.6 2.e2 3.e-" "%f %*f %f %f" a b c] $a $b $c
} {3 1.0 200.0 3.0}
test scan-2.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}
+ list [scan "4.6 99999.7 876.43e-1 118" "%f %f %f %e" a b c d] \
+ [format %.6g $a] [format %.6g $b] [format %.6g $c] [format %.6g $d]
+} {4 4.6 99999.7 87.643 118}
test scan-2.6 {floating-point scanning} {
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}
+ list [scan "1.2345 697.0e-3 124 .00005" "%f %e %f %e" a b c d] \
+ [format %.6g $a] [format %.6g $b] [format %.6g $c] [format %.6g $d]
+} {4 1.2345 0.697 124 5e-05}
test scan-2.7 {floating-point scanning} {
set a {}; set b {}; set c {}; set d {}
- list [scan "4.6abc" "%f %f %f %f" a b c d] $a $b $c $d
+ list [scan "4.6abc" "%f %f %f %f" a b c d] [format %.6g $a] $b $c $d
} {1 4.6 {} {} {}}
test scan-2.8 {floating-point scanning} {
set a {}; set b {}; set c {}; set d {}
- list [scan "4.6 5.2" "%f %f %f %f" a b c d] $a $b $c $d
+ list [scan "4.6 5.2" "%f %f %f %f" a b c d] \
+ [format %.6g $a] [format %.6g $b] $c $d
} {2 4.6 5.2 {} {}}
test scan-3.1 {string and character scanning} {
@@ -214,26 +228,6 @@ test scan-6.4 {miscellaneous tests} {
set a {}
list [catch {scan ab%c14 ab%%c%d a} msg] $msg $a
} {0 1 14}
-test scan-6.5 {miscellaneous tests} {
- catch {unset tcl_precision}
- set a {}
- scan 1.111122223333 %f a
- set a
-} {1.11112}
-test scan-6.6 {miscellaneous tests} {
- set tcl_precision 10
- set a {}
- scan 1.111122223333 %lf a
- unset tcl_precision
- set a
-} {1.111122223}
-test scan-6.7 {miscellaneous tests} {
- set tcl_precision 10
- set a {}
- scan 1.111122223333 %f a
- unset tcl_precision
- set a
-} {1.111122223}
test scan-7.1 {alignment in results array (TCL_ALIGN)} {
scan "123 13.6" "%s %f" a b