298
|
1 |
"{ Package: 'exept:regression' }"
|
|
2 |
|
|
3 |
"{ NameSpace: RegressionTests }"
|
|
4 |
|
|
5 |
TestCase subclass:#BecomeTests
|
|
6 |
instanceVariableNames:''
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
1155
|
9 |
category:'tests-Regression-RuntimeSystem'
|
298
|
10 |
!
|
|
11 |
|
|
12 |
|
|
13 |
!BecomeTests methodsFor:'tests'!
|
|
14 |
|
|
15 |
testBecome
|
|
16 |
"Test the two way become. Note. we cannot use string literals for this test"
|
|
17 |
|
|
18 |
| a b c d |
|
|
19 |
|
680
|
20 |
a := c := '123' copy.
|
|
21 |
b := d := 'cd' copy.
|
298
|
22 |
|
|
23 |
a become: b.
|
|
24 |
|
|
25 |
self
|
|
26 |
assert: a = 'cd';
|
680
|
27 |
assert: b = '123';
|
298
|
28 |
assert: c = 'cd';
|
680
|
29 |
assert: d = '123'.
|
298
|
30 |
|
|
31 |
|
|
32 |
"
|
|
33 |
self new testBecome
|
|
34 |
"
|
|
35 |
!
|
|
36 |
|
|
37 |
testBecomeForward
|
|
38 |
"Test the forward become."
|
|
39 |
|
|
40 |
| a b c d |
|
|
41 |
|
|
42 |
a := 'ab' copy.
|
|
43 |
b := 'cd' copy.
|
|
44 |
c := a.
|
|
45 |
d := b.
|
|
46 |
|
|
47 |
a becomeForward: b.
|
|
48 |
|
|
49 |
self
|
|
50 |
assert: a = 'cd';
|
|
51 |
assert: b = 'cd';
|
|
52 |
assert: c = 'cd';
|
|
53 |
assert: d = 'cd'.
|
|
54 |
|
|
55 |
|
|
56 |
"
|
|
57 |
self new testBecomeForward
|
|
58 |
"
|
|
59 |
!
|
|
60 |
|
|
61 |
testBecomeForwardDontCopyIdentityHash
|
|
62 |
"Check that
|
|
63 |
1. the argument to becomeForward: is NOT modified to have the receiver's identity hash.
|
|
64 |
2. the receiver's identity hash is unchanged."
|
|
65 |
|
|
66 |
| a b hb |
|
|
67 |
|
|
68 |
a := 'ab' copy.
|
|
69 |
b := 'cd' copy.
|
|
70 |
hb := b identityHash.
|
|
71 |
|
|
72 |
a becomeForward: b copyHash: false.
|
|
73 |
|
|
74 |
self
|
|
75 |
assert: a identityHash = hb;
|
|
76 |
assert: b identityHash = hb.
|
|
77 |
|
|
78 |
"
|
|
79 |
self new testBecomeForwardDontCopyIdentityHash
|
|
80 |
"
|
|
81 |
!
|
|
82 |
|
|
83 |
testBecomeForwardHash
|
|
84 |
| a b c hb |
|
|
85 |
|
|
86 |
a := 'ab' copy.
|
|
87 |
b := 'cd' copy.
|
|
88 |
c := a.
|
|
89 |
hb := b hash.
|
|
90 |
|
|
91 |
a becomeForward: b.
|
|
92 |
|
|
93 |
self
|
|
94 |
assert: a hash = hb;
|
|
95 |
assert: b hash = hb;
|
|
96 |
assert: c hash = hb.
|
|
97 |
|
|
98 |
"
|
|
99 |
self new testBecomeForwardHash
|
|
100 |
"
|
|
101 |
!
|
|
102 |
|
|
103 |
testBecomeForwardIdentityHash
|
|
104 |
"Check that
|
|
105 |
1. the argument to becomeForward: is modified to have the receiver's identity hash.
|
|
106 |
2. the receiver's identity hash is unchanged."
|
|
107 |
|
|
108 |
| a b ha |
|
|
109 |
|
|
110 |
a := 'ab' copy.
|
|
111 |
b := 'cd' copy.
|
|
112 |
ha := a identityHash.
|
|
113 |
|
|
114 |
a becomeForward: b.
|
|
115 |
|
|
116 |
self
|
|
117 |
assert: a identityHash = ha;
|
|
118 |
assert: b identityHash = ha.
|
|
119 |
|
|
120 |
|
|
121 |
"
|
|
122 |
self new testBecomeForwardIdentityHash
|
|
123 |
"
|
|
124 |
!
|
|
125 |
|
|
126 |
testBecomeHash
|
|
127 |
|
|
128 |
| a b c d ha hb |
|
|
129 |
|
681
|
130 |
a := c := 'ab' copy.
|
|
131 |
b := d := 'cd' copy.
|
|
132 |
|
298
|
133 |
ha := a hash.
|
|
134 |
hb := b hash.
|
|
135 |
|
|
136 |
a become: b.
|
|
137 |
|
|
138 |
self
|
680
|
139 |
assert: a = 'cd';
|
|
140 |
assert: b = 'ab';
|
|
141 |
assert: c = 'cd';
|
|
142 |
assert: d = 'ab';
|
298
|
143 |
assert: a hash = hb;
|
|
144 |
assert: b hash = ha;
|
|
145 |
assert: c hash = hb;
|
|
146 |
assert: d hash = ha.
|
|
147 |
|
|
148 |
|
|
149 |
"
|
|
150 |
self new testBecomeHash
|
|
151 |
"
|
|
152 |
!
|
|
153 |
|
|
154 |
testBecomeIdentityHash
|
|
155 |
"Note. The identity hash of both objects seems to change after the become:"
|
|
156 |
|
|
157 |
| a b c d |
|
|
158 |
|
|
159 |
a := 'ab' copy.
|
|
160 |
b := 'cd' copy.
|
|
161 |
c := a.
|
|
162 |
d := b.
|
|
163 |
|
|
164 |
a become: b.
|
|
165 |
|
|
166 |
self
|
|
167 |
assert: a identityHash = c identityHash;
|
|
168 |
assert: b identityHash = d identityHash;
|
|
169 |
deny: a identityHash = b identityHash.
|
|
170 |
|
|
171 |
"
|
|
172 |
self new testBecomeIdentityHash
|
|
173 |
"
|
|
174 |
! !
|
|
175 |
|
|
176 |
!BecomeTests class methodsFor:'documentation'!
|
|
177 |
|
|
178 |
version
|
|
179 |
^ '$Header$'
|
681
|
180 |
!
|
|
181 |
|
|
182 |
version_CVS
|
|
183 |
^ '$Header$'
|
298
|
184 |
! !
|
1155
|
185 |
|