summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2010-07-02 20:37:10 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2010-07-02 20:37:10 (GMT)
commitb1f2ce2cad5a74808cb19c4ab54a21c303329e51 (patch)
tree7de386a2d1c618c06d1c93c384ed4a9b18641473
parent56e0284e56164f3fbc02ab3b0621d24edf17c7a9 (diff)
downloadtcl-b1f2ce2cad5a74808cb19c4ab54a21c303329e51.zip
tcl-b1f2ce2cad5a74808cb19c4ab54a21c303329e51.tar.gz
tcl-b1f2ce2cad5a74808cb19c4ab54a21c303329e51.tar.bz2
* generic/tclExecute.c (IllegalExprOperandType): [Bug 3024379]: Made
sure that errors caused by an argument to an operator being outside the domain of the operator all result in ::errorCode being ARITH DOMAIN and not NONE.
-rw-r--r--ChangeLog7
-rw-r--r--generic/tclExecute.c3
-rw-r--r--tests/mathop.test36
3 files changed, 30 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index d845e2b..1f7d4aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-07-02 Donal K. Fellows <dkf@users.sf.net>
+
+ * generic/tclExecute.c (IllegalExprOperandType): [Bug 3024379]: Made
+ sure that errors caused by an argument to an operator being outside
+ the domain of the operator all result in ::errorCode being ARITH
+ DOMAIN and not NONE.
+
2010-07-01 Jan Nijtmans <nijtmans@users.sf.net>
* win/rules.vc: [Bug 3020677]: wish can't link reg1.2
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index a738065..95e036b 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -14,7 +14,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.486 2010/06/07 21:24:59 ferrieux Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.487 2010/07/02 20:37:10 dkf Exp $
*/
#include "tclInt.h"
@@ -8191,6 +8191,7 @@ IllegalExprOperandType(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't use %s as operand of \"%s\"", description, operator));
+ Tcl_SetErrorCode(interp, "ARITH", "DOMAIN", description, NULL);
}
/*
diff --git a/tests/mathop.test b/tests/mathop.test
index 3ec37fc..b7c4a04 100644
--- a/tests/mathop.test
+++ b/tests/mathop.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: mathop.test,v 1.13 2009/01/08 16:41:35 dkf Exp $
+# RCS: @(#) $Id: mathop.test,v 1.14 2010/07/02 20:37:10 dkf Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2.1
@@ -777,9 +777,15 @@ test mathop-20.6 { one arg, error } {
# skipping - for now, knownbug...
foreach op {+ * / & | ^ **} {
lappend res [TestOp $op {*}$vals]
- lappend exp "can't use non-numeric string as operand of \"$op\" NONE"
+ lappend exp "can't use non-numeric string as operand of \"$op\"\
+ ARITH DOMAIN {non-numeric string}"
}
}
+ foreach op {+ * / & | ^ **} {
+ lappend res [TestOp $op NaN 1]
+ lappend exp "can't use non-numeric floating-point value as operand of \"$op\"\
+ ARITH DOMAIN {non-numeric floating-point value}"
+ }
expr {$res eq $exp ? 0 : $res}
} 0
test mathop-20.7 { multi arg } {
@@ -846,15 +852,15 @@ test mathop-21.5 { unary ops, bad values } {
set res {}
set exp {}
lappend res [TestOp / x]
- lappend exp "can't use non-numeric string as operand of \"/\" NONE"
+ lappend exp "can't use non-numeric string as operand of \"/\" ARITH DOMAIN {non-numeric string}"
lappend res [TestOp - x]
- lappend exp "can't use non-numeric string as operand of \"-\" NONE"
+ lappend exp "can't use non-numeric string as operand of \"-\" ARITH DOMAIN {non-numeric string}"
lappend res [TestOp ~ x]
- lappend exp "can't use non-numeric string as operand of \"~\" NONE"
+ lappend exp "can't use non-numeric string as operand of \"~\" ARITH DOMAIN {non-numeric string}"
lappend res [TestOp ! x]
- lappend exp "can't use non-numeric string as operand of \"!\" NONE"
+ lappend exp "can't use non-numeric string as operand of \"!\" ARITH DOMAIN {non-numeric string}"
lappend res [TestOp ~ 5.0]
- lappend exp "can't use floating-point value as operand of \"~\" NONE"
+ lappend exp "can't use floating-point value as operand of \"~\" ARITH DOMAIN {floating-point value}"
expr {$res eq $exp ? 0 : $res}
} 0
test mathop-21.6 { unary ops, too many } {
@@ -961,9 +967,9 @@ test mathop-22.4 { unary ops, bad values } {
set exp {}
foreach op {& | ^} {
lappend res [TestOp $op x 5]
- lappend exp "can't use non-numeric string as operand of \"$op\" NONE"
+ lappend exp "can't use non-numeric string as operand of \"$op\" ARITH DOMAIN {non-numeric string}"
lappend res [TestOp $op 5 x]
- lappend exp "can't use non-numeric string as operand of \"$op\" NONE"
+ lappend exp "can't use non-numeric string as operand of \"$op\" ARITH DOMAIN {non-numeric string}"
}
expr {$res eq $exp ? 0 : $res}
} 0
@@ -1076,15 +1082,15 @@ test mathop-24.3 { binary ops, bad values } {
set exp {}
foreach op {% << >>} {
lappend res [TestOp $op x 1]
- lappend exp "can't use non-numeric string as operand of \"$op\" NONE"
+ lappend exp "can't use non-numeric string as operand of \"$op\" ARITH DOMAIN {non-numeric string}"
lappend res [TestOp $op 1 x]
- lappend exp "can't use non-numeric string as operand of \"$op\" NONE"
+ lappend exp "can't use non-numeric string as operand of \"$op\" ARITH DOMAIN {non-numeric string}"
}
foreach op {% << >>} {
lappend res [TestOp $op 5.0 1]
- lappend exp "can't use floating-point value as operand of \"$op\" NONE"
+ lappend exp "can't use floating-point value as operand of \"$op\" ARITH DOMAIN {floating-point value}"
lappend res [TestOp $op 1 5.0]
- lappend exp "can't use floating-point value as operand of \"$op\" NONE"
+ lappend exp "can't use floating-point value as operand of \"$op\" ARITH DOMAIN {floating-point value}"
}
foreach op {in ni} {
lappend res [TestOp $op 5 "a b \{ c"]
@@ -1236,9 +1242,9 @@ test mathop-25.23 { exp operator errors } {
lappend res [TestOp ** $huge 2.1]
lappend exp "Inf"
lappend res [TestOp ** 2 foo]
- lappend exp "can't use non-numeric string as operand of \"**\" NONE"
+ lappend exp "can't use non-numeric string as operand of \"**\" ARITH DOMAIN {non-numeric string}"
lappend res [TestOp ** foo 2]
- lappend exp "can't use non-numeric string as operand of \"**\" NONE"
+ lappend exp "can't use non-numeric string as operand of \"**\" ARITH DOMAIN {non-numeric string}"
expr {$res eq $exp ? 0 : $res}
} 0