diff options
author | mdejong <mdejong> | 2005-10-29 19:58:03 (GMT) |
---|---|---|
committer | mdejong <mdejong> | 2005-10-29 19:58:03 (GMT) |
commit | 6be14f61697812be0c6c88514b8ca2ae46b24c41 (patch) | |
tree | c0ef0d702b3546687ccf2ea7435a06b686276cf7 /tests/expr.test | |
parent | dc124c044dd934b96c8b7b90c3d7fc451cc85c84 (diff) | |
download | tcl-6be14f61697812be0c6c88514b8ca2ae46b24c41.zip tcl-6be14f61697812be0c6c88514b8ca2ae46b24c41.tar.gz tcl-6be14f61697812be0c6c88514b8ca2ae46b24c41.tar.bz2 |
* tests/expr.test: Fix problems in new round()
tests that lead to correct result only on 32
bit long systems. [Bug 1341368]
Diffstat (limited to 'tests/expr.test')
-rw-r--r-- | tests/expr.test | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/tests/expr.test b/tests/expr.test index 6fa2129..ff4bc0f 100644 --- a/tests/expr.test +++ b/tests/expr.test @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: expr.test,v 1.17.2.9 2005/10/28 03:26:32 mdejong Exp $ +# RCS: @(#) $Id: expr.test,v 1.17.2.10 2005/10/29 19:58:04 mdejong Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -899,35 +899,39 @@ test expr-46.12 {round() boundary case - -1/2 + 1 ulp} { expr {round($x)} } 0 -test expr-46.13 {round() boundary case - largest int} { - set imax [expr {((1<<31) + 1) * -1}] - expr {round($imax - 0.51)} -} 2147483646 +if {int(0x80000000) < 0} { + # 32 bit long + set min_long -2147483648 + set max_long 2147483647 +} else { + # 64 bit long + set min_long -9223372036854775808 + set max_long 9223372036854775807 +} -test expr-46.14 {round() boundary case - largest int} { - set imax [expr {((1<<31) + 1) * -1}] - expr {round($imax - 0.50)} -} 2147483647 +test expr-46.13 {round() boundary case - round down} { + expr {round($max_long - 0.51)} +} [expr {$max_long - 1}] -test expr-46.15 {round() boundary case - becomes wide int} { - set imax [expr {((1<<31) + 1) * -1}] - expr {round($imax + 0.50)} -} 2147483648 +test expr-46.14 {round() boundary case - round up} { + expr {round($max_long - 0.50)} +} $max_long + +test expr-46.15 {round() boundary case - round up to wide} { + expr {round($max_long + 0.50)} +} [expr {wide($max_long) + 1}] -test expr-46.16 {round() boundary case - smallest int} { - set imin [expr {1<<31}] - expr {round($imin + 0.51)} -} -2147483647 +test expr-46.16 {round() boundary case - round up} { + expr {round($min_long + 0.51)} +} [expr {$min_long + 1}] -test expr-46.17 {round() boundary case - smallest int} { - set imin [expr {1<<31}] - expr {round($imin + 0.50)} -} -2147483648 +test expr-46.17 {round() boundary case - round down} { + expr {round($min_long + 0.50)} +} $min_long -test expr-46.18 {round() boundary case - becomes wide int} { - set imin [expr {1<<31}] - expr {round($imin - 0.50)} -} -2147483649 +test expr-46.18 {round() boundary case - round down to wide} { + expr {round($min_long - 0.50)} +} [expr {wide($min_long) - 1}] # cleanup |