diff options
author | hobbs <hobbs> | 2005-09-29 23:16:29 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2005-09-29 23:16:29 (GMT) |
commit | 33d8a64399b54b08c5bd702183b92c4c9548e156 (patch) | |
tree | efa0c5c468fdb7622cbd1b156b88e24c1700ae46 /tests | |
parent | 3eb8e1f8c787fcdebda1ee637b8d1710cac1c04f (diff) | |
download | tcl-33d8a64399b54b08c5bd702183b92c4c9548e156.zip tcl-33d8a64399b54b08c5bd702183b92c4c9548e156.tar.gz tcl-33d8a64399b54b08c5bd702183b92c4c9548e156.tar.bz2 |
implementation for TIP #255, expr min/max
Diffstat (limited to 'tests')
-rw-r--r-- | tests/expr-old.test | 44 | ||||
-rw-r--r-- | tests/info.test | 6 |
2 files changed, 46 insertions, 4 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} { diff --git a/tests/info.test b/tests/info.test index 9014eee..4cc6e32 100644 --- a/tests/info.test +++ b/tests/info.test @@ -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: info.test,v 1.32 2005/07/29 14:47:47 dkf Exp $ +# RCS: @(#) $Id: info.test,v 1.33 2005/09/29 23:16:29 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -627,9 +627,9 @@ test info-19.6 {info vars: Bug 1072654} -setup { # Check whether the extra testing functions are defined... if {([catch {expr T1()} msg] == 1) && ($msg == {unknown math function "T1"})} { - set functions {abs acos asin atan atan2 bool ceil cos cosh double exp floor fmod hypot int log log10 pow rand round sin sinh sqrt srand tan tanh wide} + set functions {abs acos asin atan atan2 bool ceil cos cosh double exp floor fmod hypot int log log10 max min pow rand round sin sinh sqrt srand tan tanh wide} } else { - set functions {T1 T2 T3 abs acos asin atan atan2 bool ceil cos cosh double exp floor fmod hypot int log log10 pow rand round sin sinh sqrt srand tan tanh wide} + set functions {T1 T2 T3 abs acos asin atan atan2 bool ceil cos cosh double exp floor fmod hypot int log log10 max min pow rand round sin sinh sqrt srand tan tanh wide} } test info-20.1 {info functions option} {info functions sin} sin test info-20.2 {info functions option} {lsort [info functions]} $functions |