1447
|
1 |
"{ Package: 'stx:goodies/regression' }"
|
72
|
2 |
|
95
|
3 |
"{ NameSpace: RegressionTests }"
|
|
4 |
|
207
|
5 |
TestCase subclass:#EnumerationTests
|
72
|
6 |
instanceVariableNames:''
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
1056
|
9 |
category:'tests-Regression-Collections'
|
72
|
10 |
!
|
|
11 |
|
|
12 |
|
|
13 |
!EnumerationTests class methodsFor:'tests'!
|
|
14 |
|
|
15 |
testArrayKeysAndValuesDo
|
|
16 |
"test GC while enumerating an array"
|
|
17 |
|
|
18 |
|a|
|
|
19 |
|
|
20 |
a := (1 to:100) asArray.
|
|
21 |
|
|
22 |
10 timesRepeat:[
|
95
|
23 |
a keysAndValuesDo:[:index :val |
|
|
24 |
ObjectMemory scavenge.
|
|
25 |
index printString.
|
|
26 |
ObjectMemory scavenge.
|
|
27 |
val printString.
|
|
28 |
]
|
72
|
29 |
]
|
|
30 |
|
|
31 |
"
|
|
32 |
self testArrayKeysAndValuesDo
|
|
33 |
"
|
|
34 |
! !
|
|
35 |
|
207
|
36 |
!EnumerationTests methodsFor:'tests'!
|
|
37 |
|
|
38 |
testArrayKeysAndValuesDo
|
|
39 |
"test GC while enumerating an array"
|
|
40 |
|
|
41 |
|a|
|
|
42 |
|
|
43 |
a := (1 to:100) asArray.
|
|
44 |
|
|
45 |
10 timesRepeat:[
|
1447
|
46 |
a keysAndValuesDo:[:index :val |
|
|
47 |
ObjectMemory scavenge.
|
|
48 |
index printString.
|
|
49 |
ObjectMemory scavenge.
|
|
50 |
val printString.
|
|
51 |
]
|
207
|
52 |
]
|
|
53 |
|
|
54 |
"
|
643
|
55 |
self new testArrayKeysAndValuesDo
|
207
|
56 |
"
|
643
|
57 |
|
|
58 |
"Modified (comment): / 10-10-2011 / 13:48:48 / cg"
|
|
59 |
!
|
|
60 |
|
|
61 |
testWeakArrayKeysAndValuesDo
|
|
62 |
"test GC while enumerating an array"
|
|
63 |
|
|
64 |
|a w|
|
|
65 |
|
|
66 |
a := WeakArray new:100.
|
|
67 |
w := WeakArray new:100.
|
|
68 |
1 to:a size do:[:i |
|
1447
|
69 |
|o|
|
643
|
70 |
|
1447
|
71 |
o := Object new.
|
|
72 |
a at:i put:o.
|
|
73 |
w at:i put:o.
|
643
|
74 |
].
|
|
75 |
|
|
76 |
w keysAndValuesDo:[:index :val |
|
1447
|
77 |
self assert:(val class == Object).
|
643
|
78 |
].
|
|
79 |
|
|
80 |
w keysAndValuesDo:[:index :val |
|
1447
|
81 |
index == 5 ifTrue:[
|
|
82 |
a at:7 put:nil.
|
|
83 |
ObjectMemory scavenge
|
|
84 |
].
|
|
85 |
index == 7 ifTrue:[
|
|
86 |
self assert:(val class == SmallInteger).
|
|
87 |
]
|
643
|
88 |
]
|
|
89 |
|
|
90 |
"
|
|
91 |
self new testWeakArrayKeysAndValuesDo
|
|
92 |
"
|
|
93 |
|
|
94 |
"Created: / 10-10-2011 / 12:51:43 / cg"
|
207
|
95 |
! !
|
|
96 |
|
72
|
97 |
!EnumerationTests class methodsFor:'documentation'!
|
|
98 |
|
|
99 |
version
|
|
100 |
^ '$Header$'
|
|
101 |
! !
|
1056
|
102 |
|