summaryrefslogtreecommitdiffstats
path: root/tests/get.test
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-05-19 10:38:23 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-05-19 10:38:23 (GMT)
commite2fad6a3fa1a1911c5c3014b6d9206aadcd7bf7e (patch)
treeb036f8e5aab29934ba73f924fc0591df69bb193f /tests/get.test
parent4a48fddf76997f4e8db2a639205e385eecf837d1 (diff)
downloadtcl-e2fad6a3fa1a1911c5c3014b6d9206aadcd7bf7e.zip
tcl-e2fad6a3fa1a1911c5c3014b6d9206aadcd7bf7e.tar.gz
tcl-e2fad6a3fa1a1911c5c3014b6d9206aadcd7bf7e.tar.bz2
Fixed get.test so it really tests Tcl_GetInt() and uses constraints properly.
Diffstat (limited to 'tests/get.test')
-rw-r--r--tests/get.test110
1 files changed, 40 insertions, 70 deletions
diff --git a/tests/get.test b/tests/get.test
index 4c3f679..a04e131 100644
--- a/tests/get.test
+++ b/tests/get.test
@@ -10,76 +10,58 @@
# 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.8 2002/11/19 02:34:50 hobbs Exp $
+# RCS: @(#) $Id: get.test,v 1.9 2004/05/19 10:38:24 dkf Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
namespace import -force ::tcltest::*
}
-test get-1.1 {Tcl_GetInt procedure} {
- set x 44
- incr x { 22}
+testConstraint testgetint [llength [info commands testgetint]]
+testConstraint intsAre64bit [expr {int(0x80000000) > 0}]
+
+test get-1.1 {Tcl_GetInt procedure} testgetint {
+ testgetint 44 { 22}
} {66}
-test get-1.2 {Tcl_GetInt procedure} {
- set x 44
- incr x -3
+test get-1.2 {Tcl_GetInt procedure} testgetint {
+ testgetint 44 -3
} {41}
-test get-1.3 {Tcl_GetInt procedure} {
- set x 44
- incr x +8
+test get-1.3 {Tcl_GetInt procedure} testgetint {
+ testgetint 44 +8
} {52}
-test get-1.4 {Tcl_GetInt procedure} {
- set x 44
- list [catch {incr x foo} msg] $msg
+test get-1.4 {Tcl_GetInt procedure} testgetint {
+ list [catch {testgetint 44 foo} msg] $msg
} {1 {expected integer but got "foo"}}
-test get-1.5 {Tcl_GetInt procedure} {
- set x 44
- list [catch {incr x {16 }} msg] $msg
+test get-1.5 {Tcl_GetInt procedure} testgetint {
+ list [catch {testgetint 44 {16 }} msg] $msg
} {0 60}
-test get-1.6 {Tcl_GetInt procedure} {
- set x 44
- list [catch {incr x {16 x}} msg] $msg
+test get-1.6 {Tcl_GetInt procedure} testgetint {
+ list [catch {testgetint 44 {16 x}} msg] $msg
} {1 {expected integer but got "16 x"}}
-
-# The following tests are non-portable because they depend on
-# word size.
-
-if {wide(0x80000000) > wide(0)} {
- test get-1.7 {Tcl_GetInt procedure} {
- set x 44
- list [catch {eval incr x 18446744073709551616} msg] $msg $errorCode
- } {1 {integer value too large to represent} {ARITH IOVERFLOW {integer value too large to represent}}}
- test get-1.8 {Tcl_GetInt procedure} {
- set x 0
- list [catch {incr x 18446744073709551614} msg] $msg
- } {0 -2}
- test get-1.9 {Tcl_GetInt procedure} {
- set x 0
- list [catch {incr x +18446744073709551614} msg] $msg
- } {0 -2}
- test get-1.10 {Tcl_GetInt procedure} {
- set x 0
- list [catch {incr x -18446744073709551614} msg] $msg
- } {0 2}
-} else {
- test get-1.11 {Tcl_GetInt procedure} {
- set x 44
- list [catch {incr x 4294967296} msg] $msg $errorCode
- } {1 {integer value too large to represent} {ARITH IOVERFLOW {integer value too large to represent}}}
- test get-1.12 {Tcl_GetInt procedure} {
- set x 0
- list [catch {incr x 4294967294} msg] $msg
- } {0 -2}
- test get-1.13 {Tcl_GetInt procedure} {
- set x 0
- list [catch {incr x +4294967294} msg] $msg
- } {0 -2}
- test get-1.14 {Tcl_GetInt procedure} {
- set x 0
- list [catch {incr x -4294967294} msg] $msg
- } {0 2}
-}
+test get-1.7 {Tcl_GetInt procedure} {testgetint intsAre64bit} {
+ list [catch {testgetint 44 18446744073709551616} msg] $msg $errorCode
+} {1 {integer value too large to represent} {ARITH IOVERFLOW {integer value too large to represent}}}
+test get-1.8 {Tcl_GetInt procedure} {testgetint intsAre64bit} {
+ list [catch {testgetint 18446744073709551614} msg] $msg
+} {0 -2}
+test get-1.9 {Tcl_GetInt procedure} {testgetint intsAre64bit} {
+ list [catch {testgetint +18446744073709551614} msg] $msg
+} {0 -2}
+test get-1.10 {Tcl_GetInt procedure} {testgetint intsAre64bit} {
+ list [catch {testgetint -18446744073709551614} msg] $msg
+} {0 2}
+test get-1.11 {Tcl_GetInt procedure} {testgetint && !intsAre64bit} {
+ list [catch {testgetint 44 4294967296} msg] $msg $errorCode
+} {1 {integer value too large to represent} {ARITH IOVERFLOW {integer value too large to represent}}}
+test get-1.12 {Tcl_GetInt procedure} {testgetint && !intsAre64bit} {
+ list [catch {testgetint 4294967294} msg] $msg
+} {0 -2}
+test get-1.13 {Tcl_GetInt procedure} {testgetint && !intsAre64bit} {
+ list [catch {testgetint +4294967294} msg] $msg
+} {0 -2}
+test get-1.14 {Tcl_GetInt procedure} {testgetint && !intsAre64bit} {
+ list [catch {testgetint -4294967294} msg] $msg
+} {0 2}
test get-2.1 {Tcl_GetInt procedure} {
format %g 1.23
@@ -115,15 +97,3 @@ test get-3.2 {Tcl_GetDouble(FromObj), bad numbers} {
# cleanup
::tcltest::cleanupTests
return
-
-
-
-
-
-
-
-
-
-
-
-