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