Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/tests/obj.test @ 31

Last change on this file since 31 was 25, checked in by landauf, 17 years ago

added tcl to libs

File size: 23.6 KB
Line 
1# Functionality covered: this file contains a collection of tests for the
2# procedures in tclObj.c that implement Tcl's basic type support and the
3# type managers for the types boolean, double, and integer.
4#
5# Sourcing this file into Tcl runs the tests and generates output for
6# errors. No output means no errors were found.
7#
8# Copyright (c) 1995-1996 Sun Microsystems, Inc.
9# Copyright (c) 1998-1999 by Scriptics Corporation.
10#
11# See the file "license.terms" for information on usage and redistribution
12# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13#
14# RCS: @(#) $Id: obj.test,v 1.21 2007/12/13 15:26:07 dgp Exp $
15
16if {[lsearch [namespace children] ::tcltest] == -1} {
17    package require tcltest
18    namespace import -force ::tcltest::*
19}
20
21testConstraint testobj [llength [info commands testobj]]
22testConstraint longIs32bit      [expr {int(0x80000000) < 0}]
23testConstraint wideBiggerThanInt [expr {wide(0x80000000) != int(0x80000000)}]
24
25test obj-1.1 {Tcl_AppendAllObjTypes, and InitTypeTable, Tcl_RegisterObjType} testobj {
26    set r 1
27    foreach {t} {
28        {array search}
29        bytearray
30        bytecode
31        cmdName
32        dict
33        end-offset
34        regexp
35        string
36    } {
37        set first [string first $t [testobj types]]
38        set r [expr {$r && ($first != -1)}]
39    }
40    set result $r
41} {1}
42
43test obj-2.1 {Tcl_GetObjType error} testobj {
44    list [testintobj set 1 0] [catch {testobj convert 1 foo} msg] $msg
45} {0 1 {no type foo found}}
46test obj-2.2 {Tcl_GetObjType and Tcl_ConvertToType} testobj {
47    set result ""
48    lappend result [testobj freeallvars]
49    lappend result [testintobj set 1 12]
50    lappend result [testobj convert 1 bytearray]
51    lappend result [testobj type 1]
52    lappend result [testobj refcount 1]
53} {{} 12 12 bytearray 3}
54
55test obj-3.1 {Tcl_ConvertToType error} testobj {
56    list [testdoubleobj set 1 12.34] \
57        [catch {testobj convert 1 end-offset} msg] \
58         $msg
59} {12.34 1 {bad index "12.34": must be end?[+-]integer?}}
60test obj-3.2 {Tcl_ConvertToType error, "empty string" object} testobj {
61    list [testobj newobj 1] [catch {testobj convert 1 end-offset} msg] $msg
62} {{} 1 {bad index "": must be end?[+-]integer?}}
63
64test obj-4.1 {Tcl_NewObj and AllocateFreeObjects} testobj {
65    set result ""
66    lappend result [testobj freeallvars]
67    lappend result [testobj newobj 1]
68    lappend result [testobj type 1]
69    lappend result [testobj refcount 1]
70} {{} {} string 2}
71
72test obj-5.1 {Tcl_FreeObj} testobj {
73    set result ""
74    lappend result [testintobj set 1 12345]
75    lappend result [testobj freeallvars]
76    lappend result [catch {testintobj get 1} msg]
77    lappend result $msg
78} {12345 {} 1 {variable 1 is unset (NULL)}}
79
80test obj-6.1 {Tcl_DuplicateObj, object has internal rep} testobj {
81    set result ""
82    lappend result [testobj freeallvars]
83    lappend result [testintobj set 1 47]
84    lappend result [testobj duplicate 1 2]   
85    lappend result [testintobj get 2]
86    lappend result [testobj refcount 1]
87    lappend result [testobj refcount 2]
88} {{} 47 47 47 2 3}
89test obj-6.2 {Tcl_DuplicateObj, "empty string" object} testobj {
90    set result ""
91    lappend result [testobj freeallvars]
92    lappend result [testobj newobj 1]
93    lappend result [testobj duplicate 1 2]   
94    lappend result [testintobj get 2]
95    lappend result [testobj refcount 1]
96    lappend result [testobj refcount 2]
97} {{} {} {} {} 2 3}
98
99# We assume that testobj is an indicator for test*obj as well
100
101test obj-7.1 {Tcl_GetString, return existing string rep} testobj {
102    set result ""
103    lappend result [testintobj set 1 47]
104    lappend result [testintobj get2 1]
105} {47 47}
106test obj-7.2 {Tcl_GetString, "empty string" object} testobj {
107    set result ""
108    lappend result [testobj newobj 1]
109    lappend result [teststringobj append 1 abc -1]
110    lappend result [teststringobj get2 1]
111} {{} abc abc}
112test obj-7.3 {Tcl_GetString, returns string internal rep (DString)} testobj {
113    set result ""
114    lappend result [teststringobj set 1 xyz]
115    lappend result [teststringobj append 1 abc -1]
116    lappend result [teststringobj get2 1]
117} {xyz xyzabc xyzabc}
118test obj-7.4 {Tcl_GetString, recompute string rep from internal rep} testobj {
119    set result ""
120    lappend result [testintobj set 1 77]
121    lappend result [testintobj mult10 1]
122    lappend result [teststringobj get2 1]
123} {77 770 770}
124
125test obj-8.1 {Tcl_GetStringFromObj, return existing string rep} testobj {
126    set result ""
127    lappend result [testintobj set 1 47]
128    lappend result [testintobj get 1]
129} {47 47}
130test obj-8.2 {Tcl_GetStringFromObj, "empty string" object} testobj {
131    set result ""
132    lappend result [testobj newobj 1]
133    lappend result [teststringobj append 1 abc -1]
134    lappend result [teststringobj get 1]
135} {{} abc abc}
136test obj-8.3 {Tcl_GetStringFromObj, returns string internal rep (DString)} testobj {
137    set result ""
138    lappend result [teststringobj set 1 xyz]
139    lappend result [teststringobj append 1 abc -1]
140    lappend result [teststringobj get 1]
141} {xyz xyzabc xyzabc}
142test obj-8.4 {Tcl_GetStringFromObj, recompute string rep from internal rep} testobj {
143    set result ""
144    lappend result [testintobj set 1 77]
145    lappend result [testintobj mult10 1]
146    lappend result [teststringobj get 1]
147} {77 770 770}
148
149test obj-9.1 {Tcl_NewBooleanObj} testobj {
150    set result ""
151    lappend result [testobj freeallvars]
152    lappend result [testbooleanobj set 1 0]
153    lappend result [testobj type 1]
154    lappend result [testobj refcount 1]
155} {{} 0 int 2}
156
157test obj-10.1 {Tcl_SetBooleanObj, existing "empty string" object} testobj {
158    set result ""
159    lappend result [testobj freeallvars]
160    lappend result [testobj newobj 1]
161    lappend result [testbooleanobj set 1 0]  ;# makes existing obj boolean
162    lappend result [testobj type 1]
163    lappend result [testobj refcount 1]
164} {{} {} 0 int 2}
165test obj-10.2 {Tcl_SetBooleanObj, existing non-"empty string" object} testobj {
166    set result ""
167    lappend result [testobj freeallvars]
168    lappend result [testintobj set 1 98765]
169    lappend result [testbooleanobj set 1 1]  ;# makes existing obj boolean
170    lappend result [testobj type 1]
171    lappend result [testobj refcount 1]
172} {{} 98765 1 int 2}
173
174test obj-11.1 {Tcl_GetBooleanFromObj, existing boolean object} testobj {
175    set result ""
176    lappend result [testbooleanobj set 1 1]
177    lappend result [testbooleanobj not 1]    ;# gets existing boolean rep
178} {1 0}
179test obj-11.2 {Tcl_GetBooleanFromObj, convert to boolean} testobj {
180    set result ""
181    lappend result [testintobj set 1 47]
182    lappend result [testbooleanobj not 1]    ;# must convert to bool
183    lappend result [testobj type 1]
184} {47 0 int}
185test obj-11.3 {Tcl_GetBooleanFromObj, error converting to boolean} testobj {
186    set result ""
187    lappend result [teststringobj set 1 abc]
188    lappend result [catch {testbooleanobj not 1} msg]
189    lappend result $msg
190} {abc 1 {expected boolean value but got "abc"}}
191test obj-11.4 {Tcl_GetBooleanFromObj, error converting from "empty string"} testobj {
192    set result ""
193    lappend result [testobj newobj 1]
194    lappend result [catch {testbooleanobj not 1} msg]
195    lappend result $msg
196} {{} 1 {expected boolean value but got ""}}
197test obj-11.5 {Tcl_GetBooleanFromObj, convert hex to boolean} testobj {
198    set result ""
199    lappend result [teststringobj set 1 0xac]
200    lappend result [testbooleanobj not 1]
201    lappend result [testobj type 1]
202} {0xac 0 int}
203test obj-11.6 {Tcl_GetBooleanFromObj, convert float to boolean} testobj {
204    set result ""
205    lappend result [teststringobj set 1 5.42]
206    lappend result [testbooleanobj not 1]
207    lappend result [testobj type 1]
208} {5.42 0 int}
209
210test obj-12.1 {DupBooleanInternalRep} testobj {
211    set result ""
212    lappend result [testbooleanobj set 1 1]
213    lappend result [testobj duplicate 1 2]   ;# uses DupBooleanInternalRep
214    lappend result [testbooleanobj get 2]
215} {1 1 1}
216
217test obj-13.1 {SetBooleanFromAny, int to boolean special case} testobj {
218    set result ""
219    lappend result [testintobj set 1 1234]
220    lappend result [testbooleanobj not 1]    ;# converts with SetBooleanFromAny
221    lappend result [testobj type 1]
222} {1234 0 int}
223test obj-13.2 {SetBooleanFromAny, double to boolean special case} testobj {
224    set result ""
225    lappend result [testdoubleobj set 1 3.14159]
226    lappend result [testbooleanobj not 1]    ;# converts with SetBooleanFromAny
227    lappend result [testobj type 1]
228} {3.14159 0 int}
229test obj-13.3 {SetBooleanFromAny, special case strings representing booleans} testobj {
230    set result ""
231    foreach s {yes no true false on off} {
232        teststringobj set 1 $s
233        lappend result [testbooleanobj not 1]
234    }
235    lappend result [testobj type 1]
236} {0 1 0 1 0 1 int}
237test obj-13.4 {SetBooleanFromAny, recompute string rep then parse it} testobj {
238    set result ""
239    lappend result [testintobj set 1 456]
240    lappend result [testintobj div10 1]
241    lappend result [testbooleanobj not 1]    ;# converts with SetBooleanFromAny
242    lappend result [testobj type 1]
243} {456 45 0 int}
244test obj-13.5 {SetBooleanFromAny, error parsing string} testobj {
245    set result ""
246    lappend result [teststringobj set 1 abc]
247    lappend result [catch {testbooleanobj not 1} msg]
248    lappend result $msg
249} {abc 1 {expected boolean value but got "abc"}}
250test obj-13.6 {SetBooleanFromAny, error parsing string} testobj {
251    set result ""
252    lappend result [teststringobj set 1 x1.0]
253    lappend result [catch {testbooleanobj not 1} msg]
254    lappend result $msg
255} {x1.0 1 {expected boolean value but got "x1.0"}}
256test obj-13.7 {SetBooleanFromAny, error converting from "empty string"} testobj {
257    set result ""
258    lappend result [testobj newobj 1]
259    lappend result [catch {testbooleanobj not 1} msg]
260    lappend result $msg
261} {{} 1 {expected boolean value but got ""}}
262test obj-13.8 {SetBooleanFromAny, unicode strings} testobj {
263    set result ""
264    lappend result [teststringobj set 1 1\u7777]
265    lappend result [catch {testbooleanobj not 1} msg]
266    lappend result $msg
267} "1\u7777 1 {expected boolean value but got \"1\u7777\"}"
268
269test obj-14.1 {UpdateStringOfBoolean} testobj {
270    set result ""
271    lappend result [testbooleanobj set 1 0]
272    lappend result [testbooleanobj not 1]
273    lappend result [testbooleanobj get 1]    ;# must update string rep
274} {0 1 1}
275
276test obj-15.1 {Tcl_NewDoubleObj} testobj {
277    set result ""
278    lappend result [testobj freeallvars]
279    lappend result [testdoubleobj set 1 3.1459]
280    lappend result [testobj type 1]
281    lappend result [testobj refcount 1]
282} {{} 3.1459 double 2}
283
284test obj-16.1 {Tcl_SetDoubleObj, existing "empty string" object} testobj {
285    set result ""
286    lappend result [testobj freeallvars]
287    lappend result [testobj newobj 1]
288    lappend result [testdoubleobj set 1 0.123]  ;# makes existing obj boolean
289    lappend result [testobj type 1]
290    lappend result [testobj refcount 1]
291} {{} {} 0.123 double 2}
292test obj-16.2 {Tcl_SetDoubleObj, existing non-"empty string" object} testobj {
293    set result ""
294    lappend result [testobj freeallvars]
295    lappend result [testintobj set 1 98765]
296    lappend result [testdoubleobj set 1 27.56]  ;# makes existing obj double
297    lappend result [testobj type 1]
298    lappend result [testobj refcount 1]
299} {{} 98765 27.56 double 2}
300
301test obj-17.1 {Tcl_GetDoubleFromObj, existing double object} testobj {
302    set result ""
303    lappend result [testdoubleobj set 1 16.1]
304    lappend result [testdoubleobj mult10 1]   ;# gets existing double rep
305} {16.1 161.0}
306test obj-17.2 {Tcl_GetDoubleFromObj, convert to double} testobj {
307    set result ""
308    lappend result [testintobj set 1 477]
309    lappend result [testdoubleobj div10 1]    ;# must convert to bool
310    lappend result [testobj type 1]
311} {477 47.7 double}
312test obj-17.3 {Tcl_GetDoubleFromObj, error converting to double} testobj {
313    set result ""
314    lappend result [teststringobj set 1 abc]
315    lappend result [catch {testdoubleobj mult10 1} msg]
316    lappend result $msg
317} {abc 1 {expected floating-point number but got "abc"}}
318test obj-17.4 {Tcl_GetDoubleFromObj, error converting from "empty string"} testobj {
319    set result ""
320    lappend result [testobj newobj 1]
321    lappend result [catch {testdoubleobj div10 1} msg]
322    lappend result $msg
323} {{} 1 {expected floating-point number but got ""}}
324
325test obj-18.1 {DupDoubleInternalRep} testobj {
326    set result ""
327    lappend result [testdoubleobj set 1 17.1]
328    lappend result [testobj duplicate 1 2]      ;# uses DupDoubleInternalRep
329    lappend result [testdoubleobj get 2]
330} {17.1 17.1 17.1}
331
332test obj-19.1 {SetDoubleFromAny, int to double special case} testobj {
333    set result ""
334    lappend result [testintobj set 1 1234]
335    lappend result [testdoubleobj mult10 1] ;# converts with SetDoubleFromAny
336    lappend result [testobj type 1]
337} {1234 12340.0 double}
338test obj-19.2 {SetDoubleFromAny, boolean to double special case} testobj {
339    set result ""
340    lappend result [testbooleanobj set 1 1]
341    lappend result [testdoubleobj mult10 1] ;# converts with SetDoubleFromAny
342    lappend result [testobj type 1]
343} {1 10.0 double}
344test obj-19.3 {SetDoubleFromAny, recompute string rep then parse it} testobj {
345    set result ""
346    lappend result [testintobj set 1 456]
347    lappend result [testintobj div10 1]
348    lappend result [testdoubleobj mult10 1] ;# converts with SetDoubleFromAny
349    lappend result [testobj type 1]
350} {456 45 450.0 double}
351test obj-19.4 {SetDoubleFromAny, error parsing string} testobj {
352    set result ""
353    lappend result [teststringobj set 1 abc]
354    lappend result [catch {testdoubleobj mult10 1} msg]
355    lappend result $msg
356} {abc 1 {expected floating-point number but got "abc"}}
357test obj-19.5 {SetDoubleFromAny, error parsing string} testobj {
358    set result ""
359    lappend result [teststringobj set 1 x1.0]
360    lappend result [catch {testdoubleobj mult10 1} msg]
361    lappend result $msg
362} {x1.0 1 {expected floating-point number but got "x1.0"}}
363test obj-19.6 {SetDoubleFromAny, error converting from "empty string"} testobj {
364    set result ""
365    lappend result [testobj newobj 1]
366    lappend result [catch {testdoubleobj div10 1} msg]
367    lappend result $msg
368} {{} 1 {expected floating-point number but got ""}}
369
370test obj-20.1 {UpdateStringOfDouble} testobj {
371    set result ""
372    lappend result [testdoubleobj set 1 3.14159]
373    lappend result [testdoubleobj mult10 1]
374    lappend result [testdoubleobj get 1]   ;# must update string rep
375} {3.14159 31.4159 31.4159}
376
377test obj-21.1 {Tcl_NewIntObj} testobj {
378    set result ""
379    lappend result [testobj freeallvars]
380    lappend result [testintobj set 1 55]
381    lappend result [testobj type 1]
382    lappend result [testobj refcount 1]
383} {{} 55 int 2}
384
385test obj-22.1 {Tcl_SetIntObj, existing "empty string" object} testobj {
386    set result ""
387    lappend result [testobj freeallvars]
388    lappend result [testobj newobj 1]
389    lappend result [testintobj set 1 77]  ;# makes existing obj int
390    lappend result [testobj type 1]
391    lappend result [testobj refcount 1]
392} {{} {} 77 int 2}
393test obj-22.2 {Tcl_SetIntObj, existing non-"empty string" object} testobj {
394    set result ""
395    lappend result [testobj freeallvars]
396    lappend result [testdoubleobj set 1 12.34]
397    lappend result [testintobj set 1 77]  ;# makes existing obj int
398    lappend result [testobj type 1]
399    lappend result [testobj refcount 1]
400} {{} 12.34 77 int 2}
401
402test obj-23.1 {Tcl_GetIntFromObj, existing int object} testobj {
403    set result ""
404    lappend result [testintobj set 1 22]
405    lappend result [testintobj mult10 1]   ;# gets existing int rep
406} {22 220}
407test obj-23.2 {Tcl_GetIntFromObj, convert to int} testobj {
408    set result ""
409    lappend result [testintobj set 1 477]
410    lappend result [testintobj div10 1]    ;# must convert to bool
411    lappend result [testobj type 1]
412} {477 47 int}
413test obj-23.3 {Tcl_GetIntFromObj, error converting to int} testobj {
414    set result ""
415    lappend result [teststringobj set 1 abc]
416    lappend result [catch {testintobj mult10 1} msg]
417    lappend result $msg
418} {abc 1 {expected integer but got "abc"}}
419test obj-23.4 {Tcl_GetIntFromObj, error converting from "empty string"} testobj {
420    set result ""
421    lappend result [testobj newobj 1]
422    lappend result [catch {testintobj div10 1} msg]
423    lappend result $msg
424} {{} 1 {expected integer but got ""}}
425test obj-23.5 {Tcl_GetIntFromObj, integer too large to represent as non-long error} {testobj} {
426    set result ""
427    lappend result [testobj newobj 1]
428    lappend result [testintobj inttoobigtest 1]
429} {{} 1}
430
431test obj-24.1 {DupIntInternalRep} testobj {
432    set result ""
433    lappend result [testintobj set 1 23]
434    lappend result [testobj duplicate 1 2]    ;# uses DupIntInternalRep
435    lappend result [testintobj get 2]
436} {23 23 23}
437
438test obj-25.1 {SetIntFromAny, int to int special case} testobj {
439    set result ""
440    lappend result [testintobj set 1 1234]
441    lappend result [testintobj mult10 1]  ;# converts with SetIntFromAny
442    lappend result [testobj type 1]
443} {1234 12340 int}
444test obj-25.2 {SetIntFromAny, boolean to int special case} testobj {
445    set result ""
446    lappend result [testbooleanobj set 1 1]
447    lappend result [testintobj mult10 1]  ;# converts with SetIntFromAny
448    lappend result [testobj type 1]
449} {1 10 int}
450test obj-25.3 {SetIntFromAny, recompute string rep then parse it} testobj {
451    set result ""
452    lappend result [testintobj set 1 456]
453    lappend result [testintobj div10 1]
454    lappend result [testintobj mult10 1]  ;# converts with SetIntFromAny
455    lappend result [testobj type 1]
456} {456 45 450 int}
457test obj-25.4 {SetIntFromAny, error parsing string} testobj {
458    set result ""
459    lappend result [teststringobj set 1 abc]
460    lappend result [catch {testintobj mult10 1} msg]
461    lappend result $msg
462} {abc 1 {expected integer but got "abc"}}
463test obj-25.5 {SetIntFromAny, error parsing string} testobj {
464    set result ""
465    lappend result [teststringobj set 1 x17]
466    lappend result [catch {testintobj mult10 1} msg]
467    lappend result $msg
468} {x17 1 {expected integer but got "x17"}}
469test obj-25.6 {SetIntFromAny, integer too large} {testobj} {
470    set result ""
471    lappend result [teststringobj set 1 123456789012345678901]
472    lappend result [catch {testintobj mult10 1} msg]
473    lappend result $msg
474} {123456789012345678901 1 {integer value too large to represent}}
475test obj-25.7 {SetIntFromAny, error converting from "empty string"} testobj {
476    set result ""
477    lappend result [testobj newobj 1]
478    lappend result [catch {testintobj div10 1} msg]
479    lappend result $msg
480} {{} 1 {expected integer but got ""}}
481
482test obj-26.1 {UpdateStringOfInt} testobj {
483    set result ""
484    lappend result [testintobj set 1 512]
485    lappend result [testintobj mult10 1]
486    lappend result [testintobj get 1]       ;# must update string rep
487} {512 5120 5120}
488
489test obj-27.1 {Tcl_NewLongObj} testobj {
490    set result ""
491    lappend result [testobj freeallvars]
492    testintobj setmaxlong 1
493    lappend result [testintobj ismaxlong 1]
494    lappend result [testobj type 1]
495    lappend result [testobj refcount 1]
496} {{} 1 int 1}
497
498test obj-28.1 {Tcl_SetLongObj, existing "empty string" object} testobj {
499    set result ""
500    lappend result [testobj freeallvars]
501    lappend result [testobj newobj 1]
502    lappend result [testintobj setlong 1 77]  ;# makes existing obj long int
503    lappend result [testobj type 1]
504    lappend result [testobj refcount 1]
505} {{} {} 77 int 2}
506test obj-28.2 {Tcl_SetLongObj, existing non-"empty string" object} testobj {
507    set result ""
508    lappend result [testobj freeallvars]
509    lappend result [testdoubleobj set 1 12.34]
510    lappend result [testintobj setlong 1 77]  ;# makes existing obj long int
511    lappend result [testobj type 1]
512    lappend result [testobj refcount 1]
513} {{} 12.34 77 int 2}
514
515test obj-29.1 {Tcl_GetLongFromObj, existing long integer object} testobj {
516    set result ""
517    lappend result [testintobj setlong 1 22]
518    lappend result [testintobj mult10 1]   ;# gets existing long int rep
519} {22 220}
520test obj-29.2 {Tcl_GetLongFromObj, convert to long} testobj {
521    set result ""
522    lappend result [testintobj setlong 1 477]
523    lappend result [testintobj div10 1]    ;# must convert to bool
524    lappend result [testobj type 1]
525} {477 47 int}
526test obj-29.3 {Tcl_GetLongFromObj, error converting to long integer} testobj {
527    set result ""
528    lappend result [teststringobj set 1 abc]
529    lappend result [catch {testintobj ismaxlong 1} msg] ;# cvts to long int
530    lappend result $msg
531} {abc 1 {expected integer but got "abc"}}
532test obj-29.4 {Tcl_GetLongFromObj, error converting from "empty string"} testobj {
533    set result ""
534    lappend result [testobj newobj 1]
535    lappend result [catch {testintobj ismaxlong 1} msg] ;# cvts to long int
536    lappend result $msg
537} {{} 1 {expected integer but got ""}}
538
539test obj-30.1 {Ref counting and object deletion, simple types} testobj {
540    set result ""
541    lappend result [testobj freeallvars]
542    lappend result [testintobj set 1 1024]
543    lappend result [testobj assign 1 2]     ;# vars 1 and 2 share the int obj
544    lappend result [testobj type 2]
545    lappend result [testobj refcount 1]
546    lappend result [testobj refcount 2]
547    lappend result [testbooleanobj set 2 0] ;# must copy on write, now 2 objs
548    lappend result [testobj type 2]
549    lappend result [testobj refcount 1]
550    lappend result [testobj refcount 2]
551} {{} 1024 1024 int 4 4 0 int 3 2}
552
553
554test obj-31.1 {regenerate string rep of "end"} testobj {
555    testobj freeallvars
556    teststringobj set 1 end
557    testobj convert 1 end-offset
558    testobj invalidateStringRep 1
559} end
560test obj-31.2 {regenerate string rep of "end-1"} testobj {
561    testobj freeallvars
562    teststringobj set 1 end-0x1
563    testobj convert 1 end-offset
564    testobj invalidateStringRep 1
565} end-1
566test obj-31.3 {regenerate string rep of "end--1"} testobj {
567    testobj freeallvars
568    teststringobj set 1 end--0x1
569    testobj convert 1 end-offset
570    testobj invalidateStringRep 1
571} end--1
572test obj-31.4 {regenerate string rep of "end-bigInteger"} testobj {
573    testobj freeallvars
574    teststringobj set 1 end-0x7fffffff
575    testobj convert 1 end-offset
576    testobj invalidateStringRep 1
577} end-2147483647
578test obj-31.5 {regenerate string rep of "end--bigInteger"} testobj {
579    testobj freeallvars
580    teststringobj set 1 end--0x7fffffff
581    testobj convert 1 end-offset
582    testobj invalidateStringRep 1
583} end--2147483647
584test obj-31.6 {regenerate string rep of "end--bigInteger"} {testobj longIs32bit} {
585    testobj freeallvars
586    teststringobj set 1 end--0x80000000
587    testobj convert 1 end-offset
588    testobj invalidateStringRep 1
589} end--2147483648
590
591test obj-32.1 {freeing very large object trees} {
592    set x {}
593    for {set i 0} {$i<100000} {incr i} {
594        set x [list $x {}]
595    }
596    unset x
597} {}
598
599test obj-33.1 {integer overflow on input} {longIs32bit wideBiggerThanInt} {
600    set x 0x8000; append x 0000
601    list [string is integer $x] [expr { wide($x) }]
602} {1 2147483648}
603test obj-33.2 {integer overflow on input} {longIs32bit wideBiggerThanInt} {
604    set x 0xffff; append x ffff
605    list [string is integer $x] [expr { wide($x) }]
606} {1 4294967295}
607test obj-33.3 {integer overflow on input} {longIs32bit wideBiggerThanInt} {
608    set x 0x10000; append x 0000
609    list [string is integer $x] [expr { wide($x) }]
610} {0 4294967296}
611test obj-33.4 {integer overflow on input} {longIs32bit wideBiggerThanInt} {
612    set x -0x8000; append x 0000
613    list [string is integer $x] [expr { wide($x) }]
614} {1 -2147483648}
615test obj-33.5 {integer overflow on input} {longIs32bit wideBiggerThanInt} {
616    set x -0x8000; append x 0001
617    list [string is integer $x] [expr { wide($x) }]
618} {1 -2147483649}
619test obj-33.6 {integer overflow on input} {longIs32bit wideBiggerThanInt} {
620    set x -0xffff; append x ffff
621    list [string is integer $x] [expr { wide($x) }]
622} {1 -4294967295}
623test obj-33.7 {integer overflow on input} {longIs32bit wideBiggerThanInt} {
624    set x -0x10000; append x 0000
625    list [string is integer $x] [expr { wide($x) }]
626} {0 -4294967296}
627
628if {[testConstraint testobj]} {
629    testobj freeallvars
630}
631
632# cleanup
633::tcltest::cleanupTests
634return
Note: See TracBrowser for help on using the repository browser.