summaryrefslogtreecommitdiffstats
path: root/tests/get.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/get.test')
-rw-r--r--tests/get.test115
1 files changed, 43 insertions, 72 deletions
diff --git a/tests/get.test b/tests/get.test
index d35c19b..40ec98f 100644
--- a/tests/get.test
+++ b/tests/get.test
@@ -15,69 +15,52 @@ if {[lsearch [namespace children] ::tcltest] == -1} {
namespace import -force ::tcltest::*
}
-test get-1.1 {Tcl_GetInt procedure} {
- set x 44
- incr x { 22}
+testConstraint testgetint [llength [info commands testgetint]]
+testConstraint longIs32bit [expr {int(0x80000000) < 0}]
+testConstraint longIs64bit [expr {int(0x8000000000000000) < 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 longIs64bit} {
+ 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 longIs64bit} {
+ list [catch {testgetint 18446744073709551614} msg] $msg
+} {0 -2}
+test get-1.9 {Tcl_GetInt procedure} {testgetint longIs64bit} {
+ list [catch {testgetint +18446744073709551614} msg] $msg
+} {0 -2}
+test get-1.10 {Tcl_GetInt procedure} {testgetint longIs64bit} {
+ list [catch {testgetint -18446744073709551614} msg] $msg
+} {0 2}
+test get-1.11 {Tcl_GetInt procedure} {testgetint longIs32bit} {
+ 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 longIs32bit} {
+ list [catch {testgetint 4294967294} msg] $msg
+} {0 -2}
+test get-1.13 {Tcl_GetInt procedure} {testgetint longIs32bit} {
+ list [catch {testgetint +4294967294} msg] $msg
+} {0 -2}
+test get-1.14 {Tcl_GetInt procedure} {testgetint longIs32bit} {
+ list [catch {testgetint -4294967294} msg] $msg
+} {0 2}
test get-2.1 {Tcl_GetInt procedure} {
format %g 1.23
@@ -88,9 +71,9 @@ test get-2.2 {Tcl_GetInt procedure} {
test get-2.3 {Tcl_GetInt procedure} {
list [catch {format %g clip} msg] $msg
} {1 {expected floating-point number but got "clip"}}
-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-2.4 {Tcl_GetInt procedure} {
+ format %g .000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
+} 0
test get-3.1 {Tcl_GetInt(FromObj), bad numbers} {
# SF bug #634856
@@ -113,15 +96,3 @@ test get-3.2 {Tcl_GetDouble(FromObj), bad numbers} {
# cleanup
::tcltest::cleanupTests
return
-
-
-
-
-
-
-
-
-
-
-
-