1 |
578 |
markom |
# Commands covered: none
|
2 |
|
|
#
|
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.
|
6 |
|
|
#
|
7 |
|
|
# Copyright (c) 1995-1996 Sun Microsystems, Inc.
|
8 |
|
|
#
|
9 |
|
|
# See the file "license.terms" for information on usage and redistribution
|
10 |
|
|
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
11 |
|
|
#
|
12 |
|
|
# RCS: @(#) $Id: get.test,v 1.1.1.1 2002-01-16 10:25:36 markom Exp $
|
13 |
|
|
|
14 |
|
|
if {[string compare test [info procs test]] == 1} then {source defs}
|
15 |
|
|
|
16 |
|
|
test get-1.1 {Tcl_GetInt procedure} {
|
17 |
|
|
set x 44
|
18 |
|
|
incr x { 22}
|
19 |
|
|
} {66}
|
20 |
|
|
test get-1.2 {Tcl_GetInt procedure} {
|
21 |
|
|
set x 44
|
22 |
|
|
incr x -3
|
23 |
|
|
} {41}
|
24 |
|
|
test get-1.3 {Tcl_GetInt procedure} {
|
25 |
|
|
set x 44
|
26 |
|
|
incr x +8
|
27 |
|
|
} {52}
|
28 |
|
|
test get-1.4 {Tcl_GetInt procedure} {
|
29 |
|
|
set x 44
|
30 |
|
|
list [catch {incr x foo} msg] $msg
|
31 |
|
|
} {1 {expected integer but got "foo"}}
|
32 |
|
|
test get-1.5 {Tcl_GetInt procedure} {
|
33 |
|
|
set x 44
|
34 |
|
|
list [catch {incr x {16 }} msg] $msg
|
35 |
|
|
} {0 60}
|
36 |
|
|
test get-1.6 {Tcl_GetInt procedure} {
|
37 |
|
|
set x 44
|
38 |
|
|
list [catch {incr x {16 x}} msg] $msg
|
39 |
|
|
} {1 {expected integer but got "16 x"}}
|
40 |
|
|
|
41 |
|
|
# The following tests are non-portable because they depend on
|
42 |
|
|
# word size. 18446744073709551614
|
43 |
|
|
|
44 |
|
|
if {0x80000000 > 0} {
|
45 |
|
|
test get-1.7 {Tcl_GetInt procedure} {nonPortable unixOnly} {
|
46 |
|
|
set x 44
|
47 |
|
|
list [catch {incr x 18446744073709551616} msg] $msg $errorCode
|
48 |
|
|
} {1 {integer value too large to represent} {ARITH IOVERFLOW {integer value too large to represent}}}
|
49 |
|
|
test get-1.8 {Tcl_GetInt procedure} {nonPortable} {
|
50 |
|
|
set x 0
|
51 |
|
|
list [catch {incr x 18446744073709551614} msg] $msg
|
52 |
|
|
} {0 -2}
|
53 |
|
|
test get-1.9 {Tcl_GetInt procedure} {nonPortable} {
|
54 |
|
|
set x 0
|
55 |
|
|
list [catch {incr x +18446744073709551614} msg] $msg
|
56 |
|
|
} {0 -2}
|
57 |
|
|
test get-1.10 {Tcl_GetInt procedure} {nonPortable} {
|
58 |
|
|
set x 0
|
59 |
|
|
list [catch {incr x -18446744073709551614} msg] $msg
|
60 |
|
|
} {0 2}
|
61 |
|
|
} else {
|
62 |
|
|
test get-1.7 {Tcl_GetInt procedure} {nonPortable unixOnly} {
|
63 |
|
|
set x 44
|
64 |
|
|
list [catch {incr x 4294967296} msg] $msg $errorCode
|
65 |
|
|
} {1 {integer value too large to represent} {ARITH IOVERFLOW {integer value too large to represent}}}
|
66 |
|
|
test get-1.8 {Tcl_GetInt procedure} {nonPortable} {
|
67 |
|
|
set x 0
|
68 |
|
|
list [catch {incr x 4294967294} msg] $msg
|
69 |
|
|
} {0 -2}
|
70 |
|
|
test get-1.9 {Tcl_GetInt procedure} {nonPortable} {
|
71 |
|
|
set x 0
|
72 |
|
|
list [catch {incr x +4294967294} msg] $msg
|
73 |
|
|
} {0 -2}
|
74 |
|
|
test get-1.10 {Tcl_GetInt procedure} {nonPortable} {
|
75 |
|
|
set x 0
|
76 |
|
|
list [catch {incr x -4294967294} msg] $msg
|
77 |
|
|
} {0 2}
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
test get-2.1 {Tcl_GetInt procedure} {
|
81 |
|
|
format %g 1.23
|
82 |
|
|
} {1.23}
|
83 |
|
|
test get-2.2 {Tcl_GetInt procedure} {
|
84 |
|
|
format %g { 1.23 }
|
85 |
|
|
} {1.23}
|
86 |
|
|
test get-2.3 {Tcl_GetInt procedure} {
|
87 |
|
|
list [catch {format %g clip} msg] $msg
|
88 |
|
|
} {1 {expected floating-point number but got "clip"}}
|
89 |
|
|
test get-2.4 {Tcl_GetInt procedure} {nonPortable} {
|
90 |
|
|
list [catch {format %g .000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001} msg] $msg $errorCode
|
91 |
|
|
} {1 {floating-point value too small to represent} {ARITH UNDERFLOW {floating-point value too small to represent}}}
|