1411
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
1447
|
3 |
"{ Package: 'stx:goodies/regression' }"
|
298
|
4 |
|
|
5 |
"{ NameSpace: RegressionTests }"
|
|
6 |
|
|
7 |
TestCase subclass:#BecomeTests
|
|
8 |
instanceVariableNames:''
|
|
9 |
classVariableNames:''
|
|
10 |
poolDictionaries:''
|
1155
|
11 |
category:'tests-Regression-RuntimeSystem'
|
298
|
12 |
!
|
|
13 |
|
|
14 |
|
|
15 |
!BecomeTests methodsFor:'tests'!
|
|
16 |
|
1411
|
17 |
test01_become
|
298
|
18 |
"Test the two way become. Note. we cannot use string literals for this test"
|
|
19 |
|
|
20 |
| a b c d |
|
|
21 |
|
680
|
22 |
a := c := '123' copy.
|
|
23 |
b := d := 'cd' copy.
|
298
|
24 |
|
|
25 |
a become: b.
|
|
26 |
|
|
27 |
self
|
|
28 |
assert: a = 'cd';
|
680
|
29 |
assert: b = '123';
|
298
|
30 |
assert: c = 'cd';
|
680
|
31 |
assert: d = '123'.
|
298
|
32 |
|
|
33 |
|
|
34 |
"
|
1411
|
35 |
self new test01_become
|
298
|
36 |
"
|
1411
|
37 |
|
|
38 |
"Created: / 30-04-2016 / 09:39:09 / cg"
|
298
|
39 |
!
|
|
40 |
|
1411
|
41 |
test10_becomeForward
|
298
|
42 |
"Test the forward become."
|
|
43 |
|
|
44 |
| a b c d |
|
|
45 |
|
|
46 |
a := 'ab' copy.
|
|
47 |
b := 'cd' copy.
|
|
48 |
c := a.
|
|
49 |
d := b.
|
|
50 |
|
|
51 |
a becomeForward: b.
|
|
52 |
|
|
53 |
self
|
|
54 |
assert: a = 'cd';
|
|
55 |
assert: b = 'cd';
|
|
56 |
assert: c = 'cd';
|
|
57 |
assert: d = 'cd'.
|
|
58 |
|
|
59 |
|
|
60 |
"
|
1411
|
61 |
self new test10_becomeForward
|
298
|
62 |
"
|
1411
|
63 |
|
|
64 |
"Created: / 30-04-2016 / 09:39:19 / cg"
|
298
|
65 |
!
|
|
66 |
|
1411
|
67 |
test11_becomeForwardDontCopyIdentityHash
|
298
|
68 |
"Check that
|
|
69 |
1. the argument to becomeForward: is NOT modified to have the receiver's identity hash.
|
|
70 |
2. the receiver's identity hash is unchanged."
|
|
71 |
|
|
72 |
| a b hb |
|
|
73 |
|
|
74 |
a := 'ab' copy.
|
|
75 |
b := 'cd' copy.
|
|
76 |
hb := b identityHash.
|
|
77 |
|
|
78 |
a becomeForward: b copyHash: false.
|
|
79 |
|
|
80 |
self
|
|
81 |
assert: a identityHash = hb;
|
|
82 |
assert: b identityHash = hb.
|
|
83 |
|
|
84 |
"
|
1411
|
85 |
self new test11_becomeForwardDontCopyIdentityHash
|
298
|
86 |
"
|
1411
|
87 |
|
|
88 |
"Created: / 30-04-2016 / 09:39:30 / cg"
|
298
|
89 |
!
|
|
90 |
|
1411
|
91 |
test12_becomeForwardHash
|
298
|
92 |
| a b c hb |
|
|
93 |
|
|
94 |
a := 'ab' copy.
|
|
95 |
b := 'cd' copy.
|
|
96 |
c := a.
|
|
97 |
hb := b hash.
|
|
98 |
|
|
99 |
a becomeForward: b.
|
|
100 |
|
|
101 |
self
|
|
102 |
assert: a hash = hb;
|
|
103 |
assert: b hash = hb;
|
|
104 |
assert: c hash = hb.
|
|
105 |
|
|
106 |
"
|
1411
|
107 |
self new test12_becomeForwardHash
|
298
|
108 |
"
|
1411
|
109 |
|
|
110 |
"Created: / 30-04-2016 / 09:39:38 / cg"
|
298
|
111 |
!
|
|
112 |
|
1411
|
113 |
test13_becomeForwardIdentityHash
|
298
|
114 |
"Check that
|
|
115 |
1. the argument to becomeForward: is modified to have the receiver's identity hash.
|
|
116 |
2. the receiver's identity hash is unchanged."
|
|
117 |
|
|
118 |
| a b ha |
|
|
119 |
|
|
120 |
a := 'ab' copy.
|
|
121 |
b := 'cd' copy.
|
|
122 |
ha := a identityHash.
|
|
123 |
|
|
124 |
a becomeForward: b.
|
|
125 |
|
|
126 |
self
|
|
127 |
assert: a identityHash = ha;
|
|
128 |
assert: b identityHash = ha.
|
|
129 |
|
|
130 |
|
|
131 |
"
|
1411
|
132 |
self new test13_becomeForwardIdentityHash
|
298
|
133 |
"
|
1411
|
134 |
|
|
135 |
"Created: / 30-04-2016 / 09:39:45 / cg"
|
298
|
136 |
!
|
|
137 |
|
1411
|
138 |
test50_becomeHash
|
298
|
139 |
|
|
140 |
| a b c d ha hb |
|
|
141 |
|
681
|
142 |
a := c := 'ab' copy.
|
|
143 |
b := d := 'cd' copy.
|
|
144 |
|
298
|
145 |
ha := a hash.
|
|
146 |
hb := b hash.
|
|
147 |
|
|
148 |
a become: b.
|
|
149 |
|
|
150 |
self
|
680
|
151 |
assert: a = 'cd';
|
|
152 |
assert: b = 'ab';
|
|
153 |
assert: c = 'cd';
|
|
154 |
assert: d = 'ab';
|
298
|
155 |
assert: a hash = hb;
|
|
156 |
assert: b hash = ha;
|
|
157 |
assert: c hash = hb;
|
|
158 |
assert: d hash = ha.
|
|
159 |
|
|
160 |
|
|
161 |
"
|
1411
|
162 |
self new test50_becomeHash
|
298
|
163 |
"
|
1411
|
164 |
|
|
165 |
"Created: / 30-04-2016 / 09:39:53 / cg"
|
298
|
166 |
!
|
|
167 |
|
1411
|
168 |
test51_becomeIdentityHash
|
298
|
169 |
"Note. The identity hash of both objects seems to change after the become:"
|
|
170 |
|
|
171 |
| a b c d |
|
|
172 |
|
|
173 |
a := 'ab' copy.
|
|
174 |
b := 'cd' copy.
|
|
175 |
c := a.
|
|
176 |
d := b.
|
|
177 |
|
|
178 |
a become: b.
|
|
179 |
|
|
180 |
self
|
|
181 |
assert: a identityHash = c identityHash;
|
|
182 |
assert: b identityHash = d identityHash;
|
|
183 |
deny: a identityHash = b identityHash.
|
|
184 |
|
|
185 |
"
|
1411
|
186 |
self new test51_becomeIdentityHash
|
298
|
187 |
"
|
1411
|
188 |
|
|
189 |
"Created: / 30-04-2016 / 09:40:02 / cg"
|
1412
|
190 |
!
|
|
191 |
|
|
192 |
test60_becomeArray
|
|
193 |
| a b |
|
|
194 |
|
|
195 |
a := Array new:0.
|
|
196 |
b := Array new:0.
|
|
197 |
|
|
198 |
a add: 1.
|
|
199 |
ObjectMemory garbageCollect.
|
|
200 |
b add: 1.
|
|
201 |
ObjectMemory garbageCollect.
|
|
202 |
a add: 2.
|
|
203 |
ObjectMemory garbageCollect.
|
|
204 |
b add: 2.
|
|
205 |
ObjectMemory garbageCollect.
|
|
206 |
a printString.
|
|
207 |
b printString.
|
|
208 |
self
|
|
209 |
assert: a size == 2;
|
|
210 |
assert: b size == 2.
|
|
211 |
|
|
212 |
"
|
|
213 |
self new test60_becomeArray
|
|
214 |
"
|
|
215 |
|
|
216 |
"Created: / 30-04-2016 / 09:40:02 / cg"
|
|
217 |
!
|
|
218 |
|
|
219 |
test61_becomeArray
|
|
220 |
| a b |
|
|
221 |
|
|
222 |
a := Array new:0.
|
|
223 |
b := Array new:0.
|
|
224 |
|
|
225 |
50 timesRepeat:[
|
|
226 |
a add: 1.
|
|
227 |
ObjectMemory garbageCollect.
|
|
228 |
b add: 1.
|
|
229 |
ObjectMemory garbageCollect.
|
|
230 |
].
|
|
231 |
self
|
|
232 |
assert: a size == 50;
|
|
233 |
assert: b size == 50.
|
|
234 |
|
|
235 |
"
|
|
236 |
self new test61_becomeArray
|
|
237 |
"
|
298
|
238 |
! !
|
|
239 |
|
|
240 |
!BecomeTests class methodsFor:'documentation'!
|
|
241 |
|
|
242 |
version
|
|
243 |
^ '$Header$'
|
681
|
244 |
!
|
|
245 |
|
|
246 |
version_CVS
|
|
247 |
^ '$Header$'
|
298
|
248 |
! !
|
1155
|
249 |
|