diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/get.test | 20 | ||||
-rw-r--r-- | tests/string.test | 20 |
2 files changed, 38 insertions, 2 deletions
diff --git a/tests/get.test b/tests/get.test index 0d9bea8..4c3f679 100644 --- a/tests/get.test +++ b/tests/get.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: get.test,v 1.7 2002/02/15 23:42:12 kennykb Exp $ +# RCS: @(#) $Id: get.test,v 1.8 2002/11/19 02:34:50 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -94,6 +94,24 @@ test get-2.4 {Tcl_GetInt procedure} {nonPortable} { list [catch {format %g .000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001} msg] $msg $errorCode } {1 {floating-point value too small to represent} {ARITH UNDERFLOW {floating-point value too small to represent}}} +test get-3.1 {Tcl_GetInt(FromObj), bad numbers} { + # SF bug #634856 + set result "" + set numbers [list 1 +1 ++1 +-1 -+1 -1 --1 "- +1" "+12345678987654321" "++12345678987654321"] + foreach num $numbers { + lappend result [catch {format %ld $num} msg] $msg + } + set result +} {0 1 0 1 1 {expected integer but got "++1"} 1 {expected integer but got "+-1"} 1 {expected integer but got "-+1"} 0 -1 1 {expected integer but got "--1"} 1 {expected integer but got "- +1"} 0 12345678987654321 1 {expected integer but got "++12345678987654321"}} +test get-3.2 {Tcl_GetDouble(FromObj), bad numbers} { + set result "" + set numbers [list 1.0 +1.0 ++1.0 +-1.0 -+1.0 -1.0 --1.0 "- +1.0"] + foreach num $numbers { + lappend result [catch {format %g $num} msg] $msg + } + set result +} {0 1 0 1 1 {expected floating-point number but got "++1.0"} 1 {expected floating-point number but got "+-1.0"} 1 {expected floating-point number but got "-+1.0"} 0 -1 1 {expected floating-point number but got "--1.0"} 1 {expected floating-point number but got "- +1.0"}} + # cleanup ::tcltest::cleanupTests return diff --git a/tests/string.test b/tests/string.test index d2bdb6d..bffb623 100644 --- a/tests/string.test +++ b/tests/string.test @@ -12,7 +12,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: string.test,v 1.34 2002/05/29 09:09:00 hobbs Exp $ +# RCS: @(#) $Id: string.test,v 1.35 2002/11/19 02:34:50 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -574,6 +574,24 @@ test string-6.89 {string is xdigit} { list [string is xdigit -fail var 0123456789\u0061bcdefABCDEFg] $var } {0 22} +test string-6.90 {string is integer, bad integers} { + # SF bug #634856 + set result "" + set numbers [list 1 +1 ++1 +-1 -+1 -1 --1 "- +1"] + foreach num $numbers { + lappend result [string is int -strict $num] + } + set result +} {1 1 0 0 0 1 0 0} +test string-6.91 {string is double, bad doubles} { + set result "" + set numbers [list 1.0 +1.0 ++1.0 +-1.0 -+1.0 -1.0 --1.0 "- +1.0"] + foreach num $numbers { + lappend result [string is double -strict $num] + } + set result +} {1 1 0 0 0 1 0 0} + catch {rename largest_int {}} test string-7.1 {string last, too few args} { |