1 # Commands covered: none
3 # This file contains a collection of tests for the procedures in the
4 # file tclGet.c. Sourcing this file into Tcl runs the tests and
5 # generates output for errors. No output means no errors were found.
7 # Copyright (c) 1995-1996 Sun Microsystems, Inc.
8 # Copyright (c) 1998-1999 by Scriptics Corporation.
10 # See the file "license.terms" for information on usage and redistribution
11 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
15 if {[lsearch [namespace children] ::tcltest] == -1} {
16 package require tcltest
17 namespace import -force ::tcltest::*
20 test get-1.1 {Tcl_GetInt procedure} {
24 test get-1.2 {Tcl_GetInt procedure} {
28 test get-1.3 {Tcl_GetInt procedure} {
32 test get-1.4 {Tcl_GetInt procedure} {
34 list [catch {incr x foo} msg] $msg
35 } {1 {expected integer but got "foo"}}
36 test get-1.5 {Tcl_GetInt procedure} {
38 list [catch {incr x {16 }} msg] $msg
40 test get-1.6 {Tcl_GetInt procedure} {
42 list [catch {incr x {16 x}} msg] $msg
43 } {1 {expected integer but got "16 x"}}
45 # The following tests are non-portable because they depend on
48 if {wide(0x80000000) > wide(0)} {
49 test get-1.7 {Tcl_GetInt procedure} {
51 list [catch {eval incr x 18446744073709551616} msg] $msg $errorCode
52 } {1 {integer value too large to represent} {ARITH IOVERFLOW {integer value too large to represent}}}
53 test get-1.8 {Tcl_GetInt procedure} {
55 list [catch {incr x 18446744073709551614} msg] $msg
57 test get-1.9 {Tcl_GetInt procedure} {
59 list [catch {incr x +18446744073709551614} msg] $msg
61 test get-1.10 {Tcl_GetInt procedure} {
63 list [catch {incr x -18446744073709551614} msg] $msg
66 test get-1.11 {Tcl_GetInt procedure} {
68 list [catch {incr x 4294967296} msg] $msg $errorCode
69 } {1 {integer value too large to represent} {ARITH IOVERFLOW {integer value too large to represent}}}
70 test get-1.12 {Tcl_GetInt procedure} {
72 list [catch {incr x 4294967294} msg] $msg
74 test get-1.13 {Tcl_GetInt procedure} {
76 list [catch {incr x +4294967294} msg] $msg
78 test get-1.14 {Tcl_GetInt procedure} {
80 list [catch {incr x -4294967294} msg] $msg
84 test get-2.1 {Tcl_GetInt procedure} {
87 test get-2.2 {Tcl_GetInt procedure} {
90 test get-2.3 {Tcl_GetInt procedure} {
91 list [catch {format %g clip} msg] $msg
92 } {1 {expected floating-point number but got "clip"}}
93 test get-2.4 {Tcl_GetInt procedure} {nonPortable} {
94 list [catch {format %g .000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001} msg] $msg $errorCode
95 } {1 {floating-point value too small to represent} {ARITH UNDERFLOW {floating-point value too small to represent}}}
98 ::tcltest::cleanupTests