100
|
1 |
"{ Package: 'exept:regression' }"
|
|
2 |
|
|
3 |
"{ NameSpace: RegressionTests }"
|
|
4 |
|
239
|
5 |
nil subclass:#ContextTest2
|
100
|
6 |
instanceVariableNames:''
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
180
|
9 |
category:'tests-Regression'
|
100
|
10 |
!
|
|
11 |
|
|
12 |
|
239
|
13 |
!ContextTest2 methodsFor:'helpers'!
|
100
|
14 |
|
147
|
15 |
downToNextSegmentThenDo:aBlock
|
|
16 |
self
|
|
17 |
downToSegment:(Processor activeProcess numberOfStackSegments + 1)
|
|
18 |
thenDo:aBlock
|
|
19 |
|
|
20 |
"
|
|
21 |
self new testUnwind1
|
|
22 |
"
|
|
23 |
!
|
|
24 |
|
|
25 |
downToNextSegmentThenUnwindAndDo:aBlock
|
|
26 |
self
|
|
27 |
downToSegment:(Processor activeProcess numberOfStackSegments + 1)
|
|
28 |
thenUnwindAndDo:aBlock
|
|
29 |
|
|
30 |
"
|
|
31 |
self new testUnwind2
|
|
32 |
"
|
|
33 |
!
|
|
34 |
|
|
35 |
downToSegment:nr thenDo:aBlock
|
|
36 |
Processor activeProcess numberOfStackSegments >= nr ifTrue:[
|
|
37 |
^ aBlock value
|
|
38 |
].
|
|
39 |
self
|
|
40 |
downToSegment:(Processor activeProcess numberOfStackSegments + 1)
|
|
41 |
thenDo:aBlock
|
|
42 |
|
|
43 |
"
|
|
44 |
self new testUnwind1
|
|
45 |
"
|
|
46 |
!
|
|
47 |
|
|
48 |
downToSegment:nr thenUnwindAndDo:aBlock
|
|
49 |
Processor activeProcess numberOfStackSegments >= nr ifTrue:[
|
|
50 |
aBlock home unwindThenDo: aBlock
|
|
51 |
].
|
|
52 |
self
|
|
53 |
downToSegment:(Processor activeProcess numberOfStackSegments + 1)
|
|
54 |
thenUnwindAndDo:aBlock
|
|
55 |
|
|
56 |
"
|
|
57 |
self new testUnwind2
|
|
58 |
"
|
|
59 |
!
|
|
60 |
|
239
|
61 |
getAssocWithContext
|
|
62 |
^ self getSendersContext -> #foo
|
|
63 |
!
|
|
64 |
|
|
65 |
getSendersContext
|
|
66 |
^ thisContext sender
|
|
67 |
!
|
|
68 |
|
|
69 |
raiseWithContext
|
|
70 |
AbortOperationRequest raiseWith:self getSendersContext
|
240
|
71 |
!
|
|
72 |
|
|
73 |
selfReferringContext
|
|
74 |
|ref|
|
|
75 |
|
|
76 |
ref := thisContext.
|
|
77 |
^ thisContext
|
|
78 |
!
|
|
79 |
|
|
80 |
senderContext
|
|
81 |
^ thisContext sender
|
|
82 |
!
|
|
83 |
|
|
84 |
senderReferringContext1
|
|
85 |
^ self senderReferringContext:thisContext
|
|
86 |
!
|
|
87 |
|
|
88 |
senderReferringContext2
|
|
89 |
^ self senderContext
|
|
90 |
!
|
|
91 |
|
|
92 |
senderReferringContext:aContext
|
|
93 |
^ aContext
|
239
|
94 |
! !
|
|
95 |
|
|
96 |
!ContextTest2 methodsFor:'tests'!
|
|
97 |
|
|
98 |
testContextRef1
|
|
99 |
|assoc|
|
|
100 |
|
|
101 |
assoc := self getAssocWithContext.
|
|
102 |
ObjectMemory garbageCollect.
|
|
103 |
|
|
104 |
"
|
|
105 |
self new testContextRef1
|
|
106 |
"
|
|
107 |
!
|
|
108 |
|
|
109 |
testContextRef2
|
|
110 |
|
|
111 |
self getAssocWithContext.
|
|
112 |
ObjectMemory garbageCollect.
|
|
113 |
|
|
114 |
"
|
|
115 |
self new testContextRef2
|
|
116 |
"
|
|
117 |
!
|
|
118 |
|
|
119 |
testContextRef3
|
|
120 |
AbortOperationRequest handle:[:ex |
|
|
121 |
] do:[
|
|
122 |
self raiseWithContext.
|
|
123 |
].
|
|
124 |
ObjectMemory garbageCollect.
|
|
125 |
|
|
126 |
"
|
|
127 |
self new testContextRef3
|
|
128 |
"
|
|
129 |
!
|
|
130 |
|
|
131 |
testContextRef4
|
|
132 |
|con|
|
|
133 |
|
|
134 |
AbortOperationRequest handle:[:ex |
|
|
135 |
ObjectMemory garbageCollect.
|
|
136 |
con := ex parameter.
|
|
137 |
ObjectMemory garbageCollect.
|
|
138 |
] do:[
|
|
139 |
self raiseWithContext.
|
|
140 |
].
|
|
141 |
ObjectMemory garbageCollect.
|
|
142 |
|
|
143 |
"
|
|
144 |
self new testContextRef4
|
|
145 |
"
|
|
146 |
!
|
|
147 |
|
240
|
148 |
testContextRef5
|
|
149 |
self selfReferringContext.
|
|
150 |
ObjectMemory garbageCollect.
|
|
151 |
|
|
152 |
"
|
|
153 |
self new testContextRef5
|
|
154 |
"
|
|
155 |
!
|
|
156 |
|
|
157 |
testContextRef6
|
|
158 |
self senderReferringContext1.
|
|
159 |
ObjectMemory garbageCollect.
|
|
160 |
|
|
161 |
"
|
|
162 |
self new testContextRef6
|
|
163 |
"
|
|
164 |
!
|
|
165 |
|
|
166 |
testContextRef7
|
|
167 |
self senderReferringContext2.
|
|
168 |
ObjectMemory garbageCollect.
|
|
169 |
|
|
170 |
"
|
|
171 |
self new testContextRef7
|
|
172 |
"
|
|
173 |
!
|
|
174 |
|
100
|
175 |
testProcess1
|
101
|
176 |
|x set lockSet p arg|
|
|
177 |
|
|
178 |
lockSet := Semaphore forMutualExclusion.
|
|
179 |
set := Set new.
|
|
180 |
|
|
181 |
x := 1 @ 1.
|
|
182 |
|
|
183 |
arg := x.
|
|
184 |
|
|
185 |
p := [
|
|
186 |
[
|
|
187 |
lockSet critical:[set add:arg].
|
|
188 |
arg perform:#x .
|
|
189 |
] valueNowOrOnUnwindDo:[
|
|
190 |
lockSet critical:[set remove:arg].
|
|
191 |
].
|
|
192 |
] fork.
|
|
193 |
|
|
194 |
"
|
|
195 |
self new testProcess1
|
|
196 |
"
|
|
197 |
!
|
|
198 |
|
|
199 |
testProcess2
|
100
|
200 |
|x set lockSet p|
|
|
201 |
|
|
202 |
lockSet := Semaphore forMutualExclusion.
|
|
203 |
set := Set new.
|
|
204 |
|
|
205 |
x := 1 @ 1.
|
|
206 |
|
|
207 |
p := [:arg |
|
|
208 |
[
|
|
209 |
lockSet critical:[set add:arg].
|
102
|
210 |
arg perform:#x.
|
100
|
211 |
] valueNowOrOnUnwindDo:[
|
|
212 |
lockSet critical:[set remove:arg].
|
|
213 |
].
|
|
214 |
] forkWith:(Array with:x).
|
|
215 |
|
|
216 |
"
|
101
|
217 |
self new testProcess2
|
100
|
218 |
"
|
102
|
219 |
!
|
|
220 |
|
|
221 |
testProcess3
|
|
222 |
|x set lockSet p|
|
|
223 |
|
|
224 |
lockSet := Semaphore forMutualExclusion.
|
|
225 |
set := Set new.
|
|
226 |
|
|
227 |
x := 1 @ 1.
|
|
228 |
|
|
229 |
p := [:arg |
|
|
230 |
[
|
|
231 |
lockSet critical:[set add:arg].
|
|
232 |
arg perform:#x: with:1234.
|
|
233 |
] valueNowOrOnUnwindDo:[
|
|
234 |
lockSet critical:[set remove:arg].
|
|
235 |
].
|
|
236 |
] forkWith:(Array with:x).
|
|
237 |
|
|
238 |
"
|
|
239 |
self new testProcess3
|
|
240 |
"
|
147
|
241 |
!
|
|
242 |
|
|
243 |
testUnwind1
|
|
244 |
Transcript showCR:'1'.
|
|
245 |
self downToNextSegmentThenDo:[Transcript showCR:'2'. ^ self ].
|
|
246 |
Transcript showCR:'3'.
|
|
247 |
|
|
248 |
"
|
|
249 |
self new testUnwind1
|
|
250 |
"
|
|
251 |
!
|
|
252 |
|
|
253 |
testUnwind2
|
|
254 |
Transcript showCR:'1'.
|
|
255 |
self downToNextSegmentThenUnwindAndDo:[Transcript showCR:'2'. ^ self ].
|
|
256 |
Transcript showCR:'3'.
|
|
257 |
|
|
258 |
"
|
|
259 |
self new testUnwind2
|
|
260 |
"
|
|
261 |
!
|
|
262 |
|
|
263 |
testUnwind3
|
|
264 |
<context: #return>
|
|
265 |
|
|
266 |
|foo|
|
|
267 |
|
|
268 |
Transcript showCR:'1'.
|
|
269 |
self downToNextSegmentThenUnwindAndDo:[Transcript showCR:'2'. foo := #foo ].
|
|
270 |
Transcript showCR:'3'.
|
|
271 |
|
|
272 |
"
|
|
273 |
self new testUnwind3
|
|
274 |
"
|
|
275 |
!
|
|
276 |
|
|
277 |
testUnwind4
|
|
278 |
|foo|
|
|
279 |
|
|
280 |
Transcript showCR:'1'.
|
|
281 |
self downToNextSegmentThenDo:[Transcript showCR:'2'. foo := #foo ].
|
|
282 |
Transcript showCR:'3'.
|
|
283 |
|
|
284 |
"
|
|
285 |
self new testUnwind4
|
|
286 |
"
|
100
|
287 |
! !
|
|
288 |
|
|
289 |
!ContextTest2 class methodsFor:'documentation'!
|
|
290 |
|
|
291 |
version
|
|
292 |
^ '$Header$'
|
|
293 |
! !
|