summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormdejong <mdejong>2005-10-28 03:26:32 (GMT)
committermdejong <mdejong>2005-10-28 03:26:32 (GMT)
commit71b715c88b019bf819a112ac7e8b0aa68c6dc9e8 (patch)
tree931092530cdc8242d3889e664bb9019453dce015
parent337481bde00a01912f25ffeda6d5bd4351057c7d (diff)
downloadtcl-71b715c88b019bf819a112ac7e8b0aa68c6dc9e8.zip
tcl-71b715c88b019bf819a112ac7e8b0aa68c6dc9e8.tar.gz
tcl-71b715c88b019bf819a112ac7e8b0aa68c6dc9e8.tar.bz2
* 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.
-rw-r--r--generic/tclExecute.c4
-rw-r--r--tests/expr.test33
-rw-r--r--tests/util.test9
3 files changed, 35 insertions, 11 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 20f34e6..c238a98 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclExecute.c,v 1.94.2.16 2005/10/23 22:01:29 msofer Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.94.2.17 2005/10/28 03:26:32 mdejong Exp $
*/
#include "tclInt.h"
@@ -5501,7 +5501,7 @@ ExprRoundFunc(interp, eePtr, clientData)
}
if (i <= Tcl_WideAsDouble(LLONG_MIN)) {
goto tooLarge;
- } else if (d <= (double) LONG_MIN) {
+ } else if (i <= (double) LONG_MIN) {
resPtr = Tcl_NewWideIntObj(Tcl_DoubleAsWide(i));
} else {
resPtr = Tcl_NewLongObj((long) i);
diff --git a/tests/expr.test b/tests/expr.test
index 1928a84..6fa2129 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.8 2005/08/29 17:56:22 kennykb Exp $
+# RCS: @(#) $Id: expr.test,v 1.17.2.9 2005/10/28 03:26:32 mdejong Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -899,6 +899,37 @@ 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
+
+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.15 {round() boundary case - becomes wide int} {
+ set imax [expr {((1<<31) + 1) * -1}]
+ expr {round($imax + 0.50)}
+} 2147483648
+
+test expr-46.16 {round() boundary case - smallest int} {
+ set imin [expr {1<<31}]
+ expr {round($imin + 0.51)}
+} -2147483647
+
+test expr-46.17 {round() boundary case - smallest int} {
+ set imin [expr {1<<31}]
+ expr {round($imin + 0.50)}
+} -2147483648
+
+test expr-46.18 {round() boundary case - becomes wide int} {
+ set imin [expr {1<<31}]
+ expr {round($imin - 0.50)}
+} -2147483649
+
+
# cleanup
if {[info exists a]} {
unset a
diff --git a/tests/util.test b/tests/util.test
index c16cd58..b71906d 100644
--- a/tests/util.test
+++ b/tests/util.test
@@ -7,20 +7,13 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: util.test,v 1.10.4.3 2004/11/03 22:12:17 dgp Exp $
+# RCS: @(#) $Id: util.test,v 1.10.4.4 2005/10/28 03:26:33 mdejong Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
namespace import -force ::tcltest::*
}
-if {[info commands testobj] == {}} {
- puts "This application hasn't been compiled with the \"testobj\""
- puts "command, so I can't test the Tcl type and object support."
- ::tcltest::cleanupTests
- return
-}
-
test util-1.1 {TclFindElement procedure - binary element in middle of list} {
lindex {0 foo\x00help 1} 1
} "foo\x00help"