diff options
author | dgp <dgp@users.sourceforge.net> | 2005-07-28 18:42:28 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2005-07-28 18:42:28 (GMT) |
commit | cb789f51b77dd4702d548d9aa828a757472b725a (patch) | |
tree | 85f757e2612f551d93a44ffbca41b861711fe9b2 /tests/format.test | |
parent | 97b69e6ac0b3bfe72f1e3e4a490af5a45fb22776 (diff) | |
download | tcl-cb789f51b77dd4702d548d9aa828a757472b725a.zip tcl-cb789f51b77dd4702d548d9aa828a757472b725a.tar.gz tcl-cb789f51b77dd4702d548d9aa828a757472b725a.tar.bz2 |
* tests/compExpr-old.test: Still more conversion of "nonPortable"
* tests/error.test: tests into tests with constraints that
* tests/expr-old.test: describe the limits of their
* tests/expr.test: portability. Also more consolidation
* tests/fileName.test: of constraint synonyms.
* tests/format.test: wideis64bit, 64bitInts => wideIs64bit
* tests/get.test: wideIntegerUnparsed => wideIs32bit
* tests/load.test: wideIntExpressions => wideBiggerThanInt
* tests/obj.test:
* tests/parseExpr.test: Dropped "roundOffBug" constraint that
* tests/string.test: protected from buggy sprintf.
Diffstat (limited to 'tests/format.test')
-rw-r--r-- | tests/format.test | 73 |
1 files changed, 43 insertions, 30 deletions
diff --git a/tests/format.test b/tests/format.test index afb18b0..a6e2242 100644 --- a/tests/format.test +++ b/tests/format.test @@ -10,32 +10,30 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: format.test,v 1.20 2005/06/17 23:41:03 dkf Exp $ +# RCS: @(#) $Id: format.test,v 1.21 2005/07/28 18:42:32 dgp Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 namespace import -force ::tcltest::* } -# The following code is needed because some versions of SCO Unix have -# a round-off error in sprintf which would cause some of the tests to -# fail. Someday I hope this code shouldn't be necessary (code added -# 9/9/91). - -testConstraint roundOffBug [expr {"[format %7.1e 68.514]" != "6.8e+01"}] - test format-1.1 {integer formatting} { format "%*d %d %d %d" 6 34 16923 -12 -1 } { 34 16923 -12 -1} -test format-1.2 {integer formatting} {nonPortable} { +test format-1.2 {integer formatting} { format "%4d %4d %4d %4d %d %#x %#X" 6 34 16923 -12 -1 14 12 } { 6 34 16923 -12 -1 0xe 0XC} # %u output depends on word length, so this test is not portable. +testConstraint longIs32bit [expr {int(0x80000000) < 0}] +testConstraint longIs64bit [expr {int(0x8000000000000000) < 0}] -test format-1.3 {integer formatting} {nonPortable} { +test format-1.3 {integer formatting} longIs32bit { format "%4u %4u %4u %4u %d %#o" 6 34 16923 -12 -1 0 } { 6 34 16923 4294967284 -1 0} +test format-1.3.1 {integer formatting} longIs64bit { + format "%4u %4u %4u %4u %d %#o" 6 34 16923 -12 -1 0 +} { 6 34 16923 18446744073709551604 -1 0} test format-1.4 {integer formatting} { format "%-4d %-4i %-4d %-4ld" 6 34 16923 -12 -1 } {6 34 16923 -12 } @@ -49,21 +47,36 @@ test format-1.6 {integer formatting} { # Printing negative numbers in hex or octal format depends on word # length, so these tests are not portable. -test format-1.7 {integer formatting} {nonPortable} { +test format-1.7 {integer formatting} longIs32bit { format "%4x %4x %4x %4x" 6 34 16923 -12 -1 } { 6 22 421b fffffff4} -test format-1.8 {integer formatting} {nonPortable} { +test format-1.7.1 {integer formatting} longIs64bit { + format "%4x %4x %4x %4x" 6 34 16923 -12 -1 +} { 6 22 421b fffffffffffffff4} +test format-1.8 {integer formatting} longIs32bit { format "%#x %#X %#X %#x" 6 34 16923 -12 -1 } {0x6 0X22 0X421B 0xfffffff4} -test format-1.9 {integer formatting} {nonPortable} { +test format-1.8.1 {integer formatting} longIs64bit { + format "%#x %#X %#X %#x" 6 34 16923 -12 -1 +} {0x6 0X22 0X421B 0xfffffffffffffff4} +test format-1.9 {integer formatting} longIs32bit { format "%#20x %#20x %#20x %#20x" 6 34 16923 -12 -1 } { 0x6 0x22 0x421b 0xfffffff4} -test format-1.10 {integer formatting} {nonPortable} { +test format-1.9.1 {integer formatting} longIs64bit { + format "%#20x %#20x %#20x %#20x" 6 34 16923 -12 -1 +} { 0x6 0x22 0x421b 0xfffffffffffffff4} +test format-1.10 {integer formatting} longIs32bit { format "%-#20x %-#20x %-#20x %-#20x" 6 34 16923 -12 -1 } {0x6 0x22 0x421b 0xfffffff4 } -test format-1.11 {integer formatting} {nonPortable} { +test format-1.10.1 {integer formatting} longIs64bit { + format "%-#20x %-#20x %-#20x %-#20x" 6 34 16923 -12 -1 +} {0x6 0x22 0x421b 0xfffffffffffffff4 } +test format-1.11 {integer formatting} longIs32bit { format "%-#20o %#-20o %#-20o %#-20o" 6 34 16923 -12 -1 } {06 042 041033 037777777764 } +test format-1.11.1 {integer formatting} longIs64bit { + format "%-#20o %#-20o %#-20o %#-20o" 6 34 16923 -12 -1 +} {06 042 041033 01777777777777777777764} test format-2.1 {string formatting} { format "%s %s %c %s" abcd {This is a very long test string.} 120 x @@ -130,19 +143,19 @@ test format-4.1 {e and f formats} {eformat} { test format-4.2 {e and f formats} {eformat} { format "%20e %20e %20e %20e" 34.2e12 68.514 -.125 -16000. .000053 } { 3.420000e+13 6.851400e+01 -1.250000e-01 -1.600000e+04} -test format-4.3 {e and f formats} {eformat roundOffBug} { +test format-4.3 {e and f formats} {eformat} { format "%.1e %.1e %.1e %.1e" 34.2e12 68.514 -.126 -16000. .000053 } {3.4e+13 6.9e+01 -1.3e-01 -1.6e+04} -test format-4.4 {e and f formats} {eformat roundOffBug} { +test format-4.4 {e and f formats} {eformat} { format "%020e %020e %020e %020e" 34.2e12 68.514 -.126 -16000. .000053 } {000000003.420000e+13 000000006.851400e+01 -00000001.260000e-01 -00000001.600000e+04} -test format-4.5 {e and f formats} {eformat roundOffBug} { +test format-4.5 {e and f formats} {eformat} { format "%7.1e %7.1e %7.1e %7.1e" 34.2e12 68.514 -.126 -16000. .000053 } {3.4e+13 6.9e+01 -1.3e-01 -1.6e+04} -test format-4.6 {e and f formats roundOffBug} { +test format-4.6 {e and f formats} { format "%f %f %f %f" 34.2e12 68.514 -.125 -16000. .000053 } {34200000000000.000000 68.514000 -0.125000 -16000.000000} -test format-4.7 {e and f formats} {nonPortable} { +test format-4.7 {e and f formats} { format "%.4f %.4f %.4f %.4f %.4f" 34.2e12 68.514 -.125 -16000. .000053 } {34200000000000.0000 68.5140 -0.1250 -16000.0000 0.0001} test format-4.8 {e and f formats} {eformat} { @@ -355,13 +368,13 @@ test format-9.1 {long result} { format {1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG %s %s} $a $a } {1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG 1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 1 2 3 4 5 6 7 8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 1 2 3 4 5 6 7 8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z} -test format-10.1 {"h" format specifier} {nonPortable} { +test format-10.1 {"h" format specifier} { format %hd 0xffff } -1 -test format-10.2 {"h" format specifier} {nonPortable} { +test format-10.2 {"h" format specifier} { format %hx 0x10fff } fff -test format-10.3 {"h" format specifier} {nonPortable} { +test format-10.3 {"h" format specifier} { format %hd 0x10000 } 0 test format-10.4 {"h" format specifier} { @@ -490,18 +503,18 @@ for {set i 290} {$i < 400} {incr i} { append b "x" } -::tcltest::testConstraint 64bitInts \ - [expr {0x80000000 > 0}] -::tcltest::testConstraint wideIntExpressions \ +::tcltest::testConstraint wideIs64bit \ + [expr {(0x80000000 > 0) && (0x8000000000000000 < 0)}] +::tcltest::testConstraint wideBiggerThanInt \ [expr {wide(0x80000000) != int(0x80000000)}] -test format-17.1 {testing %d with wide} {64bitInts wideIntExpressions} { +test format-17.1 {testing %d with wide} {wideIs64bit wideBiggerThanInt} { list [catch {format %d 7810179016327718216} msg] $msg } {1 {integer value too large to represent}} -test format-17.2 {testing %ld with wide} {64bitInts} { +test format-17.2 {testing %ld with wide} {wideIs64bit} { format %ld 7810179016327718216 } 7810179016327718216 -test format-17.3 {testing %ld with non-wide} {64bitInts} { +test format-17.3 {testing %ld with non-wide} {wideIs64bit} { format %ld 42 } 42 test format-17.4 {testing %l with non-integer} { @@ -525,7 +538,7 @@ test format-18.1 {do not demote existing numeric values} { format %08x $b lappend result [expr {$a == $b}] } {1 1 1 1} -test format-18.2 {do not demote existing numeric values} {wideIntExpressions} { +test format-18.2 {do not demote existing numeric values} {wideBiggerThanInt} { set a [expr {0xaaaaaaaaaa + 1}] set b 0xaaaaaaaaab list [catch {format %08x $a} msg] $msg [expr {$a == $b}] |