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 | |
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]
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | tests/expr.test | 54 |
2 files changed, 47 insertions, 25 deletions
@@ -1,3 +1,9 @@ +2005-10-29 Mo DeJong <mdejong@users.sourceforge.net> + + * tests/expr.test: Fix problems in new round() + tests that lead to correct result only on 32 + bit long systems. [Bug 1341368] + 2005-10-29 Miguel Sofer <msofer@users.sf.net> * generic/tclCmdMZ.c (TraceVarProc): [Bug 1337229], partial @@ -8,6 +14,18 @@ * tests/trace.test (test-18.3-4): added tests for bugs #1337229 and 1338280. +2005-10-27 Mo DeJong <mdejong@users.sourceforge.net> + + * generic/tclExecute.c (ExprRoundFunc): + Fix typo where number before rounding is + compared with smallest integer instead of + number after rounding. This fix does not + change the results of any tests. + * tests/expr.test: Add round() tests + for cases near the min and max int values. + * tests/util.test: Remove pointless + warning code about testobj command. + 2005-10-23 Miguel Sofer <msofer@users.sf.net> * generic/tclBasic.c: 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 |