summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2006-12-08 16:14:16 (GMT)
committerdgp <dgp@users.sourceforge.net>2006-12-08 16:14:16 (GMT)
commit075c0449ce2a01114dcd419a912889ce694a35cc (patch)
tree1abc67af24d394346125a19bcecd987fc4698765
parenta8eab3914ae049d11796aae78540064f3a277dbf (diff)
downloadtcl-075c0449ce2a01114dcd419a912889ce694a35cc.zip
tcl-075c0449ce2a01114dcd419a912889ce694a35cc.tar.gz
tcl-075c0449ce2a01114dcd419a912889ce694a35cc.tar.bz2
* generic/tclMathOp.c: More revisions to make tests pass.
* tests/mathop.test:
-rw-r--r--ChangeLog5
-rw-r--r--generic/tclMathOp.c17
-rw-r--r--tests/mathop.test14
3 files changed, 26 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 9320406..82b90bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-12-08 Don Porter <dgp@users.sourceforge.net>
+
+ * generic/tclMathOp.c: More revisions to make tests pass.
+ * tests/mathop.test:
+
2006-12-08 Donal K. Fellows <donal.k.fellows@manchester.ac.uk>
* generic/tclNamesp.c (TclTeardownNamespace): Ensure that dying
diff --git a/generic/tclMathOp.c b/generic/tclMathOp.c
index ed28123..f4a5b53 100644
--- a/generic/tclMathOp.c
+++ b/generic/tclMathOp.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclMathOp.c,v 1.4 2006/12/07 23:35:30 dgp Exp $
+ * RCS: @(#) $Id: tclMathOp.c,v 1.5 2006/12/08 16:14:17 dgp Exp $
*/
#include "tclInt.h"
@@ -1062,7 +1062,9 @@ TclInvertOpCmd(
Tcl_WrongNumArgs(interp, 1, objv, "number");
return TCL_ERROR;
}
- if (TclGetNumberFromObj(interp, objv[1], &val, &type) != TCL_OK) {
+ if (TclGetNumberFromObj(NULL, objv[1], &val, &type) != TCL_OK) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "can't use non-numeric string as operand of \"~\"", -1));
return TCL_ERROR;
}
switch (type) {
@@ -1137,7 +1139,16 @@ TclNotOpCmd(
Tcl_WrongNumArgs(interp, 1, objv, "boolean");
return TCL_ERROR;
}
- if (Tcl_GetBooleanFromObj(interp, objv[1], &b) != TCL_OK) {
+ if (Tcl_GetBooleanFromObj(NULL, objv[1], &b) != TCL_OK) {
+ int type;
+ ClientData val;
+ if (TclGetNumberFromObj(NULL, objv[1], &val, &type) == TCL_OK) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "can't use non-numeric floating-point value as operand of \"!\"", -1));
+ } else {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "can't use non-numeric string as operand of \"!\"", -1));
+ }
return TCL_ERROR;
}
Tcl_SetBooleanObj(Tcl_GetObjResult(interp), !b);
diff --git a/tests/mathop.test b/tests/mathop.test
index 66c7221..477120d 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.5 2006/12/08 10:59:45 dkf Exp $
+# RCS: @(#) $Id: mathop.test,v 1.6 2006/12/08 16:14:18 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2.1
@@ -263,7 +263,7 @@ namespace eval ::testmathop {
test mathop-3.7 {compiled !} {! 10000000000000000000000000} 0
test mathop-3.8 {compiled !: errors} -body {
! foobar
- } -returnCodes error -result {expected boolean value but got "foobar"}
+ } -returnCodes error -result {can't use non-numeric string as operand of "!"}
test mathop-3.9 {compiled !: errors} -body {
! 0 0
} -returnCodes error -result "wrong # args: should be \"! boolean\""
@@ -280,7 +280,7 @@ namespace eval ::testmathop {
test mathop-3.17 {interpreted !} {$op 10000000000000000000000000} 0
test mathop-3.18 {interpreted !: errors} -body {
$op foobar
- } -returnCodes error -result {expected boolean value but got "foobar"}
+ } -returnCodes error -result {can't use non-numeric string as operand of "!"}
test mathop-3.19 {interpreted !: errors} -body {
$op 0 0
} -returnCodes error -result "wrong # args: should be \"! boolean\""
@@ -289,10 +289,10 @@ namespace eval ::testmathop {
} -returnCodes error -result "wrong # args: should be \"! boolean\""
test mathop-3.21 {compiled !: error} -returnCodes error -body {
! NaN
- } -result {floating point value is Not a Number}
+ } -result {can't use non-numeric floating-point value as operand of "!"}
test mathop-3.22 {interpreted !: error} -returnCodes error -body {
$op NaN
- } -result {floating point value is Not a Number}
+ } -result {can't use non-numeric floating-point value as operand of "!"}
test mathop-4.1 {compiled ~} {~ 0} -1
test mathop-4.2 {compiled ~} {~ 1} -2
@@ -303,7 +303,7 @@ namespace eval ::testmathop {
test mathop-4.7 {compiled ~} {~ 10000000000000000000000000} -10000000000000000000000001
test mathop-4.8 {compiled ~: errors} -body {
~ foobar
- } -returnCodes error -result {expected number but got "foobar"}
+ } -returnCodes error -result {can't use non-numeric string as operand of "~"}
test mathop-4.9 {compiled ~: errors} -body {
~ 0 0
} -returnCodes error -result "wrong # args: should be \"~ number\""
@@ -326,7 +326,7 @@ namespace eval ::testmathop {
test mathop-4.19 {interpreted ~} {$op 10000000000000000000000000} -10000000000000000000000001
test mathop-4.20 {interpreted ~: errors} -body {
$op foobar
- } -returnCodes error -result {expected number but got "foobar"}
+ } -returnCodes error -result {can't use non-numeric string as operand of "~"}
test mathop-4.21 {interpreted ~: errors} -body {
$op 0 0
} -returnCodes error -result "wrong # args: should be \"~ number\""