summaryrefslogtreecommitdiffstats
path: root/tests/expr-old.test
diff options
context:
space:
mode:
authorhobbs <hobbs>2005-09-29 23:16:29 (GMT)
committerhobbs <hobbs>2005-09-29 23:16:29 (GMT)
commit33d8a64399b54b08c5bd702183b92c4c9548e156 (patch)
treeefa0c5c468fdb7622cbd1b156b88e24c1700ae46 /tests/expr-old.test
parent3eb8e1f8c787fcdebda1ee637b8d1710cac1c04f (diff)
downloadtcl-33d8a64399b54b08c5bd702183b92c4c9548e156.zip
tcl-33d8a64399b54b08c5bd702183b92c4c9548e156.tar.gz
tcl-33d8a64399b54b08c5bd702183b92c4c9548e156.tar.bz2
implementation for TIP #255, expr min/max
Diffstat (limited to 'tests/expr-old.test')
-rw-r--r--tests/expr-old.test44
1 files changed, 43 insertions, 1 deletions
diff --git a/tests/expr-old.test b/tests/expr-old.test
index 1817e9a..bb5a4fd 100644
--- a/tests/expr-old.test
+++ b/tests/expr-old.test
@@ -13,7 +13,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-old.test,v 1.26 2005/07/28 18:42:28 dgp Exp $
+# RCS: @(#) $Id: expr-old.test,v 1.27 2005/09/29 23:16:29 hobbs Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2.1
@@ -1055,6 +1055,48 @@ test expr-old-39.1 {Rounding with wide result} {
} {1 1}
unset -nocomplain x y
+#
+# TIP #255 min and max math functions
+#
+
+test expr-old-40.1 {min math function} -body {
+ expr {min(0)}
+} -result 0
+test expr-old-40.2 {min math function} -body {
+ expr {min(0.0)}
+} -result 0.0
+test expr-old-40.3 {min math function} -body {
+ list [catch {expr {min()}} msg] $msg
+} -result {1 {too few arguments to math function "min"}}
+test expr-old-40.4 {min math function} -body {
+ expr {min(wide(-1) << 30, 4.5, -10)}
+} -result [expr {wide(-1) << 30}]
+test expr-old-40.5 {min math function} -body {
+ list [catch {expr {min("a", 0)}} msg] $msg
+} -result {1 {argument to math function didn't have numeric value}}
+test expr-old-40.6 {min math function} -body {
+ expr {min(300, "0xFF")}
+} -result 255
+
+test expr-old-41.1 {max math function} -body {
+ expr {max(0)}
+} -result 0
+test expr-old-41.2 {max math function} -body {
+ expr {max(0.0)}
+} -result 0.0
+test expr-old-41.3 {max math function} -body {
+ list [catch {expr {max()}} msg] $msg
+} -result {1 {too few arguments to math function "max"}}
+test expr-old-41.4 {max math function} -body {
+ expr {max(wide(1) << 30, 4.5, -10)}
+} -result [expr {wide(1) << 30}]
+test expr-old-41.5 {max math function} -body {
+ list [catch {expr {max("a", 0)}} msg] $msg
+} -result {1 {argument to math function didn't have numeric value}}
+test expr-old-41.6 {max math function} -body {
+ expr {max(200, "0xFF")}
+} -result 255
+
# Special test for Pentium arithmetic bug of 1994:
if {(4195835.0 - (4195835.0/3145727.0)*3145727.0) == 256.0} {