sl@0
|
1 |
# This file contains tests for the tclExecute.c source file. Tests appear
|
sl@0
|
2 |
# in the same order as the C code that they test. The set of tests is
|
sl@0
|
3 |
# currently incomplete since it currently includes only new tests for
|
sl@0
|
4 |
# code changed for the addition of Tcl namespaces. Other execution-
|
sl@0
|
5 |
# related tests appear in several other test files including
|
sl@0
|
6 |
# namespace.test, basic.test, eval.test, for.test, etc.
|
sl@0
|
7 |
#
|
sl@0
|
8 |
# Sourcing this file into Tcl runs the tests and generates output for
|
sl@0
|
9 |
# errors. No output means no errors were found.
|
sl@0
|
10 |
#
|
sl@0
|
11 |
# Copyright (c) 1997 Sun Microsystems, Inc.
|
sl@0
|
12 |
# Copyright (c) 1998-1999 by Scriptics Corporation.
|
sl@0
|
13 |
#
|
sl@0
|
14 |
# See the file "license.terms" for information on usage and redistribution
|
sl@0
|
15 |
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
sl@0
|
16 |
#
|
sl@0
|
17 |
# RCS: @(#) $Id: execute.test,v 1.13.2.2 2004/10/28 00:01:07 dgp Exp $
|
sl@0
|
18 |
|
sl@0
|
19 |
if {[lsearch [namespace children] ::tcltest] == -1} {
|
sl@0
|
20 |
package require tcltest 2
|
sl@0
|
21 |
namespace import -force ::tcltest::*
|
sl@0
|
22 |
}
|
sl@0
|
23 |
|
sl@0
|
24 |
catch {eval namespace delete [namespace children :: test_ns_*]}
|
sl@0
|
25 |
catch {rename foo ""}
|
sl@0
|
26 |
catch {unset x}
|
sl@0
|
27 |
catch {unset y}
|
sl@0
|
28 |
catch {unset msg}
|
sl@0
|
29 |
|
sl@0
|
30 |
::tcltest::testConstraint testobj \
|
sl@0
|
31 |
[expr {[info commands testobj] != {} \
|
sl@0
|
32 |
&& [info commands testdoubleobj] != {} \
|
sl@0
|
33 |
&& [info commands teststringobj] != {} \
|
sl@0
|
34 |
&& [info commands testobj] != {}}]
|
sl@0
|
35 |
|
sl@0
|
36 |
::tcltest::testConstraint longIs32bit \
|
sl@0
|
37 |
[expr {int(0x80000000) < 0}]
|
sl@0
|
38 |
|
sl@0
|
39 |
# Tests for the omnibus TclExecuteByteCode function:
|
sl@0
|
40 |
|
sl@0
|
41 |
# INST_DONE not tested
|
sl@0
|
42 |
# INST_PUSH1 not tested
|
sl@0
|
43 |
# INST_PUSH4 not tested
|
sl@0
|
44 |
# INST_POP not tested
|
sl@0
|
45 |
# INST_DUP not tested
|
sl@0
|
46 |
# INST_CONCAT1 not tested
|
sl@0
|
47 |
# INST_INVOKE_STK4 not tested
|
sl@0
|
48 |
# INST_INVOKE_STK1 not tested
|
sl@0
|
49 |
# INST_EVAL_STK not tested
|
sl@0
|
50 |
# INST_EXPR_STK not tested
|
sl@0
|
51 |
|
sl@0
|
52 |
# INST_LOAD_SCALAR1
|
sl@0
|
53 |
|
sl@0
|
54 |
test execute-1.1 {TclExecuteByteCode, INST_LOAD_SCALAR1, small opnd} {
|
sl@0
|
55 |
proc foo {} {
|
sl@0
|
56 |
set x 1
|
sl@0
|
57 |
return $x
|
sl@0
|
58 |
}
|
sl@0
|
59 |
foo
|
sl@0
|
60 |
} 1
|
sl@0
|
61 |
test execute-1.2 {TclExecuteByteCode, INST_LOAD_SCALAR1, large opnd} {
|
sl@0
|
62 |
# Bug: 2243
|
sl@0
|
63 |
set body {}
|
sl@0
|
64 |
for {set i 0} {$i < 129} {incr i} {
|
sl@0
|
65 |
append body "set x$i x\n"
|
sl@0
|
66 |
}
|
sl@0
|
67 |
append body {
|
sl@0
|
68 |
set y 1
|
sl@0
|
69 |
return $y
|
sl@0
|
70 |
}
|
sl@0
|
71 |
|
sl@0
|
72 |
proc foo {} $body
|
sl@0
|
73 |
foo
|
sl@0
|
74 |
} 1
|
sl@0
|
75 |
test execute-1.3 {TclExecuteByteCode, INST_LOAD_SCALAR1, error} {
|
sl@0
|
76 |
proc foo {} {
|
sl@0
|
77 |
set x 1
|
sl@0
|
78 |
unset x
|
sl@0
|
79 |
return $x
|
sl@0
|
80 |
}
|
sl@0
|
81 |
list [catch {foo} msg] $msg
|
sl@0
|
82 |
} {1 {can't read "x": no such variable}}
|
sl@0
|
83 |
|
sl@0
|
84 |
|
sl@0
|
85 |
# INST_LOAD_SCALAR4
|
sl@0
|
86 |
|
sl@0
|
87 |
test execute-2.1 {TclExecuteByteCode, INST_LOAD_SCALAR4, simple case} {
|
sl@0
|
88 |
set body {}
|
sl@0
|
89 |
for {set i 0} {$i < 256} {incr i} {
|
sl@0
|
90 |
append body "set x$i x\n"
|
sl@0
|
91 |
}
|
sl@0
|
92 |
append body {
|
sl@0
|
93 |
set y 1
|
sl@0
|
94 |
return $y
|
sl@0
|
95 |
}
|
sl@0
|
96 |
|
sl@0
|
97 |
proc foo {} $body
|
sl@0
|
98 |
foo
|
sl@0
|
99 |
} 1
|
sl@0
|
100 |
test execute-2.2 {TclExecuteByteCode, INST_LOAD_SCALAR4, error} {
|
sl@0
|
101 |
set body {}
|
sl@0
|
102 |
for {set i 0} {$i < 256} {incr i} {
|
sl@0
|
103 |
append body "set x$i x\n"
|
sl@0
|
104 |
}
|
sl@0
|
105 |
append body {
|
sl@0
|
106 |
set y 1
|
sl@0
|
107 |
unset y
|
sl@0
|
108 |
return $y
|
sl@0
|
109 |
}
|
sl@0
|
110 |
|
sl@0
|
111 |
proc foo {} $body
|
sl@0
|
112 |
list [catch {foo} msg] $msg
|
sl@0
|
113 |
} {1 {can't read "y": no such variable}}
|
sl@0
|
114 |
|
sl@0
|
115 |
|
sl@0
|
116 |
# INST_LOAD_SCALAR_STK not tested
|
sl@0
|
117 |
# INST_LOAD_ARRAY4 not tested
|
sl@0
|
118 |
# INST_LOAD_ARRAY1 not tested
|
sl@0
|
119 |
# INST_LOAD_ARRAY_STK not tested
|
sl@0
|
120 |
# INST_LOAD_STK not tested
|
sl@0
|
121 |
# INST_STORE_SCALAR4 not tested
|
sl@0
|
122 |
# INST_STORE_SCALAR1 not tested
|
sl@0
|
123 |
# INST_STORE_SCALAR_STK not tested
|
sl@0
|
124 |
# INST_STORE_ARRAY4 not tested
|
sl@0
|
125 |
# INST_STORE_ARRAY1 not tested
|
sl@0
|
126 |
# INST_STORE_ARRAY_STK not tested
|
sl@0
|
127 |
# INST_STORE_STK not tested
|
sl@0
|
128 |
# INST_INCR_SCALAR1 not tested
|
sl@0
|
129 |
# INST_INCR_SCALAR_STK not tested
|
sl@0
|
130 |
# INST_INCR_STK not tested
|
sl@0
|
131 |
# INST_INCR_ARRAY1 not tested
|
sl@0
|
132 |
# INST_INCR_ARRAY_STK not tested
|
sl@0
|
133 |
# INST_INCR_SCALAR1_IMM not tested
|
sl@0
|
134 |
# INST_INCR_SCALAR_STK_IMM not tested
|
sl@0
|
135 |
# INST_INCR_STK_IMM not tested
|
sl@0
|
136 |
# INST_INCR_ARRAY1_IMM not tested
|
sl@0
|
137 |
# INST_INCR_ARRAY_STK_IMM not tested
|
sl@0
|
138 |
# INST_JUMP1 not tested
|
sl@0
|
139 |
# INST_JUMP4 not tested
|
sl@0
|
140 |
# INST_JUMP_TRUE4 not tested
|
sl@0
|
141 |
# INST_JUMP_TRUE1 not tested
|
sl@0
|
142 |
# INST_JUMP_FALSE4 not tested
|
sl@0
|
143 |
# INST_JUMP_FALSE1 not tested
|
sl@0
|
144 |
# INST_LOR not tested
|
sl@0
|
145 |
# INST_LAND not tested
|
sl@0
|
146 |
# INST_EQ not tested
|
sl@0
|
147 |
# INST_NEQ not tested
|
sl@0
|
148 |
# INST_LT not tested
|
sl@0
|
149 |
# INST_GT not tested
|
sl@0
|
150 |
# INST_LE not tested
|
sl@0
|
151 |
# INST_GE not tested
|
sl@0
|
152 |
# INST_MOD not tested
|
sl@0
|
153 |
# INST_LSHIFT not tested
|
sl@0
|
154 |
# INST_RSHIFT not tested
|
sl@0
|
155 |
# INST_BITOR not tested
|
sl@0
|
156 |
# INST_BITXOR not tested
|
sl@0
|
157 |
# INST_BITAND not tested
|
sl@0
|
158 |
|
sl@0
|
159 |
# INST_ADD is partially tested:
|
sl@0
|
160 |
test execute-3.1 {TclExecuteByteCode, INST_ADD, op1 is int} {testobj} {
|
sl@0
|
161 |
set x [testintobj set 0 1]
|
sl@0
|
162 |
expr {$x + 1}
|
sl@0
|
163 |
} 2
|
sl@0
|
164 |
test execute-3.2 {TclExecuteByteCode, INST_ADD, op1 is double} {testobj} {
|
sl@0
|
165 |
set x [testdoubleobj set 0 1]
|
sl@0
|
166 |
expr {$x + 1}
|
sl@0
|
167 |
} 2.0
|
sl@0
|
168 |
test execute-3.3 {TclExecuteByteCode, INST_ADD, op1 is double with string} {testobj} {
|
sl@0
|
169 |
set x [testintobj set 0 1]
|
sl@0
|
170 |
testobj convert 0 double
|
sl@0
|
171 |
expr {$x + 1}
|
sl@0
|
172 |
} 2
|
sl@0
|
173 |
test execute-3.4 {TclExecuteByteCode, INST_ADD, op1 is string int} {testobj} {
|
sl@0
|
174 |
set x [teststringobj set 0 1]
|
sl@0
|
175 |
expr {$x + 1}
|
sl@0
|
176 |
} 2
|
sl@0
|
177 |
test execute-3.5 {TclExecuteByteCode, INST_ADD, op1 is string double} {testobj} {
|
sl@0
|
178 |
set x [teststringobj set 0 1.0]
|
sl@0
|
179 |
expr {$x + 1}
|
sl@0
|
180 |
} 2.0
|
sl@0
|
181 |
test execute-3.6 {TclExecuteByteCode, INST_ADD, op1 is non-numeric} {testobj} {
|
sl@0
|
182 |
set x [teststringobj set 0 foo]
|
sl@0
|
183 |
list [catch {expr {$x + 1}} msg] $msg
|
sl@0
|
184 |
} {1 {can't use non-numeric string as operand of "+"}}
|
sl@0
|
185 |
test execute-3.7 {TclExecuteByteCode, INST_ADD, op2 is int} {testobj} {
|
sl@0
|
186 |
set x [testintobj set 0 1]
|
sl@0
|
187 |
expr {1 + $x}
|
sl@0
|
188 |
} 2
|
sl@0
|
189 |
test execute-3.8 {TclExecuteByteCode, INST_ADD, op2 is double} {testobj} {
|
sl@0
|
190 |
set x [testdoubleobj set 0 1]
|
sl@0
|
191 |
expr {1 + $x}
|
sl@0
|
192 |
} 2.0
|
sl@0
|
193 |
test execute-3.9 {TclExecuteByteCode, INST_ADD, op2 is double with string} {testobj} {
|
sl@0
|
194 |
set x [testintobj set 0 1]
|
sl@0
|
195 |
testobj convert 0 double
|
sl@0
|
196 |
expr {1 + $x}
|
sl@0
|
197 |
} 2
|
sl@0
|
198 |
test execute-3.10 {TclExecuteByteCode, INST_ADD, op2 is string int} {testobj} {
|
sl@0
|
199 |
set x [teststringobj set 0 1]
|
sl@0
|
200 |
expr {1 + $x}
|
sl@0
|
201 |
} 2
|
sl@0
|
202 |
test execute-3.11 {TclExecuteByteCode, INST_ADD, op2 is string double} {testobj} {
|
sl@0
|
203 |
set x [teststringobj set 0 1.0]
|
sl@0
|
204 |
expr {1 + $x}
|
sl@0
|
205 |
} 2.0
|
sl@0
|
206 |
test execute-3.12 {TclExecuteByteCode, INST_ADD, op2 is non-numeric} {testobj} {
|
sl@0
|
207 |
set x [teststringobj set 0 foo]
|
sl@0
|
208 |
list [catch {expr {1 + $x}} msg] $msg
|
sl@0
|
209 |
} {1 {can't use non-numeric string as operand of "+"}}
|
sl@0
|
210 |
|
sl@0
|
211 |
# INST_SUB is partially tested:
|
sl@0
|
212 |
test execute-3.13 {TclExecuteByteCode, INST_SUB, op1 is int} {testobj} {
|
sl@0
|
213 |
set x [testintobj set 0 1]
|
sl@0
|
214 |
expr {$x - 1}
|
sl@0
|
215 |
} 0
|
sl@0
|
216 |
test execute-3.14 {TclExecuteByteCode, INST_SUB, op1 is double} {testobj} {
|
sl@0
|
217 |
set x [testdoubleobj set 0 1]
|
sl@0
|
218 |
expr {$x - 1}
|
sl@0
|
219 |
} 0.0
|
sl@0
|
220 |
test execute-3.15 {TclExecuteByteCode, INST_SUB, op1 is double with string} {testobj} {
|
sl@0
|
221 |
set x [testintobj set 0 1]
|
sl@0
|
222 |
testobj convert 0 double
|
sl@0
|
223 |
expr {$x - 1}
|
sl@0
|
224 |
} 0
|
sl@0
|
225 |
test execute-3.16 {TclExecuteByteCode, INST_SUB, op1 is string int} {testobj} {
|
sl@0
|
226 |
set x [teststringobj set 0 1]
|
sl@0
|
227 |
expr {$x - 1}
|
sl@0
|
228 |
} 0
|
sl@0
|
229 |
test execute-3.17 {TclExecuteByteCode, INST_SUB, op1 is string double} {testobj} {
|
sl@0
|
230 |
set x [teststringobj set 0 1.0]
|
sl@0
|
231 |
expr {$x - 1}
|
sl@0
|
232 |
} 0.0
|
sl@0
|
233 |
test execute-3.18 {TclExecuteByteCode, INST_SUB, op1 is non-numeric} {testobj} {
|
sl@0
|
234 |
set x [teststringobj set 0 foo]
|
sl@0
|
235 |
list [catch {expr {$x - 1}} msg] $msg
|
sl@0
|
236 |
} {1 {can't use non-numeric string as operand of "-"}}
|
sl@0
|
237 |
test execute-3.19 {TclExecuteByteCode, INST_SUB, op2 is int} {testobj} {
|
sl@0
|
238 |
set x [testintobj set 0 1]
|
sl@0
|
239 |
expr {1 - $x}
|
sl@0
|
240 |
} 0
|
sl@0
|
241 |
test execute-3.20 {TclExecuteByteCode, INST_SUB, op2 is double} {testobj} {
|
sl@0
|
242 |
set x [testdoubleobj set 0 1]
|
sl@0
|
243 |
expr {1 - $x}
|
sl@0
|
244 |
} 0.0
|
sl@0
|
245 |
test execute-3.21 {TclExecuteByteCode, INST_SUB, op2 is double with string} {testobj} {
|
sl@0
|
246 |
set x [testintobj set 0 1]
|
sl@0
|
247 |
testobj convert 0 double
|
sl@0
|
248 |
expr {1 - $x}
|
sl@0
|
249 |
} 0
|
sl@0
|
250 |
test execute-3.22 {TclExecuteByteCode, INST_SUB, op2 is string int} {testobj} {
|
sl@0
|
251 |
set x [teststringobj set 0 1]
|
sl@0
|
252 |
expr {1 - $x}
|
sl@0
|
253 |
} 0
|
sl@0
|
254 |
test execute-3.23 {TclExecuteByteCode, INST_SUB, op2 is string double} {testobj} {
|
sl@0
|
255 |
set x [teststringobj set 0 1.0]
|
sl@0
|
256 |
expr {1 - $x}
|
sl@0
|
257 |
} 0.0
|
sl@0
|
258 |
test execute-3.24 {TclExecuteByteCode, INST_SUB, op2 is non-numeric} {testobj} {
|
sl@0
|
259 |
set x [teststringobj set 0 foo]
|
sl@0
|
260 |
list [catch {expr {1 - $x}} msg] $msg
|
sl@0
|
261 |
} {1 {can't use non-numeric string as operand of "-"}}
|
sl@0
|
262 |
|
sl@0
|
263 |
# INST_MULT is partially tested:
|
sl@0
|
264 |
test execute-3.25 {TclExecuteByteCode, INST_MULT, op1 is int} {testobj} {
|
sl@0
|
265 |
set x [testintobj set 1 1]
|
sl@0
|
266 |
expr {$x * 1}
|
sl@0
|
267 |
} 1
|
sl@0
|
268 |
test execute-3.26 {TclExecuteByteCode, INST_MULT, op1 is double} {testobj} {
|
sl@0
|
269 |
set x [testdoubleobj set 1 2.0]
|
sl@0
|
270 |
expr {$x * 1}
|
sl@0
|
271 |
} 2.0
|
sl@0
|
272 |
test execute-3.27 {TclExecuteByteCode, INST_MULT, op1 is double with string} {testobj} {
|
sl@0
|
273 |
set x [testintobj set 1 2]
|
sl@0
|
274 |
testobj convert 1 double
|
sl@0
|
275 |
expr {$x * 1}
|
sl@0
|
276 |
} 2
|
sl@0
|
277 |
test execute-3.28 {TclExecuteByteCode, INST_MULT, op1 is string int} {testobj} {
|
sl@0
|
278 |
set x [teststringobj set 1 1]
|
sl@0
|
279 |
expr {$x * 1}
|
sl@0
|
280 |
} 1
|
sl@0
|
281 |
test execute-3.29 {TclExecuteByteCode, INST_MULT, op1 is string double} {testobj} {
|
sl@0
|
282 |
set x [teststringobj set 1 1.0]
|
sl@0
|
283 |
expr {$x * 1}
|
sl@0
|
284 |
} 1.0
|
sl@0
|
285 |
test execute-3.30 {TclExecuteByteCode, INST_MULT, op1 is non-numeric} {testobj} {
|
sl@0
|
286 |
set x [teststringobj set 1 foo]
|
sl@0
|
287 |
list [catch {expr {$x * 1}} msg] $msg
|
sl@0
|
288 |
} {1 {can't use non-numeric string as operand of "*"}}
|
sl@0
|
289 |
test execute-3.31 {TclExecuteByteCode, INST_MULT, op2 is int} {testobj} {
|
sl@0
|
290 |
set x [testintobj set 1 1]
|
sl@0
|
291 |
expr {1 * $x}
|
sl@0
|
292 |
} 1
|
sl@0
|
293 |
test execute-3.32 {TclExecuteByteCode, INST_MULT, op2 is double} {testobj} {
|
sl@0
|
294 |
set x [testdoubleobj set 1 2.0]
|
sl@0
|
295 |
expr {1 * $x}
|
sl@0
|
296 |
} 2.0
|
sl@0
|
297 |
test execute-3.33 {TclExecuteByteCode, INST_MULT, op2 is double with string} {testobj} {
|
sl@0
|
298 |
set x [testintobj set 1 2]
|
sl@0
|
299 |
testobj convert 1 double
|
sl@0
|
300 |
expr {1 * $x}
|
sl@0
|
301 |
} 2
|
sl@0
|
302 |
test execute-3.34 {TclExecuteByteCode, INST_MULT, op2 is string int} {testobj} {
|
sl@0
|
303 |
set x [teststringobj set 1 1]
|
sl@0
|
304 |
expr {1 * $x}
|
sl@0
|
305 |
} 1
|
sl@0
|
306 |
test execute-3.35 {TclExecuteByteCode, INST_MULT, op2 is string double} {testobj} {
|
sl@0
|
307 |
set x [teststringobj set 1 1.0]
|
sl@0
|
308 |
expr {1 * $x}
|
sl@0
|
309 |
} 1.0
|
sl@0
|
310 |
test execute-3.36 {TclExecuteByteCode, INST_MULT, op2 is non-numeric} {testobj} {
|
sl@0
|
311 |
set x [teststringobj set 1 foo]
|
sl@0
|
312 |
list [catch {expr {1 * $x}} msg] $msg
|
sl@0
|
313 |
} {1 {can't use non-numeric string as operand of "*"}}
|
sl@0
|
314 |
|
sl@0
|
315 |
# INST_DIV is partially tested:
|
sl@0
|
316 |
test execute-3.37 {TclExecuteByteCode, INST_DIV, op1 is int} {testobj} {
|
sl@0
|
317 |
set x [testintobj set 1 1]
|
sl@0
|
318 |
expr {$x / 1}
|
sl@0
|
319 |
} 1
|
sl@0
|
320 |
test execute-3.38 {TclExecuteByteCode, INST_DIV, op1 is double} {testobj} {
|
sl@0
|
321 |
set x [testdoubleobj set 1 2.0]
|
sl@0
|
322 |
expr {$x / 1}
|
sl@0
|
323 |
} 2.0
|
sl@0
|
324 |
test execute-3.39 {TclExecuteByteCode, INST_DIV, op1 is double with string} {testobj} {
|
sl@0
|
325 |
set x [testintobj set 1 2]
|
sl@0
|
326 |
testobj convert 1 double
|
sl@0
|
327 |
expr {$x / 1}
|
sl@0
|
328 |
} 2
|
sl@0
|
329 |
test execute-3.40 {TclExecuteByteCode, INST_DIV, op1 is string int} {testobj} {
|
sl@0
|
330 |
set x [teststringobj set 1 1]
|
sl@0
|
331 |
expr {$x / 1}
|
sl@0
|
332 |
} 1
|
sl@0
|
333 |
test execute-3.41 {TclExecuteByteCode, INST_DIV, op1 is string double} {testobj} {
|
sl@0
|
334 |
set x [teststringobj set 1 1.0]
|
sl@0
|
335 |
expr {$x / 1}
|
sl@0
|
336 |
} 1.0
|
sl@0
|
337 |
test execute-3.42 {TclExecuteByteCode, INST_DIV, op1 is non-numeric} {testobj} {
|
sl@0
|
338 |
set x [teststringobj set 1 foo]
|
sl@0
|
339 |
list [catch {expr {$x / 1}} msg] $msg
|
sl@0
|
340 |
} {1 {can't use non-numeric string as operand of "/"}}
|
sl@0
|
341 |
test execute-3.43 {TclExecuteByteCode, INST_DIV, op2 is int} {testobj} {
|
sl@0
|
342 |
set x [testintobj set 1 1]
|
sl@0
|
343 |
expr {2 / $x}
|
sl@0
|
344 |
} 2
|
sl@0
|
345 |
test execute-3.44 {TclExecuteByteCode, INST_DIV, op2 is double} {testobj} {
|
sl@0
|
346 |
set x [testdoubleobj set 1 1.0]
|
sl@0
|
347 |
expr {2 / $x}
|
sl@0
|
348 |
} 2.0
|
sl@0
|
349 |
test execute-3.45 {TclExecuteByteCode, INST_DIV, op2 is double with string} {testobj} {
|
sl@0
|
350 |
set x [testintobj set 1 1]
|
sl@0
|
351 |
testobj convert 1 double
|
sl@0
|
352 |
expr {2 / $x}
|
sl@0
|
353 |
} 2
|
sl@0
|
354 |
test execute-3.46 {TclExecuteByteCode, INST_DIV, op2 is string int} {testobj} {
|
sl@0
|
355 |
set x [teststringobj set 1 1]
|
sl@0
|
356 |
expr {2 / $x}
|
sl@0
|
357 |
} 2
|
sl@0
|
358 |
test execute-3.47 {TclExecuteByteCode, INST_DIV, op2 is string double} {testobj} {
|
sl@0
|
359 |
set x [teststringobj set 1 1.0]
|
sl@0
|
360 |
expr {2 / $x}
|
sl@0
|
361 |
} 2.0
|
sl@0
|
362 |
test execute-3.48 {TclExecuteByteCode, INST_DIV, op2 is non-numeric} {testobj} {
|
sl@0
|
363 |
set x [teststringobj set 1 foo]
|
sl@0
|
364 |
list [catch {expr {1 / $x}} msg] $msg
|
sl@0
|
365 |
} {1 {can't use non-numeric string as operand of "/"}}
|
sl@0
|
366 |
|
sl@0
|
367 |
# INST_UPLUS is partially tested:
|
sl@0
|
368 |
test execute-3.49 {TclExecuteByteCode, INST_UPLUS, op is int} {testobj} {
|
sl@0
|
369 |
set x [testintobj set 1 1]
|
sl@0
|
370 |
expr {+ $x}
|
sl@0
|
371 |
} 1
|
sl@0
|
372 |
test execute-3.50 {TclExecuteByteCode, INST_UPLUS, op is double} {testobj} {
|
sl@0
|
373 |
set x [testdoubleobj set 1 1.0]
|
sl@0
|
374 |
expr {+ $x}
|
sl@0
|
375 |
} 1.0
|
sl@0
|
376 |
test execute-3.51 {TclExecuteByteCode, INST_UPLUS, op is double with string} {testobj} {
|
sl@0
|
377 |
set x [testintobj set 1 1]
|
sl@0
|
378 |
testobj convert 1 double
|
sl@0
|
379 |
expr {+ $x}
|
sl@0
|
380 |
} 1
|
sl@0
|
381 |
test execute-3.52 {TclExecuteByteCode, INST_UPLUS, op is string int} {testobj} {
|
sl@0
|
382 |
set x [teststringobj set 1 1]
|
sl@0
|
383 |
expr {+ $x}
|
sl@0
|
384 |
} 1
|
sl@0
|
385 |
test execute-3.53 {TclExecuteByteCode, INST_UPLUS, op is string double} {testobj} {
|
sl@0
|
386 |
set x [teststringobj set 1 1.0]
|
sl@0
|
387 |
expr {+ $x}
|
sl@0
|
388 |
} 1.0
|
sl@0
|
389 |
test execute-3.54 {TclExecuteByteCode, INST_UPLUS, op is non-numeric} {testobj} {
|
sl@0
|
390 |
set x [teststringobj set 1 foo]
|
sl@0
|
391 |
list [catch {expr {+ $x}} msg] $msg
|
sl@0
|
392 |
} {1 {can't use non-numeric string as operand of "+"}}
|
sl@0
|
393 |
|
sl@0
|
394 |
# INST_UMINUS is partially tested:
|
sl@0
|
395 |
test execute-3.55 {TclExecuteByteCode, INST_UMINUS, op is int} {testobj} {
|
sl@0
|
396 |
set x [testintobj set 1 1]
|
sl@0
|
397 |
expr {- $x}
|
sl@0
|
398 |
} -1
|
sl@0
|
399 |
test execute-3.56 {TclExecuteByteCode, INST_UMINUS, op is double} {testobj} {
|
sl@0
|
400 |
set x [testdoubleobj set 1 1.0]
|
sl@0
|
401 |
expr {- $x}
|
sl@0
|
402 |
} -1.0
|
sl@0
|
403 |
test execute-3.57 {TclExecuteByteCode, INST_UMINUS, op is double with string} {testobj} {
|
sl@0
|
404 |
set x [testintobj set 1 1]
|
sl@0
|
405 |
testobj convert 1 double
|
sl@0
|
406 |
expr {- $x}
|
sl@0
|
407 |
} -1
|
sl@0
|
408 |
test execute-3.58 {TclExecuteByteCode, INST_UMINUS, op is string int} {testobj} {
|
sl@0
|
409 |
set x [teststringobj set 1 1]
|
sl@0
|
410 |
expr {- $x}
|
sl@0
|
411 |
} -1
|
sl@0
|
412 |
test execute-3.59 {TclExecuteByteCode, INST_UMINUS, op is string double} {testobj} {
|
sl@0
|
413 |
set x [teststringobj set 1 1.0]
|
sl@0
|
414 |
expr {- $x}
|
sl@0
|
415 |
} -1.0
|
sl@0
|
416 |
test execute-3.60 {TclExecuteByteCode, INST_UMINUS, op is non-numeric} {testobj} {
|
sl@0
|
417 |
set x [teststringobj set 1 foo]
|
sl@0
|
418 |
list [catch {expr {- $x}} msg] $msg
|
sl@0
|
419 |
} {1 {can't use non-numeric string as operand of "-"}}
|
sl@0
|
420 |
|
sl@0
|
421 |
# INST_LNOT is partially tested:
|
sl@0
|
422 |
test execute-3.61 {TclExecuteByteCode, INST_LNOT, op is int} {testobj} {
|
sl@0
|
423 |
set x [testintobj set 1 2]
|
sl@0
|
424 |
expr {! $x}
|
sl@0
|
425 |
} 0
|
sl@0
|
426 |
test execute-3.62 {TclExecuteByteCode, INST_LNOT, op is int} {testobj} {
|
sl@0
|
427 |
set x [testintobj set 1 0]
|
sl@0
|
428 |
expr {! $x}
|
sl@0
|
429 |
} 1
|
sl@0
|
430 |
test execute-3.63 {TclExecuteByteCode, INST_LNOT, op is double} {testobj} {
|
sl@0
|
431 |
set x [testdoubleobj set 1 1.0]
|
sl@0
|
432 |
expr {! $x}
|
sl@0
|
433 |
} 0
|
sl@0
|
434 |
test execute-3.64 {TclExecuteByteCode, INST_LNOT, op is double} {testobj} {
|
sl@0
|
435 |
set x [testdoubleobj set 1 0.0]
|
sl@0
|
436 |
expr {! $x}
|
sl@0
|
437 |
} 1
|
sl@0
|
438 |
test execute-3.65 {TclExecuteByteCode, INST_LNOT, op is double with string} {testobj} {
|
sl@0
|
439 |
set x [testintobj set 1 1]
|
sl@0
|
440 |
testobj convert 1 double
|
sl@0
|
441 |
expr {! $x}
|
sl@0
|
442 |
} 0
|
sl@0
|
443 |
test execute-3.66 {TclExecuteByteCode, INST_LNOT, op is double with string} {testobj} {
|
sl@0
|
444 |
set x [testintobj set 1 0]
|
sl@0
|
445 |
testobj convert 1 double
|
sl@0
|
446 |
expr {! $x}
|
sl@0
|
447 |
} 1
|
sl@0
|
448 |
test execute-3.67 {TclExecuteByteCode, INST_LNOT, op is string int} {testobj} {
|
sl@0
|
449 |
set x [teststringobj set 1 1]
|
sl@0
|
450 |
expr {! $x}
|
sl@0
|
451 |
} 0
|
sl@0
|
452 |
test execute-3.68 {TclExecuteByteCode, INST_LNOT, op is string int} {testobj} {
|
sl@0
|
453 |
set x [teststringobj set 1 0]
|
sl@0
|
454 |
expr {! $x}
|
sl@0
|
455 |
} 1
|
sl@0
|
456 |
test execute-3.69 {TclExecuteByteCode, INST_LNOT, op is string double} {testobj} {
|
sl@0
|
457 |
set x [teststringobj set 1 1.0]
|
sl@0
|
458 |
expr {! $x}
|
sl@0
|
459 |
} 0
|
sl@0
|
460 |
test execute-3.70 {TclExecuteByteCode, INST_LNOT, op is string double} {testobj} {
|
sl@0
|
461 |
set x [teststringobj set 1 0.0]
|
sl@0
|
462 |
expr {! $x}
|
sl@0
|
463 |
} 1
|
sl@0
|
464 |
test execute-3.71 {TclExecuteByteCode, INST_LNOT, op is non-numeric} {testobj} {
|
sl@0
|
465 |
set x [teststringobj set 1 foo]
|
sl@0
|
466 |
list [catch {expr {! $x}} msg] $msg
|
sl@0
|
467 |
} {1 {can't use non-numeric string as operand of "!"}}
|
sl@0
|
468 |
|
sl@0
|
469 |
# INST_BITNOT not tested
|
sl@0
|
470 |
# INST_CALL_BUILTIN_FUNC1 not tested
|
sl@0
|
471 |
# INST_CALL_FUNC1 not tested
|
sl@0
|
472 |
|
sl@0
|
473 |
# INST_TRY_CVT_TO_NUMERIC is partially tested:
|
sl@0
|
474 |
test execute-3.72 {TclExecuteByteCode, INST_TRY_CVT_TO_NUMERIC, op is int} {testobj} {
|
sl@0
|
475 |
set x [testintobj set 1 1]
|
sl@0
|
476 |
expr {$x}
|
sl@0
|
477 |
} 1
|
sl@0
|
478 |
test execute-3.73 {TclExecuteByteCode, INST_TRY_CVT_TO_NUMERIC, op is double} {testobj} {
|
sl@0
|
479 |
set x [testdoubleobj set 1 1.0]
|
sl@0
|
480 |
expr {$x}
|
sl@0
|
481 |
} 1.0
|
sl@0
|
482 |
test execute-3.74 {TclExecuteByteCode, INST_TRY_CVT_TO_NUMERIC, op is double with string} {testobj} {
|
sl@0
|
483 |
set x [testintobj set 1 1]
|
sl@0
|
484 |
testobj convert 1 double
|
sl@0
|
485 |
expr {$x}
|
sl@0
|
486 |
} 1
|
sl@0
|
487 |
test execute-3.75 {TclExecuteByteCode, INST_TRY_CVT_TO_NUMERIC, op is string int} {testobj} {
|
sl@0
|
488 |
set x [teststringobj set 1 1]
|
sl@0
|
489 |
expr {$x}
|
sl@0
|
490 |
} 1
|
sl@0
|
491 |
test execute-3.76 {TclExecuteByteCode, INST_TRY_CVT_TO_NUMERIC, op is string double} {testobj} {
|
sl@0
|
492 |
set x [teststringobj set 1 1.0]
|
sl@0
|
493 |
expr {$x}
|
sl@0
|
494 |
} 1.0
|
sl@0
|
495 |
test execute-3.77 {TclExecuteByteCode, INST_TRY_CVT_TO_NUMERIC, op is non-numeric} {testobj} {
|
sl@0
|
496 |
set x [teststringobj set 1 foo]
|
sl@0
|
497 |
expr {$x}
|
sl@0
|
498 |
} foo
|
sl@0
|
499 |
|
sl@0
|
500 |
# INST_BREAK not tested
|
sl@0
|
501 |
# INST_CONTINUE not tested
|
sl@0
|
502 |
# INST_FOREACH_START4 not tested
|
sl@0
|
503 |
# INST_FOREACH_STEP4 not tested
|
sl@0
|
504 |
# INST_BEGIN_CATCH4 not tested
|
sl@0
|
505 |
# INST_END_CATCH not tested
|
sl@0
|
506 |
# INST_PUSH_RESULT not tested
|
sl@0
|
507 |
# INST_PUSH_RETURN_CODE not tested
|
sl@0
|
508 |
|
sl@0
|
509 |
test execute-4.1 {Tcl_GetCommandFromObj, convert to tclCmdNameType} {
|
sl@0
|
510 |
catch {eval namespace delete [namespace children :: test_ns_*]}
|
sl@0
|
511 |
catch {unset x}
|
sl@0
|
512 |
catch {unset y}
|
sl@0
|
513 |
namespace eval test_ns_1 {
|
sl@0
|
514 |
namespace export cmd1
|
sl@0
|
515 |
proc cmd1 {args} {return "cmd1: $args"}
|
sl@0
|
516 |
proc cmd2 {args} {return "cmd2: $args"}
|
sl@0
|
517 |
}
|
sl@0
|
518 |
namespace eval test_ns_1::test_ns_2 {
|
sl@0
|
519 |
namespace import ::test_ns_1::*
|
sl@0
|
520 |
}
|
sl@0
|
521 |
set x "test_ns_1::"
|
sl@0
|
522 |
set y "test_ns_2::"
|
sl@0
|
523 |
list [namespace which -command ${x}${y}cmd1] \
|
sl@0
|
524 |
[catch {namespace which -command ${x}${y}cmd2} msg] $msg \
|
sl@0
|
525 |
[catch {namespace which -command ${x}${y}:cmd2} msg] $msg
|
sl@0
|
526 |
} {::test_ns_1::test_ns_2::cmd1 0 {} 0 {}}
|
sl@0
|
527 |
test execute-4.2 {Tcl_GetCommandFromObj, check if cached tclCmdNameType is invalid} {
|
sl@0
|
528 |
catch {eval namespace delete [namespace children :: test_ns_*]}
|
sl@0
|
529 |
catch {rename foo ""}
|
sl@0
|
530 |
catch {unset l}
|
sl@0
|
531 |
proc foo {} {
|
sl@0
|
532 |
return "global foo"
|
sl@0
|
533 |
}
|
sl@0
|
534 |
namespace eval test_ns_1 {
|
sl@0
|
535 |
proc whichFoo {} {
|
sl@0
|
536 |
return [namespace which -command foo]
|
sl@0
|
537 |
}
|
sl@0
|
538 |
}
|
sl@0
|
539 |
set l ""
|
sl@0
|
540 |
lappend l [test_ns_1::whichFoo]
|
sl@0
|
541 |
namespace eval test_ns_1 {
|
sl@0
|
542 |
proc foo {} {
|
sl@0
|
543 |
return "namespace foo"
|
sl@0
|
544 |
}
|
sl@0
|
545 |
}
|
sl@0
|
546 |
lappend l [test_ns_1::whichFoo]
|
sl@0
|
547 |
set l
|
sl@0
|
548 |
} {::foo ::test_ns_1::foo}
|
sl@0
|
549 |
test execute-4.3 {Tcl_GetCommandFromObj, command never found} {
|
sl@0
|
550 |
catch {eval namespace delete [namespace children :: test_ns_*]}
|
sl@0
|
551 |
catch {rename foo ""}
|
sl@0
|
552 |
namespace eval test_ns_1 {
|
sl@0
|
553 |
proc foo {} {
|
sl@0
|
554 |
return "namespace foo"
|
sl@0
|
555 |
}
|
sl@0
|
556 |
}
|
sl@0
|
557 |
namespace eval test_ns_1 {
|
sl@0
|
558 |
proc foo {} {
|
sl@0
|
559 |
return "namespace foo"
|
sl@0
|
560 |
}
|
sl@0
|
561 |
}
|
sl@0
|
562 |
list [namespace eval test_ns_1 {namespace which -command foo}] \
|
sl@0
|
563 |
[rename test_ns_1::foo ""] \
|
sl@0
|
564 |
[catch {namespace eval test_ns_1 {namespace which -command foo}} msg] $msg
|
sl@0
|
565 |
} {::test_ns_1::foo {} 0 {}}
|
sl@0
|
566 |
|
sl@0
|
567 |
test execute-5.1 {SetCmdNameFromAny, set cmd name to empty heap string if NULL} {
|
sl@0
|
568 |
catch {eval namespace delete [namespace children :: test_ns_*]}
|
sl@0
|
569 |
catch {unset l}
|
sl@0
|
570 |
proc {} {} {return {}}
|
sl@0
|
571 |
{}
|
sl@0
|
572 |
set l {}
|
sl@0
|
573 |
lindex {} 0
|
sl@0
|
574 |
{}
|
sl@0
|
575 |
} {}
|
sl@0
|
576 |
|
sl@0
|
577 |
test execute-6.1 {UpdateStringOfCmdName: called for duplicate of empty cmdName object} {
|
sl@0
|
578 |
proc {} {} {}
|
sl@0
|
579 |
proc { } {} {}
|
sl@0
|
580 |
proc p {} {
|
sl@0
|
581 |
set x {}
|
sl@0
|
582 |
$x
|
sl@0
|
583 |
append x { }
|
sl@0
|
584 |
$x
|
sl@0
|
585 |
}
|
sl@0
|
586 |
p
|
sl@0
|
587 |
} {}
|
sl@0
|
588 |
|
sl@0
|
589 |
test execute-6.2 {Evaluate an expression in a variable; compile the first time, do not the second} {
|
sl@0
|
590 |
set w {3*5}
|
sl@0
|
591 |
proc a {obj} {expr $obj}
|
sl@0
|
592 |
set res "[a $w]:[a $w]"
|
sl@0
|
593 |
} {15:15}
|
sl@0
|
594 |
|
sl@0
|
595 |
test execute-7.0 {Wide int handling in INST_JUMP_FALSE/LAND} {longIs32bit} {
|
sl@0
|
596 |
set x 0x100000000
|
sl@0
|
597 |
expr {$x && 1}
|
sl@0
|
598 |
} 1
|
sl@0
|
599 |
test execute-7.1 {Wide int handling in INST_JUMP_FALSE/LAND} {longIs32bit} {
|
sl@0
|
600 |
expr {0x100000000 && 1}
|
sl@0
|
601 |
} 1
|
sl@0
|
602 |
test execute-7.2 {Wide int handling in INST_JUMP_FALSE/LAND} {longIs32bit} {
|
sl@0
|
603 |
expr {1 && 0x100000000}
|
sl@0
|
604 |
} 1
|
sl@0
|
605 |
test execute-7.3 {Wide int handling in INST_JUMP_FALSE/LAND} {longIs32bit} {
|
sl@0
|
606 |
expr {wide(0x100000000) && 1}
|
sl@0
|
607 |
} 1
|
sl@0
|
608 |
test execute-7.4 {Wide int handling in INST_JUMP_FALSE/LAND} {longIs32bit} {
|
sl@0
|
609 |
expr {1 && wide(0x100000000)}
|
sl@0
|
610 |
} 1
|
sl@0
|
611 |
test execute-7.5 {Wide int handling in INST_EQ} {longIs32bit} {
|
sl@0
|
612 |
expr {4 == (wide(1)+wide(3))}
|
sl@0
|
613 |
} 1
|
sl@0
|
614 |
test execute-7.6 {Wide int handling in INST_EQ and [incr]} {longIs32bit} {
|
sl@0
|
615 |
set x 399999999999
|
sl@0
|
616 |
expr {400000000000 == [incr x]}
|
sl@0
|
617 |
} 1
|
sl@0
|
618 |
# wide ints have more bits of precision than doubles, but we convert anyway
|
sl@0
|
619 |
test execute-7.7 {Wide int handling in INST_EQ and [incr]} {longIs32bit} {
|
sl@0
|
620 |
set x [expr {wide(1)<<62}]
|
sl@0
|
621 |
set y [expr {$x+1}]
|
sl@0
|
622 |
expr {double($x) == double($y)}
|
sl@0
|
623 |
} 1
|
sl@0
|
624 |
test execute-7.8 {Wide int conversions can change sign} {longIs32bit} {
|
sl@0
|
625 |
set x 0x80000000
|
sl@0
|
626 |
expr {int($x) < wide($x)}
|
sl@0
|
627 |
} 1
|
sl@0
|
628 |
test execute-7.9 {Wide int handling in INST_MOD} {longIs32bit} {
|
sl@0
|
629 |
expr {(wide(1)<<60) % ((wide(47)<<45)-1)}
|
sl@0
|
630 |
} 316659348800185
|
sl@0
|
631 |
test execute-7.10 {Wide int handling in INST_MOD} {longIs32bit} {
|
sl@0
|
632 |
expr {((wide(1)<<60)-1) % 0x400000000}
|
sl@0
|
633 |
} 17179869183
|
sl@0
|
634 |
test execute-7.11 {Wide int handling in INST_LSHIFT} {longIs32bit} {
|
sl@0
|
635 |
expr wide(42)<<30
|
sl@0
|
636 |
} 45097156608
|
sl@0
|
637 |
test execute-7.12 {Wide int handling in INST_LSHIFT} {longIs32bit} {
|
sl@0
|
638 |
expr 12345678901<<3
|
sl@0
|
639 |
} 98765431208
|
sl@0
|
640 |
test execute-7.13 {Wide int handling in INST_RSHIFT} {longIs32bit} {
|
sl@0
|
641 |
expr 0x543210febcda9876>>7
|
sl@0
|
642 |
} 47397893236700464
|
sl@0
|
643 |
test execute-7.14 {Wide int handling in INST_RSHIFT} {longIs32bit} {
|
sl@0
|
644 |
expr 0x9876543210febcda>>7
|
sl@0
|
645 |
} -58286587177206407
|
sl@0
|
646 |
test execute-7.15 {Wide int handling in INST_BITOR} {longIs32bit} {
|
sl@0
|
647 |
expr 0x9876543210febcda | 0x543210febcda9876
|
sl@0
|
648 |
} -2560765885044310786
|
sl@0
|
649 |
test execute-7.16 {Wide int handling in INST_BITXOR} {longIs32bit} {
|
sl@0
|
650 |
expr 0x9876543210febcda ^ 0x543210febcda9876
|
sl@0
|
651 |
} -3727778945703861076
|
sl@0
|
652 |
test execute-7.17 {Wide int handling in INST_BITAND} {longIs32bit} {
|
sl@0
|
653 |
expr 0x9876543210febcda & 0x543210febcda9876
|
sl@0
|
654 |
} 1167013060659550290
|
sl@0
|
655 |
test execute-7.18 {Wide int handling in INST_ADD} {longIs32bit} {
|
sl@0
|
656 |
expr wide(0x7fffffff)+wide(0x7fffffff)
|
sl@0
|
657 |
} 4294967294
|
sl@0
|
658 |
test execute-7.19 {Wide int handling in INST_ADD} {longIs32bit} {
|
sl@0
|
659 |
expr 0x7fffffff+wide(0x7fffffff)
|
sl@0
|
660 |
} 4294967294
|
sl@0
|
661 |
test execute-7.20 {Wide int handling in INST_ADD} {longIs32bit} {
|
sl@0
|
662 |
expr wide(0x7fffffff)+0x7fffffff
|
sl@0
|
663 |
} 4294967294
|
sl@0
|
664 |
test execute-7.21 {Wide int handling in INST_ADD} {longIs32bit} {
|
sl@0
|
665 |
expr double(0x7fffffff)+wide(0x7fffffff)
|
sl@0
|
666 |
} 4294967294.0
|
sl@0
|
667 |
test execute-7.22 {Wide int handling in INST_ADD} {longIs32bit} {
|
sl@0
|
668 |
expr wide(0x7fffffff)+double(0x7fffffff)
|
sl@0
|
669 |
} 4294967294.0
|
sl@0
|
670 |
test execute-7.23 {Wide int handling in INST_SUB} {longIs32bit} {
|
sl@0
|
671 |
expr 0x123456789a-0x20406080a
|
sl@0
|
672 |
} 69530054800
|
sl@0
|
673 |
test execute-7.24 {Wide int handling in INST_MULT} {longIs32bit} {
|
sl@0
|
674 |
expr 0x123456789a*193
|
sl@0
|
675 |
} 15090186251290
|
sl@0
|
676 |
test execute-7.25 {Wide int handling in INST_DIV} {longIs32bit} {
|
sl@0
|
677 |
expr 0x123456789a/193
|
sl@0
|
678 |
} 405116546
|
sl@0
|
679 |
test execute-7.26 {Wide int handling in INST_UPLUS} {longIs32bit} {
|
sl@0
|
680 |
set x 0x123456871234568
|
sl@0
|
681 |
expr {+ $x}
|
sl@0
|
682 |
} 81985533099853160
|
sl@0
|
683 |
test execute-7.27 {Wide int handling in INST_UMINUS} {longIs32bit} {
|
sl@0
|
684 |
set x 0x123456871234568
|
sl@0
|
685 |
expr {- $x}
|
sl@0
|
686 |
} -81985533099853160
|
sl@0
|
687 |
test execute-7.28 {Wide int handling in INST_LNOT} {longIs32bit} {
|
sl@0
|
688 |
set x 0x123456871234568
|
sl@0
|
689 |
expr {! $x}
|
sl@0
|
690 |
} 0
|
sl@0
|
691 |
test execute-7.29 {Wide int handling in INST_BITNOT} {longIs32bit} {
|
sl@0
|
692 |
set x 0x123456871234568
|
sl@0
|
693 |
expr {~ $x}
|
sl@0
|
694 |
} -81985533099853161
|
sl@0
|
695 |
test execute-7.30 {Wide int handling in function call} {longIs32bit} {
|
sl@0
|
696 |
set x 0x12345687123456
|
sl@0
|
697 |
incr x
|
sl@0
|
698 |
expr {log($x) == log(double($x))}
|
sl@0
|
699 |
} 1
|
sl@0
|
700 |
test execute-7.31 {Wide int handling in abs()} {longIs32bit} {
|
sl@0
|
701 |
set x 0xa23456871234568
|
sl@0
|
702 |
incr x
|
sl@0
|
703 |
set y 0x123456871234568
|
sl@0
|
704 |
concat [expr {abs($x)}] [expr {abs($y)}]
|
sl@0
|
705 |
} {730503879441204585 81985533099853160}
|
sl@0
|
706 |
test execute-7.32 {Wide int handling} {longIs32bit} {
|
sl@0
|
707 |
expr {1024 * 1024 * 1024 * 1024}
|
sl@0
|
708 |
} 0
|
sl@0
|
709 |
test execute-7.33 {Wide int handling} {longIs32bit} {
|
sl@0
|
710 |
expr {0x1 * 1024 * 1024 * 1024 * 1024}
|
sl@0
|
711 |
} 0
|
sl@0
|
712 |
test execute-7.34 {Wide int handling} {longIs32bit} {
|
sl@0
|
713 |
expr {wide(0x1) * 1024 * 1024 * 1024 * 1024}
|
sl@0
|
714 |
} 1099511627776
|
sl@0
|
715 |
|
sl@0
|
716 |
test execute-8.1 {Stack protection} -setup {
|
sl@0
|
717 |
# If [Bug #804681] has not been properly
|
sl@0
|
718 |
# taken care of, this should segfault
|
sl@0
|
719 |
proc whatever args {llength $args}
|
sl@0
|
720 |
trace add variable ::errorInfo {write unset} whatever
|
sl@0
|
721 |
} -body {
|
sl@0
|
722 |
expr {1+9/0}
|
sl@0
|
723 |
} -cleanup {
|
sl@0
|
724 |
trace remove variable ::errorInfo {write unset} whatever
|
sl@0
|
725 |
rename whatever {}
|
sl@0
|
726 |
} -returnCodes error -match glob -result *
|
sl@0
|
727 |
|
sl@0
|
728 |
# cleanup
|
sl@0
|
729 |
if {[info commands testobj] != {}} {
|
sl@0
|
730 |
testobj freeallvars
|
sl@0
|
731 |
}
|
sl@0
|
732 |
catch {eval namespace delete [namespace children :: test_ns_*]}
|
sl@0
|
733 |
catch {rename foo ""}
|
sl@0
|
734 |
catch {rename p ""}
|
sl@0
|
735 |
catch {rename {} ""}
|
sl@0
|
736 |
catch {rename { } ""}
|
sl@0
|
737 |
catch {unset x}
|
sl@0
|
738 |
catch {unset y}
|
sl@0
|
739 |
catch {unset msg}
|
sl@0
|
740 |
::tcltest::cleanupTests
|
sl@0
|
741 |
return
|