OSDN Git Service

Updated to tcl 8.4.1
[pf3gnuchains/sourceware.git] / tcl / tests / get.test
1 # 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 # Copyright (c) 1998-1999 by Scriptics Corporation.
9 #
10 # See the file "license.terms" for information on usage and redistribution
11 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12 #
13 # RCS: @(#) $Id$
14
15 if {[lsearch [namespace children] ::tcltest] == -1} {
16     package require tcltest
17     namespace import -force ::tcltest::*
18 }
19
20 test get-1.1 {Tcl_GetInt procedure} {
21     set x 44
22     incr x {      22}
23 } {66}
24 test get-1.2 {Tcl_GetInt procedure} {
25     set x 44
26     incr x -3
27 } {41}
28 test get-1.3 {Tcl_GetInt procedure} {
29     set x 44
30     incr x +8
31 } {52}
32 test get-1.4 {Tcl_GetInt procedure} {
33     set x 44
34     list [catch {incr x foo} msg] $msg
35 } {1 {expected integer but got "foo"}}
36 test get-1.5 {Tcl_GetInt procedure} {
37     set x 44
38     list [catch {incr x {16      }} msg] $msg
39 } {0 60}
40 test get-1.6 {Tcl_GetInt procedure} {
41     set x 44
42     list [catch {incr x {16      x}} msg] $msg
43 } {1 {expected integer but got "16       x"}}
44
45 # The following tests are non-portable because they depend on
46 # word size.
47
48 if {wide(0x80000000) > wide(0)} {
49     test get-1.7 {Tcl_GetInt procedure} {
50         set x 44
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} {
54         set x 0
55         list [catch {incr x 18446744073709551614} msg] $msg
56     } {0 -2}
57     test get-1.9 {Tcl_GetInt procedure} {
58         set x 0
59         list [catch {incr x +18446744073709551614} msg] $msg
60     } {0 -2}
61     test get-1.10 {Tcl_GetInt procedure} {
62         set x 0
63         list [catch {incr x -18446744073709551614} msg] $msg
64     } {0 2}
65 } else {
66     test get-1.11 {Tcl_GetInt procedure} {
67         set x 44
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} {
71         set x 0
72         list [catch {incr x 4294967294} msg] $msg
73     } {0 -2}
74     test get-1.13 {Tcl_GetInt procedure} {
75         set x 0
76         list [catch {incr x +4294967294} msg] $msg
77     } {0 -2}
78     test get-1.14 {Tcl_GetInt procedure} {
79         set x 0
80         list [catch {incr x -4294967294} msg] $msg
81     } {0 2}
82 }
83
84 test get-2.1 {Tcl_GetInt procedure} {
85     format %g 1.23
86 } {1.23}
87 test get-2.2 {Tcl_GetInt procedure} {
88     format %g {          1.23   }
89 } {1.23}
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}}}
96
97 # cleanup
98 ::tcltest::cleanupTests
99 return
100
101
102
103
104
105
106
107
108
109
110
111