1445
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2003 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
1266
|
13 |
"{ Package: 'stx:libbasic3' }"
|
|
14 |
|
|
15 |
"{ NameSpace: Packages }"
|
|
16 |
|
|
17 |
AbstractTestCases subclass:#PackageSmalltalkManipulationTestCases
|
|
18 |
instanceVariableNames:'packageManager defaultPackage'
|
|
19 |
classVariableNames:''
|
|
20 |
poolDictionaries:''
|
|
21 |
category:'Package'
|
|
22 |
!
|
|
23 |
|
1445
|
24 |
!PackageSmalltalkManipulationTestCases class methodsFor:'documentation'!
|
|
25 |
|
|
26 |
copyright
|
|
27 |
"
|
|
28 |
COPYRIGHT (c) 2003 by eXept Software AG
|
|
29 |
All Rights Reserved
|
|
30 |
|
|
31 |
This software is furnished under a license and may be used
|
|
32 |
only in accordance with the terms of that license and with the
|
|
33 |
inclusion of the above copyright notice. This software may not
|
|
34 |
be provided or otherwise made available to, or used by, any
|
|
35 |
other person. No title to or ownership of the software is
|
|
36 |
hereby transferred.
|
|
37 |
"
|
|
38 |
! !
|
1266
|
39 |
|
|
40 |
!PackageSmalltalkManipulationTestCases methodsFor:'initialize / release'!
|
|
41 |
|
|
42 |
initialize
|
|
43 |
|
|
44 |
packageManager ifNil:[
|
|
45 |
packageManager := self packageManager.
|
|
46 |
].
|
|
47 |
|
|
48 |
defaultPackage ifNil:[
|
|
49 |
defaultPackage := packageManager defaultPackage.
|
|
50 |
].
|
|
51 |
!
|
|
52 |
|
|
53 |
setUp
|
|
54 |
"common setup - invoked before testing"
|
1273
|
55 |
super setUp.
|
1266
|
56 |
self setUpUsedClasses.
|
|
57 |
!
|
|
58 |
|
|
59 |
setUpAllForQWERTY
|
|
60 |
| class copyQWERTYDic|
|
|
61 |
|
|
62 |
(class := Smalltalk at:#QWERTY) ifNil:[
|
|
63 |
self createClassNamed:#QWERTY.
|
|
64 |
(class := Smalltalk at:#QWERTY).
|
|
65 |
].
|
|
66 |
|
|
67 |
(class compiledMethodAt:#aDummyMethod) ifNil:[
|
|
68 |
self createMethodFor:QWERTY source:'aDummyMethod 1 + 1.'.
|
|
69 |
].
|
|
70 |
(class compiledMethodAt:#aDummyMethod2) ifNil:[
|
|
71 |
self createMethodFor:QWERTY source:'aDummyMethod2 1 + 1.'.
|
|
72 |
].
|
|
73 |
(class compiledMethodAt:#aDummyMethod3) ifNil:[
|
|
74 |
self createMethodFor:QWERTY source:'aDummyMethod3 1 + 1.'.
|
|
75 |
].
|
|
76 |
copyQWERTYDic := QWERTY methodDictionary copy.
|
|
77 |
copyQWERTYDic removeKey:#aDummyMethod.
|
|
78 |
copyQWERTYDic removeKey:#aDummyMethod2.
|
|
79 |
copyQWERTYDic removeKey:#aDummyMethod3.
|
|
80 |
copyQWERTYDic keysAndValuesDo:[:key :value |
|
|
81 |
QWERTY methodDictionary removeKey:key.
|
|
82 |
].
|
|
83 |
|
|
84 |
packageManager moveClass:QWERTY toPackage:defaultPackage.
|
|
85 |
packageManager moveMethod:(class compiledMethodAt:#aDummyMethod) toPackage:defaultPackage.
|
|
86 |
packageManager moveMethod:(class compiledMethodAt:#aDummyMethod2) toPackage:defaultPackage.
|
|
87 |
packageManager moveMethod:(class compiledMethodAt:#aDummyMethod3) toPackage:defaultPackage.
|
|
88 |
!
|
|
89 |
|
|
90 |
setUpAllForQWERTZ
|
|
91 |
| class copyQWERTZDic|
|
|
92 |
(class := Smalltalk at:#QWERTZ) ifNil:[
|
|
93 |
self createClassNamed:#QWERTZ.
|
|
94 |
(class := Smalltalk at:#QWERTZ)
|
|
95 |
].
|
|
96 |
|
|
97 |
(class compiledMethodAt:#aDummyMethod) ifNil:[
|
|
98 |
self createMethodFor:QWERTZ source:'aDummyMethod 1 + 1.'.
|
|
99 |
].
|
|
100 |
(class compiledMethodAt:#aDummyMethod2) ifNil:[
|
|
101 |
self createMethodFor:QWERTZ source:'aDummyMethod2 1 + 1.'.
|
|
102 |
].
|
|
103 |
(class compiledMethodAt:#aDummyMethod3) ifNil:[
|
|
104 |
self createMethodFor:QWERTZ source:'aDummyMethod3 1 + 1.'.
|
|
105 |
].
|
|
106 |
|
|
107 |
copyQWERTZDic := QWERTZ methodDictionary copy.
|
|
108 |
copyQWERTZDic removeKey:#aDummyMethod.
|
|
109 |
copyQWERTZDic removeKey:#aDummyMethod2.
|
|
110 |
copyQWERTZDic removeKey:#aDummyMethod3.
|
|
111 |
copyQWERTZDic keysAndValuesDo:[:key :value |
|
|
112 |
QWERTZ methodDictionary removeKey:key.
|
|
113 |
].
|
|
114 |
|
|
115 |
packageManager moveClass:QWERTZ toPackage:defaultPackage.
|
|
116 |
packageManager moveMethod:(class compiledMethodAt:#aDummyMethod) toPackage:defaultPackage.
|
|
117 |
packageManager moveMethod:(class compiledMethodAt:#aDummyMethod2) toPackage:defaultPackage.
|
|
118 |
packageManager moveMethod:(class compiledMethodAt:#aDummyMethod3) toPackage:defaultPackage.
|
|
119 |
!
|
|
120 |
|
|
121 |
setUpUsedClasses
|
|
122 |
"common setup - invoked before testing"
|
|
123 |
| |
|
|
124 |
self setUpAllForQWERTZ.
|
|
125 |
self setUpAllForQWERTY.
|
|
126 |
!
|
|
127 |
|
|
128 |
tearDown
|
|
129 |
"common cleanup - invoked after testing"
|
|
130 |
|
|
131 |
"move class package to where it was"
|
|
132 |
super tearDown
|
|
133 |
! !
|
|
134 |
|
|
135 |
!PackageSmalltalkManipulationTestCases methodsFor:'test - creation'!
|
|
136 |
|
|
137 |
testClassCreation
|
|
138 |
"tests that new classes are automatically included in workingPackage"
|
|
139 |
| packagedClass |
|
|
140 |
[
|
1276
|
141 |
"prerequisites"
|
|
142 |
self assert:(Smalltalk classNamed:#QWERTZ2) isNil.
|
|
143 |
|
1266
|
144 |
self createClassNamed:#QWERTZ2.
|
|
145 |
self assert:(packageManager workingPackage includesPackagedClassNamed:#QWERTZ2).
|
|
146 |
packagedClass := (packageManager workingPackage packagedClassNamed:#QWERTZ2).
|
|
147 |
self assert:(packagedClass isInSmalltalk)
|
|
148 |
] ensure:[
|
|
149 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
150 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
151 |
].
|
|
152 |
self assert:(defaultPackage includesPackagedClassNamed:#QWERTZ2).
|
|
153 |
self shouldnt:(packagedClass isInSmalltalk).
|
|
154 |
packagedClass removeFromPackage.
|
|
155 |
|
|
156 |
self shouldnt:(defaultPackage includesPackagedClassNamed:#QWERTZ2).
|
|
157 |
]
|
|
158 |
!
|
|
159 |
|
|
160 |
testClassCreation2
|
|
161 |
"tests that new classes are automatically included in workingPackage"
|
|
162 |
| packagedClass packageTestCases |
|
|
163 |
[
|
1283
|
164 |
self shouldnt:(packageManager workingPackage includesPackagedClassNamed:#QWERTZ2).
|
|
165 |
|
1266
|
166 |
packageTestCases := packageManager newPackageNamed:#'packageTestCases'.
|
|
167 |
packageManager workingPackage:packageTestCases.
|
|
168 |
self createClassNamed:#QWERTZ2.
|
|
169 |
self assert:(QWERTZ2 package == packageManager workingPackage name).
|
|
170 |
|
|
171 |
|
|
172 |
self assert:(packageTestCases includesPackagedClassNamed:#QWERTZ2).
|
|
173 |
packagedClass := (packageTestCases packagedClassNamed:#QWERTZ2).
|
|
174 |
self assert:(packagedClass isInSmalltalk)
|
|
175 |
] ensure:[
|
|
176 |
packageTestCases ifNotNil:[
|
|
177 |
packageManager removePackageNamed:#'packageTestCases'.
|
|
178 |
].
|
|
179 |
|
|
180 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
181 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
182 |
].
|
|
183 |
|
|
184 |
packageManager workingPackage:defaultPackage.
|
|
185 |
self shouldnt:(packageManager workingPackage includesPackagedClassNamed:#QWERTZ2).
|
|
186 |
]
|
|
187 |
|
|
188 |
!
|
|
189 |
|
|
190 |
testClassRedefine
|
|
191 |
"tests that new classes are automatically included in workingPackage"
|
|
192 |
| packagedClass packageTestCases workingPackage newPackage |
|
|
193 |
[
|
|
194 |
packageTestCases := packageManager newPackageNamed:#'packageTestCases'.
|
|
195 |
workingPackage := packageManager workingPackage.
|
|
196 |
self createClassNamed:#QWERTZ2.
|
|
197 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation 1 + 1'.
|
|
198 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation 1 + 1'.
|
|
199 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation 1 + 1'.
|
|
200 |
self assert:(QWERTZ2 package == packageManager workingPackage name).
|
|
201 |
|
|
202 |
packageManager moveClass:QWERTZ2 toPackage:packageTestCases.
|
|
203 |
self assert:(packageTestCases includesPackagedClassNamed:#QWERTZ2).
|
|
204 |
packagedClass := (packageTestCases packagedClassNamed:#QWERTZ2).
|
|
205 |
self assert:(packagedClass isInSmalltalk).
|
|
206 |
|
|
207 |
self shouldnt:(workingPackage includesPackagedClassNamed:#QWERTZ2).
|
|
208 |
|
|
209 |
self createClassNamed:#QWERTZ2 inheritsFrom:#Collection.
|
|
210 |
newPackage := packageManager packageNamed:QWERTZ2 package.
|
|
211 |
|
|
212 |
self assert:(newPackage includesPackagedClassNamed:#QWERTZ2).
|
|
213 |
packagedClass := (newPackage packagedClassNamed:#QWERTZ2).
|
|
214 |
self assert:(packagedClass isInSmalltalk).
|
|
215 |
|
|
216 |
workingPackage ~= newPackage ifTrue:[
|
|
217 |
self shouldnt:(workingPackage includesPackagedClassNamed:#QWERTZ2).
|
|
218 |
].
|
|
219 |
|
|
220 |
|
|
221 |
packageManager moveClass:QWERTZ2 toPackage:packageTestCases.
|
|
222 |
] ensure:[
|
|
223 |
packageManager unloadPackageNamed:#'packageTestCases'.
|
1276
|
224 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
225 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
1266
|
226 |
].
|
|
227 |
]
|
|
228 |
!
|
|
229 |
|
|
230 |
testMethodCreation
|
|
231 |
"tests that new methods are automatically included in workingPackage"
|
|
232 |
self createMethodFor:QWERTZ source:'testBasicMethodCreation 1 + 1'.
|
|
233 |
self assert:(packageManager workingPackage definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ)
|
|
234 |
!
|
|
235 |
|
|
236 |
testMethodRedefine
|
|
237 |
"tests that redefined are automatically included in workingPackage when they are added to
|
|
238 |
another package"
|
|
239 |
| package1 method1 packageClassIsIn packageMethodIsIn |
|
|
240 |
[
|
|
241 |
package1 := packageManager newPackageNamed:#'package1'.
|
|
242 |
|
|
243 |
self createClassNamed:#QWERTZ2.
|
|
244 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation 1 + 1'.
|
|
245 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
246 |
|
|
247 |
packageClassIsIn := packageManager packageNamed:QWERTZ2 package.
|
|
248 |
packageMethodIsIn := packageManager packageNamed:method1 package.
|
|
249 |
|
|
250 |
self assert:(packageMethodIsIn definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
251 |
self assert:(packageMethodIsIn isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
252 |
|
|
253 |
packageManager addMethod:method1 toPackage:package1.
|
|
254 |
self assert:(package1 definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
255 |
self assert:(package1 isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
256 |
|
|
257 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation 1 + 1'.
|
|
258 |
|
|
259 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
260 |
packageMethodIsIn := packageManager packageNamed:method1 package.
|
|
261 |
|
|
262 |
self assert:(packageMethodIsIn definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
263 |
self assert:(packageMethodIsIn isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
264 |
"sometimes the #keep is done automatically. #keep meaning when a method is created a signal is asked for
|
|
265 |
and if not returned the method is either keep in the current project OR put into another one OR put into
|
|
266 |
the working package"
|
|
267 |
package1 ~= packageMethodIsIn ifTrue:[
|
|
268 |
self assert:(package1 definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
269 |
self shouldnt:(package1 isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
270 |
].
|
|
271 |
|
|
272 |
] ensure:[
|
|
273 |
packageManager unloadPackageNamed:#'package1'.
|
1276
|
274 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
275 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
276 |
].
|
1266
|
277 |
]
|
|
278 |
!
|
|
279 |
|
|
280 |
testMethodRedefine2
|
|
281 |
"tests that redefined are automatically included in workingPackage when they are moved to
|
|
282 |
another package"
|
|
283 |
| package1 method1 packageClassIsIn packageMethodIsIn |
|
|
284 |
[
|
|
285 |
package1 := packageManager newPackageNamed:#'package1'.
|
|
286 |
|
|
287 |
self createClassNamed:#QWERTZ2.
|
|
288 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation 1 + 1'.
|
|
289 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
290 |
packageClassIsIn := packageManager packageNamed:QWERTZ2 package.
|
|
291 |
packageMethodIsIn := packageManager packageNamed:method1 package.
|
|
292 |
|
|
293 |
self assert:(packageMethodIsIn definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
294 |
self assert:(packageMethodIsIn isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
295 |
|
|
296 |
packageManager moveMethod:method1 toPackage:package1.
|
|
297 |
self assert:(package1 definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
298 |
self assert:(package1 isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
299 |
|
|
300 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation 1 + 1'.
|
|
301 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
302 |
packageMethodIsIn := packageManager packageNamed:method1 package.
|
|
303 |
|
|
304 |
self assert:(packageMethodIsIn definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
305 |
self assert:(packageMethodIsIn isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
306 |
package1 ~= packageMethodIsIn ifTrue:[
|
|
307 |
self assert:(package1 definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
308 |
self shouldnt:(package1 isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
309 |
].
|
|
310 |
|
|
311 |
] ensure:[
|
|
312 |
packageManager unloadPackageNamed:#'package1'.
|
1276
|
313 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
314 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
315 |
].
|
1266
|
316 |
]
|
|
317 |
!
|
|
318 |
|
|
319 |
testMethodRedefine3_cancel
|
|
320 |
"tests that redefined methods that want to be kept in the cuurent package do so!!
|
|
321 |
"
|
|
322 |
| package1 method1 method2 packageClassIsIn packageMethodIsIn packageMethodWasIn |
|
|
323 |
[
|
|
324 |
package1 := packageManager newPackageNamed:#'package1'.
|
|
325 |
self createClassNamed:#QWERTZ2.
|
|
326 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation 1 + 1'.
|
|
327 |
|
|
328 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
329 |
|
|
330 |
packageClassIsIn := packageManager packageNamed:QWERTZ2 package.
|
|
331 |
packageMethodIsIn := packageManager packageNamed:method1 package.
|
|
332 |
|
|
333 |
|
|
334 |
self assert:(packageMethodIsIn definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
335 |
self assert:(packageMethodIsIn isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
336 |
|
|
337 |
packageManager moveMethod:method1 toPackage:package1.
|
|
338 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
339 |
|
|
340 |
packageMethodIsIn := packageManager packageNamed:method1 package.
|
|
341 |
self assert:(packageMethodIsIn definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
342 |
self assert:(packageMethodIsIn isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
343 |
|
|
344 |
packageMethodWasIn := packageMethodIsIn.
|
|
345 |
|
|
346 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
1273
|
347 |
(Class methodRedefinitionSignal) handle:[:ex |
|
1266
|
348 |
ex proceedWith:#cancel
|
|
349 |
] do:[
|
|
350 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation 1 + 1'.
|
|
351 |
method2 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
352 |
].
|
|
353 |
|
1273
|
354 |
self shouldnt:(method2 package = method1 package).
|
1266
|
355 |
|
|
356 |
] ensure:[
|
|
357 |
packageManager unloadPackageNamed:#'package1'.
|
1276
|
358 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
359 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
360 |
].
|
1266
|
361 |
]
|
|
362 |
!
|
|
363 |
|
|
364 |
testMethodRedefine3_continue
|
|
365 |
"tests that redefined methods that want to be kept in the cuurent package do so!!
|
|
366 |
"
|
|
367 |
| package1 method1 packageClassIsIn packageMethodIsIn packageMethodWasIn |
|
|
368 |
[
|
|
369 |
package1 := packageManager newPackageNamed:#'package1'.
|
|
370 |
self createClassNamed:#QWERTZ2.
|
|
371 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation 1 + 1'.
|
|
372 |
|
|
373 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
374 |
|
|
375 |
packageClassIsIn := packageManager packageNamed:QWERTZ2 package.
|
|
376 |
packageMethodIsIn := packageManager packageNamed:method1 package.
|
|
377 |
|
|
378 |
|
|
379 |
self assert:(packageMethodIsIn definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
380 |
self assert:(packageMethodIsIn isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
381 |
|
|
382 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
383 |
packageManager moveMethod:method1 toPackage:package1.
|
|
384 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
385 |
|
|
386 |
packageMethodIsIn := packageManager packageNamed:method1 package.
|
|
387 |
self assert:(packageMethodIsIn definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
388 |
self assert:(packageMethodIsIn isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
389 |
|
|
390 |
packageMethodWasIn := packageMethodIsIn.
|
|
391 |
|
|
392 |
(Class methodRedefinitionSignal) handle:[:ex |
|
|
393 |
ex proceedWith:#continue
|
|
394 |
] do:[
|
|
395 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation 1 + 1'.
|
|
396 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
397 |
].
|
|
398 |
|
|
399 |
packageMethodIsIn := packageManager packageNamed:method1 package.
|
|
400 |
self assert:(packageMethodIsIn definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
401 |
self assert:(packageMethodIsIn isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
402 |
|
|
403 |
packageMethodWasIn ~= packageMethodIsIn ifTrue:[
|
|
404 |
self assert:(packageMethodIsIn definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
405 |
self shouldnt:(packageMethodWasIn isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
406 |
].
|
|
407 |
|
|
408 |
] ensure:[
|
|
409 |
packageManager unloadPackageNamed:#'package1'.
|
1276
|
410 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
411 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
412 |
].
|
1266
|
413 |
]
|
|
414 |
!
|
|
415 |
|
|
416 |
testMethodRedefine3_keep
|
|
417 |
"tests that redefined methods that want to be kept in the cuurent package do so!!
|
|
418 |
"
|
|
419 |
| package1 method1 packageClassIsIn packageMethodIsIn packageMethodWasIn |
|
|
420 |
[
|
|
421 |
package1 := packageManager newPackageNamed:#'package1'.
|
|
422 |
self createClassNamed:#QWERTZ2.
|
|
423 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation 1 + 1'.
|
|
424 |
|
|
425 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
426 |
|
|
427 |
packageClassIsIn := packageManager packageNamed:QWERTZ2 package.
|
|
428 |
packageMethodIsIn := packageManager packageNamed:method1 package.
|
|
429 |
|
|
430 |
|
|
431 |
self assert:(packageMethodIsIn definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
432 |
self assert:(packageMethodIsIn isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
433 |
|
|
434 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
435 |
packageManager moveMethod:method1 toPackage:package1.
|
|
436 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
437 |
|
|
438 |
packageMethodIsIn := packageManager packageNamed:method1 package.
|
|
439 |
self assert:(packageMethodIsIn definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
440 |
self assert:(packageMethodIsIn isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
441 |
|
|
442 |
packageMethodWasIn := packageMethodIsIn.
|
|
443 |
|
|
444 |
(Class methodRedefinitionSignal) handle:[:ex |
|
|
445 |
ex proceedWith:#keep
|
|
446 |
] do:[
|
|
447 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation 1 + 1'.
|
|
448 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
449 |
].
|
|
450 |
|
|
451 |
packageMethodIsIn := packageManager packageNamed:method1 package.
|
|
452 |
self assert:(packageMethodIsIn definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
453 |
self assert:(packageMethodIsIn isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
454 |
|
|
455 |
packageMethodWasIn ~= packageMethodIsIn ifTrue:[
|
|
456 |
self assert:(packageMethodIsIn definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
457 |
self shouldnt:(packageMethodWasIn isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
458 |
].
|
|
459 |
|
|
460 |
] ensure:[
|
|
461 |
packageManager unloadPackageNamed:#'package1'.
|
1276
|
462 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
463 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
464 |
].
|
1266
|
465 |
]
|
|
466 |
! !
|
|
467 |
|
1277
|
468 |
!PackageSmalltalkManipulationTestCases methodsFor:'test - fileIn type'!
|
|
469 |
|
|
470 |
testMethod_FileIn
|
|
471 |
"I can across an error in the GUI builder when it tried to recompile a method on the class side!!
|
|
472 |
it decided to change the package of the old class confusing the package completely!!
|
|
473 |
"
|
|
474 |
| package1 method1 packageClassIsIn packageMethodIsIn |
|
|
475 |
[
|
|
476 |
package1 := packageManager newPackageNamed:#'package1'.
|
|
477 |
|
|
478 |
self createClassNamed:#QWERTZ2.
|
|
479 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation 1 + 1'.
|
|
480 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
481 |
|
|
482 |
packageClassIsIn := packageManager packageNamed:QWERTZ2 package.
|
|
483 |
packageMethodIsIn := packageManager packageNamed:method1 package.
|
|
484 |
|
|
485 |
self assert:(packageMethodIsIn definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
486 |
self assert:(packageMethodIsIn isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
487 |
|
|
488 |
packageManager addMethod:method1 toPackage:package1.
|
|
489 |
self assert:(package1 definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
490 |
self assert:(package1 isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
491 |
|
|
492 |
" The test!!!!!! "
|
|
493 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation 1 + 1'.
|
|
494 |
|
|
495 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
496 |
packageMethodIsIn := packageManager packageNamed:method1 package.
|
|
497 |
|
|
498 |
self assert:(packageMethodIsIn definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
499 |
self assert:(packageMethodIsIn isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
500 |
"sometimes the #keep is done automatically. #keep meaning when a method is created a signal is asked for
|
|
501 |
and if not returned the method is either keep in the current project OR put into another one OR put into
|
|
502 |
the working package"
|
|
503 |
package1 ~= packageMethodIsIn ifTrue:[
|
|
504 |
self assert:(package1 definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
505 |
self shouldnt:(package1 isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
506 |
].
|
|
507 |
|
|
508 |
] ensure:[
|
|
509 |
packageManager unloadPackageNamed:#'package1'.
|
|
510 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
511 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
512 |
].
|
|
513 |
]
|
|
514 |
! !
|
|
515 |
|
1266
|
516 |
!PackageSmalltalkManipulationTestCases methodsFor:'test - moving'!
|
|
517 |
|
|
518 |
obsolete_test_moveClass1
|
|
519 |
"moving classes via change notification is now deprecated as i found it best to try and seperate
|
|
520 |
the functionality on Smalltalk and the functionality of package handling.
|
|
521 |
"
|
|
522 |
"Move QWERTZ class from package1 to package 2. Then move the class back."
|
|
523 |
| package1 package2 aName |
|
|
524 |
[
|
|
525 |
package1 := packageManager newPackageNamed:#'package1'.
|
|
526 |
package2 := packageManager newPackageNamed:#'package2'.
|
|
527 |
|
|
528 |
packageManager addClass:QWERTZ toPackage:package1.
|
|
529 |
|
|
530 |
self assert:(package1 includesPackagedClassNamed:#QWERTZ).
|
|
531 |
self shouldnt:(package2 includesPackagedClassNamed:#QWERTZ).
|
|
532 |
|
|
533 |
self assert:(package1 isDirty).
|
|
534 |
self shouldnt:(package2 isDirty).
|
|
535 |
|
|
536 |
"<simulatedChangeInBrowser>"
|
|
537 |
"This change always moves the class away from the classes current owner"
|
|
538 |
self assert:(aName := QWERTZ package) == package1 name.
|
|
539 |
QWERTZ setPackage:package2 name.
|
|
540 |
ChangeFaker classMovePackageChangeWithClass:QWERTZ oldPackageName:aName.
|
|
541 |
"</simulatedChangeInBrowser>"
|
|
542 |
self assert:(package2 includesPackagedClassNamed:#QWERTZ).
|
|
543 |
self assert:(package1 includesPackagedClassNamed:#QWERTZ).
|
|
544 |
self assert:(package2 packagedClassNamed:#QWERTZ) isInSmalltalk.
|
|
545 |
self shouldnt:(package1 packagedClassNamed:#QWERTZ) isInSmalltalk.
|
|
546 |
self assert:(package2 isDependentOnClassNamed:#QWERTZ).
|
|
547 |
self shouldnt:(package1 isDependentOnClassNamed:#QWERTZ).
|
|
548 |
|
|
549 |
self assert:(package2 isDirty).
|
|
550 |
self assert:(package1 isDirty).
|
|
551 |
|
|
552 |
"<simulatedChangeInBrowser>"
|
|
553 |
self assert:(aName := QWERTZ package) == package2 name.
|
|
554 |
QWERTZ setPackage:package1 name.
|
|
555 |
ChangeFaker classMovePackageChangeWithClass:QWERTZ oldPackageName:aName.
|
|
556 |
"</simulatedChangeInBrowser>"
|
|
557 |
self shouldnt:(package2 isDependentOnClassNamed:#QWERTZ).
|
|
558 |
self assert:(package1 isDependentOnClassNamed:#QWERTZ).
|
|
559 |
|
|
560 |
self assert:(package1 packagedClassNamed:#QWERTZ) isInSmalltalk.
|
|
561 |
self assert:(package2 isDirty).
|
|
562 |
self assert:(package1 isDirty).
|
|
563 |
self assert:((package1 blockedMethodsAtClassNamed:#QWERTZ) size == 0).
|
|
564 |
packageManager addClass:QWERTZ toPackage:defaultPackage.
|
|
565 |
] ensure:[
|
|
566 |
packageManager unloadPackageNamed:#'package1'.
|
|
567 |
packageManager unloadPackageNamed:#'package2'.
|
|
568 |
].
|
|
569 |
!
|
|
570 |
|
|
571 |
obsolete_test_moveClass2
|
|
572 |
"moving classes via change notification is now deprecated as i found it best to try and seperate
|
|
573 |
the functionality on Smalltalk and the functionality of package handling.
|
|
574 |
"
|
|
575 |
"Move QWERTZ class to a new package named the same as the old package
|
|
576 |
but with a 1 on the end. Then move the class back."
|
|
577 |
| package1 package2 aName package3 |
|
|
578 |
[
|
|
579 |
package1 := packageManager newPackageNamed:#'package1'.
|
|
580 |
package2 := packageManager newPackageNamed:#'package2'.
|
|
581 |
package3 := packageManager newPackageNamed:#'package3'.
|
|
582 |
|
|
583 |
packageManager addClass:QWERTZ toPackage:package1.
|
|
584 |
packageManager addClass:QWERTZ toPackage:package2.
|
|
585 |
packageManager addClass:QWERTZ toPackage:package3.
|
|
586 |
|
|
587 |
self assert:(package1 includesPackagedClassNamed:#QWERTZ).
|
|
588 |
self assert:(package2 includesPackagedClassNamed:#QWERTZ).
|
|
589 |
self assert:(package3 includesPackagedClassNamed:#QWERTZ).
|
|
590 |
|
|
591 |
self shouldnt:(package1 packagedClassNamed:#QWERTZ) isInSmalltalk.
|
|
592 |
self shouldnt:(package2 packagedClassNamed:#QWERTZ) isInSmalltalk.
|
|
593 |
self assert:(package3 packagedClassNamed:#QWERTZ) isInSmalltalk.
|
|
594 |
|
|
595 |
self assert:(package1 isDirty).
|
|
596 |
self assert:(package2 isDirty).
|
|
597 |
self assert:(package3 isDirty).
|
|
598 |
|
|
599 |
"<simulatedChangeInBrowser>"
|
|
600 |
"This change always moves the class away from the classes current owner"
|
|
601 |
self assert:(aName := QWERTZ package) == package3 name.
|
|
602 |
QWERTZ setPackage:package2 name.
|
|
603 |
ChangeFaker classMovePackageChangeWithClass:QWERTZ oldPackageName:aName.
|
|
604 |
"</simulatedChangeInBrowser>"
|
|
605 |
self assert:(package2 includesPackagedClassNamed:#QWERTZ).
|
|
606 |
self assert:(package3 includesPackagedClassNamed:#QWERTZ).
|
|
607 |
|
|
608 |
self assert:(package2 packagedClassNamed:#QWERTZ) isInSmalltalk.
|
|
609 |
self shouldnt:(package3 packagedClassNamed:#QWERTZ) isInSmalltalk.
|
|
610 |
|
|
611 |
self assert:(package2 isDirty).
|
|
612 |
self assert:(package3 isDirty).
|
|
613 |
|
|
614 |
"<simulatedChangeInBrowser>"
|
|
615 |
self assert:(aName := QWERTZ package) == package2 name.
|
|
616 |
QWERTZ setPackage:package1 name.
|
|
617 |
ChangeFaker classMovePackageChangeWithClass:QWERTZ oldPackageName:aName.
|
|
618 |
"</simulatedChangeInBrowser>"
|
|
619 |
self assert:(package2 includesPackagedClassNamed:QWERTZ).
|
|
620 |
self assert:(package1 includesPackagedClassNamed:QWERTZ).
|
|
621 |
|
|
622 |
self assert:(package1 packagedClassNamed:#QWERTZ) isInSmalltalk.
|
|
623 |
self shouldnt:(package2 packagedClassNamed:#QWERTZ) isInSmalltalk.
|
|
624 |
|
|
625 |
self assert:(package3 isDirty).
|
|
626 |
self assert:(package2 isDirty).
|
|
627 |
self assert:(package1 isDirty).
|
|
628 |
|
|
629 |
] ensure:[
|
|
630 |
packageManager unloadPackageNamed:#'package1'.
|
|
631 |
packageManager unloadPackageNamed:#'package2'.
|
|
632 |
packageManager unloadPackageNamed:#'package3'.
|
|
633 |
].
|
|
634 |
!
|
|
635 |
|
|
636 |
test_moveClass1
|
|
637 |
"Move QWERTZ class from package1 to package 2. Then move the class back."
|
|
638 |
| package1 aName |
|
|
639 |
[
|
|
640 |
package1 := packageManager newPackageNamed:#'package1'.
|
|
641 |
|
|
642 |
|
|
643 |
"<simulatedChangeInBrowser>"
|
|
644 |
"This change always moves the class away from the classes current owner"
|
|
645 |
self assert:(aName := QWERTZ package) == defaultPackage name.
|
|
646 |
QWERTZ setPackage:package1 name.
|
|
647 |
self should:[ChangeFaker classMovePackageChangeWithClass:QWERTZ oldPackageName:aName] raise:Error.
|
|
648 |
"</simulatedChangeInBrowser>"
|
|
649 |
] ensure:[
|
|
650 |
packageManager unloadPackageNamed:#'package1'.
|
|
651 |
].
|
|
652 |
!
|
|
653 |
|
|
654 |
test_moveMethod1
|
|
655 |
"moving classes via change notification is now deprecated as i found it best to try and seperate
|
|
656 |
the functionality on Smalltalk and the functionality of package handling.
|
|
657 |
"
|
|
658 |
"Move QWERTZ class from package1 to package 2. Then move the class back."
|
|
659 |
| package1 aName theMethod methodOwnedClass|
|
|
660 |
[
|
|
661 |
package1 := packageManager newPackageNamed:#'package1'.
|
|
662 |
theMethod :=(QWERTZ compiledMethodAt:#'aDummyMethod').
|
|
663 |
methodOwnedClass := QWERTZ.
|
|
664 |
|
|
665 |
"<simulatedChangeInBrowser>"
|
|
666 |
"This change always moves the method away from the classes current owner"
|
|
667 |
self assert:(aName := theMethod package) == defaultPackage name.
|
|
668 |
theMethod setPackage:package1 name.
|
|
669 |
self should:[ChangeFaker methodMovePackageChangeWithMethod:theMethod class:methodOwnedClass oldPackageName:aName.]
|
|
670 |
raise:Error.
|
|
671 |
"</simulatedChangeInBrowser>"
|
|
672 |
] ensure:[
|
|
673 |
packageManager unloadPackageNamed:#'package1'.
|
|
674 |
].
|
|
675 |
! !
|
|
676 |
|
|
677 |
!PackageSmalltalkManipulationTestCases methodsFor:'test - removing'!
|
|
678 |
|
|
679 |
testClassRemove
|
|
680 |
"Changes caught my the manager should not affect the packages state.
|
|
681 |
So a class removal should remove the class in Smalltalk yet the package should still keep hold of the
|
|
682 |
entire definition INCLUDING the methods it requires!!"
|
|
683 |
| packagedClass packageTestCases|
|
|
684 |
[
|
|
685 |
packageTestCases := packageManager newPackageNamed:#'packageTestCases'.
|
|
686 |
packageManager workingPackage:packageTestCases.
|
|
687 |
|
|
688 |
self createClassNamed:#QWERTZ2.
|
|
689 |
|
|
690 |
self assert:(packageManager workingPackage includesPackagedClassNamed:#QWERTZ2).
|
|
691 |
packagedClass := (packageManager workingPackage packagedClassNamed:#QWERTZ2).
|
|
692 |
self assert:(packagedClass isInSmalltalk).
|
|
693 |
|
|
694 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
695 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
696 |
].
|
|
697 |
|
|
698 |
self shouldnt:(packagedClass isInSmalltalk).
|
|
699 |
self assert:(packageManager workingPackage includesPackagedClassNamed:#QWERTZ2).
|
|
700 |
|
|
701 |
|
|
702 |
] ensure:[
|
|
703 |
packageManager unloadPackageNamed:#'packageTestCases'.
|
1276
|
704 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
705 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
706 |
].
|
1266
|
707 |
]
|
|
708 |
!
|
|
709 |
|
|
710 |
testClassRemove2
|
|
711 |
"Changes caught my the manager should not affect the packages state.
|
|
712 |
So a class removal should remove the class in Smalltalk yet the package should still keep hold of the
|
|
713 |
entire definition INCLUDING the methods it requires!!"
|
|
714 |
"This one tests if the methods are still kept within the pacakge as packagedMethods"
|
|
715 |
"WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! DONT correct during the debugger otherwise changes made could be removed!!!!!!"
|
|
716 |
| packagedClass packageTestCases packagedMethod |
|
|
717 |
[
|
|
718 |
packageTestCases := packageManager newPackageNamed:#'packageTestCases'.
|
|
719 |
packageManager workingPackage:packageTestCases.
|
|
720 |
|
|
721 |
self createClassNamed:#QWERTZ2.
|
|
722 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation 1 + 1'.
|
|
723 |
|
|
724 |
self assert:(packageTestCases includesPackagedClassNamed:#QWERTZ2).
|
|
725 |
self assert:(packageTestCases definesSelector:#'testBasicMethodCreation' forClassNamed:#QWERTZ2).
|
|
726 |
packagedClass := (packageTestCases packagedClassNamed:#QWERTZ2).
|
|
727 |
self assert:(packagedClass isInSmalltalk).
|
|
728 |
|
|
729 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
730 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
731 |
].
|
|
732 |
"test that the CLASS is removed from Smalltalk BUT the package still retains it!!"
|
|
733 |
self assert:(packageTestCases includesPackagedClassNamed:#QWERTZ2).
|
|
734 |
self assert:(packageTestCases definesSelector:#'testBasicMethodCreation' forClassNamed:#QWERTZ2).
|
|
735 |
self shouldnt:(packagedClass isInSmalltalk).
|
|
736 |
|
|
737 |
"test that the METHOD is removed from Smalltalk BUT the package still retains it!!"
|
|
738 |
packagedMethod := (packageTestCases packagedMethodNamed:#'testBasicMethodCreation' forClassNamed:#QWERTZ2).
|
|
739 |
self assert:(packagedMethod notNil).
|
|
740 |
self shouldnt:(packagedMethod isInSmalltalk).
|
|
741 |
|
|
742 |
|
|
743 |
] ensure:[
|
|
744 |
packageManager workingPackage:packageManager defaultPackage.
|
|
745 |
packageManager unloadPackageNamed:#'packageTestCases'.
|
1276
|
746 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
747 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
748 |
].
|
1266
|
749 |
]
|
|
750 |
!
|
|
751 |
|
|
752 |
testClassRemove3
|
|
753 |
"Changes caught my the manager should not affect the packages state.
|
|
754 |
So a class removal should remove the class in Smalltalk yet the package should still keep hold of the
|
|
755 |
entire definition INCLUDING the methods it requires!!"
|
|
756 |
"This one tests if the methods are still kept within the pacakge as packagedMethods"
|
|
757 |
"WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! DONT correct during the debugger otherwise changes made could be removed!!!!!!"
|
|
758 |
| packagedClass package1 package2 packagedMethod1 packagedMethod2 method1 method2 |
|
|
759 |
[
|
|
760 |
package1 := packageManager newPackageNamed:#'package1'.
|
|
761 |
package2 := packageManager newPackageNamed:#'package2'.
|
|
762 |
|
|
763 |
self createClassNamed:#QWERTZ2.
|
|
764 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation 1 + 1'.
|
|
765 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation2 1 + 1'.
|
|
766 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
767 |
method2 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation2.
|
|
768 |
|
|
769 |
packageManager moveClass:QWERTZ2 toPackage:package1.
|
|
770 |
"This blocks method2 from package1"
|
|
771 |
packageManager moveMethod:method2 toPackage:package2.
|
|
772 |
|
|
773 |
self assert:(package1 includesPackagedClassNamed:#QWERTZ2).
|
|
774 |
"package1 stores method2 as blocked"
|
|
775 |
self shouldnt:(package1 definesSelector:method2 name forClassNamed:#QWERTZ2).
|
|
776 |
|
|
777 |
packagedClass := (package1 packagedClassNamed:#QWERTZ2).
|
|
778 |
self assert:packagedClass notNil.
|
|
779 |
self assert:(packagedClass isInSmalltalk).
|
|
780 |
|
|
781 |
"Package2 should NOT define the class QWERTZ2 but should define method2 which should also be in Smalltalk!!"
|
|
782 |
self shouldnt:(package2 includesPackagedClassNamed:#QWERTZ2).
|
|
783 |
self assert:(package2 definesSelector:method2 name forClassNamed:#QWERTZ2).
|
|
784 |
packagedMethod2 := (package2 packagedMethodNamed:method2 name forClassNamed:#QWERTZ2).
|
|
785 |
self assert:(packagedMethod2 isInSmalltalk).
|
|
786 |
|
|
787 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
788 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
789 |
].
|
|
790 |
"test that the CLASS is removed from Smalltalk BUT the package1 still retains it!!"
|
|
791 |
self assert:(package1 includesPackagedClassNamed:#QWERTZ2).
|
|
792 |
self assert:(package1 definesSelector:#'testBasicMethodCreation' forClassNamed:#QWERTZ2).
|
|
793 |
self shouldnt:(packagedClass isInSmalltalk).
|
|
794 |
|
|
795 |
"test that the METHOD is removed from Smalltalk BUT the package1 still retains it!!"
|
|
796 |
self assert:(package1 definesSelector:method1 name forClassNamed:#QWERTZ2).
|
|
797 |
packagedMethod1 := (package1 packagedMethodNamed:method1 name forClassNamed:#QWERTZ2).
|
|
798 |
self assert:(packagedMethod1 notNil).
|
|
799 |
self shouldnt:(packagedMethod1 isInSmalltalk).
|
|
800 |
|
|
801 |
"test that the METHOD is removed from Smalltalk BUT the package2 still retains it!!"
|
|
802 |
self assert:(package2 definesSelector:method2 name forClassNamed:#QWERTZ2).
|
|
803 |
packagedMethod2 := (package2 packagedMethodNamed:method2 name forClassNamed:#QWERTZ2).
|
|
804 |
self assert:(packagedMethod2 notNil).
|
|
805 |
self shouldnt:(packagedMethod2 isInSmalltalk).
|
|
806 |
|
|
807 |
|
|
808 |
] ensure:[
|
|
809 |
packageManager unloadPackageNamed:#'package1'.
|
|
810 |
packageManager unloadPackageNamed:#'package2'.
|
1276
|
811 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
812 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
813 |
].
|
1266
|
814 |
]
|
|
815 |
!
|
|
816 |
|
|
817 |
testClassRemove4
|
|
818 |
"Changes caught my the manager should not affect the packages state.
|
|
819 |
So a class removal should remove the class in Smalltalk yet the package should still keep hold of the
|
|
820 |
entire definition INCLUDING the methods it requires!!"
|
|
821 |
"This one tests if the methods are still kept within the pacakge as packagedMethods"
|
|
822 |
| packagedClass package1 package2 packagedMethod1 packagedMethod2 method1 method2 |
|
|
823 |
[
|
|
824 |
package1 := packageManager newPackageNamed:#'package1'.
|
|
825 |
package2 := packageManager newPackageNamed:#'package2'.
|
|
826 |
|
|
827 |
self createClassNamed:#QWERTZ2.
|
|
828 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation 1 + 1'.
|
|
829 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation2 1 + 1'.
|
|
830 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
831 |
method2 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation2.
|
|
832 |
|
|
833 |
packageManager moveClass:QWERTZ2 toPackage:package1.
|
|
834 |
"This blocks method2 from package1"
|
|
835 |
packageManager addMethod:method2 toPackage:package2.
|
|
836 |
"method2 has been overridden in package1 by package2!!"
|
|
837 |
|
|
838 |
self assert:(package1 includesPackagedClassNamed:#QWERTZ2).
|
|
839 |
packagedClass := (package1 packagedClassNamed:#QWERTZ2).
|
|
840 |
self assert:(packagedClass isInSmalltalk).
|
|
841 |
|
|
842 |
"Method1 in package1 "
|
|
843 |
self assert:(package1 definesSelector:method1 name forClassNamed:#QWERTZ2).
|
|
844 |
self assert:(package1 isDependentOnMethodNamed:method1 name forClassNamed:#QWERTZ2).
|
|
845 |
packagedMethod1 := (package1 packagedMethodNamed:method1 name forClassNamed:#QWERTZ2).
|
|
846 |
self assert:(packagedMethod1 isInSmalltalk).
|
|
847 |
|
|
848 |
"Method2 in package1 is overridden but still own's a copy which it is not dependant on"
|
|
849 |
self assert:(package1 definesSelector:method2 name forClassNamed:#QWERTZ2).
|
|
850 |
self shouldnt:(package1 isDependentOnMethodNamed:method2 name forClassNamed:#QWERTZ2).
|
|
851 |
packagedMethod2 := (package1 packagedMethodNamed:method2 name forClassNamed:#QWERTZ2).
|
|
852 |
self shouldnt:(packagedMethod2 isInSmalltalk).
|
|
853 |
|
|
854 |
"Package2 should NOT define the class QWERTZ2 but should define method2 which should also be in Smalltalk!!"
|
|
855 |
self shouldnt:(package2 includesPackagedClassNamed:#QWERTZ2).
|
|
856 |
self assert:(package2 definesSelector:method2 name forClassNamed:#QWERTZ2).
|
|
857 |
packagedMethod2 := (package2 packagedMethodNamed:method2 name forClassNamed:#QWERTZ2).
|
|
858 |
self assert:(packagedMethod2 isInSmalltalk).
|
|
859 |
|
|
860 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
861 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
862 |
].
|
|
863 |
"test that the CLASS is removed from Smalltalk BUT the package1 still retains it!!"
|
|
864 |
self assert:(package1 includesPackagedClassNamed:#QWERTZ2).
|
|
865 |
packagedClass := (package1 packagedClassNamed:#QWERTZ2).
|
|
866 |
self shouldnt:(packagedClass isInSmalltalk).
|
|
867 |
|
|
868 |
"test that the METHOD1 is removed from Smalltalk BUT the package1 still retains it!!"
|
|
869 |
self assert:(package1 definesSelector:method1 name forClassNamed:#QWERTZ2).
|
|
870 |
self shouldnt:(package1 isDependentOnMethodNamed:method1 name forClassNamed:#QWERTZ2).
|
|
871 |
packagedMethod1 := (package1 packagedMethodNamed:method1 name forClassNamed:#QWERTZ2).
|
|
872 |
self assert:(packagedMethod1 notNil).
|
|
873 |
self shouldnt:(packagedMethod1 isInSmalltalk).
|
|
874 |
|
|
875 |
"This that method2 is still overridden but still own's a copy which it is not dependant on"
|
|
876 |
self assert:(package1 definesSelector:method2 name forClassNamed:#QWERTZ2).
|
|
877 |
self shouldnt:(package1 isDependentOnMethodNamed:method2 name forClassNamed:#QWERTZ2).
|
|
878 |
packagedMethod2 := (package1 packagedMethodNamed:method2 name forClassNamed:#QWERTZ2).
|
|
879 |
self assert:(packagedMethod2 notNil).
|
|
880 |
self shouldnt:(packagedMethod1 isInSmalltalk).
|
|
881 |
|
|
882 |
"test that the METHOD is removed from Smalltalk BUT the package2 still retains it!!"
|
|
883 |
self assert:(package2 definesSelector:method2 name forClassNamed:#QWERTZ2).
|
|
884 |
self shouldnt:(package2 isDependentOnMethodNamed:method2 name forClassNamed:#QWERTZ2).
|
|
885 |
packagedMethod2 := (package2 packagedMethodNamed:method2 name forClassNamed:#QWERTZ2).
|
|
886 |
self assert:(packagedMethod2 notNil).
|
|
887 |
self shouldnt:(packagedMethod2 isInSmalltalk).
|
|
888 |
|
|
889 |
|
|
890 |
] ensure:[
|
|
891 |
packageManager unloadPackageNamed:#'package1'.
|
|
892 |
packageManager unloadPackageNamed:#'package2'.
|
1276
|
893 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
894 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
895 |
].
|
1266
|
896 |
]
|
|
897 |
!
|
|
898 |
|
|
899 |
testClassRemove5
|
|
900 |
"Changes caught my the manager should not affect the packages state.
|
|
901 |
So a class removal should remove the class in Smalltalk yet the package should still keep hold of the
|
|
902 |
entire definition INCLUDING the methods it requires!!"
|
|
903 |
"This one tests if the methods are still kept within the pacakge as packagedMethods"
|
|
904 |
| packagedClass package1 package2 method1 |
|
|
905 |
[
|
|
906 |
package1 := packageManager newPackageNamed:#'package1'.
|
|
907 |
package2 := packageManager newPackageNamed:#'package2'.
|
|
908 |
|
|
909 |
self createClassNamed:#QWERTZ2.
|
|
910 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation 1 + 1'.
|
|
911 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation2 1 + 1'.
|
|
912 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
913 |
|
|
914 |
packageManager moveClass:QWERTZ2 toPackage:package1.
|
|
915 |
|
|
916 |
packagedClass := (package1 packagedClassNamed:#QWERTZ2).
|
|
917 |
self assert:packagedClass notNil.
|
|
918 |
self assert:(packagedClass isInSmalltalk).
|
|
919 |
self assert:(packagedClass packagedMethods size == 2).
|
|
920 |
|
|
921 |
packageManager addClass:QWERTZ2 toPackage:package2.
|
|
922 |
packagedClass := (package1 packagedClassNamed:#QWERTZ2).
|
|
923 |
self assert:packagedClass notNil.
|
|
924 |
self assert:(packagedClass packagedMethods size == 2).
|
|
925 |
packagedClass packagedMethods do:[:aPackagedMethod |
|
|
926 |
self assert:(aPackagedMethod isInSmalltalk).
|
|
927 |
].
|
|
928 |
self shouldnt:(packagedClass isInSmalltalk).
|
|
929 |
|
|
930 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
931 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
932 |
].
|
|
933 |
"package1 still has all the information it had before"
|
|
934 |
packagedClass := (package1 packagedClassNamed:#QWERTZ2).
|
|
935 |
self assert:packagedClass notNil.
|
|
936 |
self assert:(packagedClass packagedMethods size == 2).
|
|
937 |
packagedClass packagedMethods do:[:aPackagedMethod |
|
|
938 |
self shouldnt:(aPackagedMethod isInSmalltalk).
|
|
939 |
].
|
|
940 |
self shouldnt:(packagedClass isInSmalltalk).
|
|
941 |
|
|
942 |
"test that the METHOD is removed from Smalltalk BUT the package2 still retains it!!"
|
|
943 |
packagedClass := (package2 packagedClassNamed:#QWERTZ2).
|
|
944 |
self assert:packagedClass notNil.
|
|
945 |
self assert:(packagedClass packagedMethods size == 2).
|
|
946 |
packagedClass packagedMethods do:[:aPackagedMethod |
|
|
947 |
self shouldnt:(aPackagedMethod isInSmalltalk).
|
|
948 |
].
|
|
949 |
self shouldnt:(packagedClass isInSmalltalk).
|
|
950 |
|
|
951 |
|
|
952 |
|
|
953 |
] ensure:[
|
|
954 |
packageManager unloadPackageNamed:#'package1'.
|
|
955 |
packageManager unloadPackageNamed:#'package2'.
|
1276
|
956 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
957 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
958 |
].
|
1266
|
959 |
]
|
|
960 |
!
|
|
961 |
|
|
962 |
testMethodRemove
|
|
963 |
"Changes caught my the manager should not affect the packages state.
|
|
964 |
So a class removal should remove the class in Smalltalk yet the package should still keep hold of the
|
|
965 |
entire definition INCLUDING the methods it requires!!"
|
|
966 |
"This one tests if the methods are still kept within the pacakge as packagedMethods"
|
|
967 |
"WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! DONT correct during the debugger otherwise changes made could be removed!!!!!!"
|
|
968 |
| package1 package2 packagedMethod1 method1 |
|
|
969 |
[
|
|
970 |
package1 := packageManager newPackageNamed:#'package1'.
|
|
971 |
package2 := packageManager newPackageNamed:#'package2'.
|
|
972 |
|
|
973 |
self createClassNamed:#QWERTZ2.
|
|
974 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation 1 + 1'.
|
|
975 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation2 1 + 1'.
|
|
976 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
977 |
|
|
978 |
packageManager moveClass:QWERTZ2 toPackage:package1.
|
|
979 |
"This blocks method1 from package1"
|
|
980 |
packageManager moveMethod:method1 toPackage:package2.
|
|
981 |
|
|
982 |
self assert:(package1 includesPackagedClassNamed:#QWERTZ2).
|
|
983 |
"package1 stores method2 as blocked"
|
|
984 |
self shouldnt:(package1 definesSelector:method1 name forClassNamed:#QWERTZ2).
|
|
985 |
|
|
986 |
|
|
987 |
"Package2 should NOT define the class QWERTZ2 but should define method2 which should also be in Smalltalk!!"
|
|
988 |
self shouldnt:(package2 includesPackagedClassNamed:#QWERTZ2).
|
|
989 |
self assert:(package2 definesSelector:method1 name forClassNamed:#QWERTZ2).
|
|
990 |
packagedMethod1 := (package2 packagedMethodNamed:method1 name forClassNamed:#QWERTZ2).
|
|
991 |
self assert:(packagedMethod1 isInSmalltalk).
|
|
992 |
|
|
993 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
994 |
QWERTZ2 removeSelector:method1 name.
|
|
995 |
].
|
|
996 |
"test that the CLASS is removed from Smalltalk BUT the package1 still retains it!!"
|
|
997 |
self assert:(package1 includesPackagedClassNamed:#QWERTZ2).
|
|
998 |
self shouldnt:(package1 definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
999 |
|
|
1000 |
"test that the METHOD is still blocked in package1!!"
|
|
1001 |
self assert:(package2 definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
1002 |
|
|
1003 |
"test that the METHOD is removed from Smalltalk BUT the package2 still retains it!!"
|
|
1004 |
self assert:(package2 definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
1005 |
packagedMethod1 := (package2 packagedMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
1006 |
self assert:(packagedMethod1 notNil).
|
|
1007 |
self shouldnt:(packagedMethod1 isInSmalltalk).
|
|
1008 |
|
|
1009 |
|
|
1010 |
] ensure:[
|
|
1011 |
packageManager unloadPackageNamed:#'package1'.
|
|
1012 |
packageManager unloadPackageNamed:#'package2'.
|
1276
|
1013 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
1014 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
1015 |
].
|
1266
|
1016 |
]
|
|
1017 |
!
|
|
1018 |
|
|
1019 |
testMethodRemove2
|
|
1020 |
"Changes caught my the manager should not affect the packages state.
|
|
1021 |
So a class removal should remove the class in Smalltalk yet the package should still keep hold of the
|
|
1022 |
entire definition INCLUDING the methods it requires!!"
|
|
1023 |
"This one tests if the methods are still kept within the pacakge as packagedMethods"
|
|
1024 |
"WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! DONT correct during the debugger otherwise changes made could be removed!!!!!!"
|
|
1025 |
| package1 package2 packagedMethod1 method1 |
|
1276
|
1026 |
|
1266
|
1027 |
[
|
1276
|
1028 |
"prerequisites"
|
|
1029 |
self assert:(Smalltalk classNamed:#QWERTZ2) isNil.
|
|
1030 |
|
1266
|
1031 |
package1 := packageManager newPackageNamed:#'package1'.
|
|
1032 |
package2 := packageManager newPackageNamed:#'package2'.
|
|
1033 |
|
1276
|
1034 |
self createClassNamed:#QWERTZ2.
|
1266
|
1035 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation 1 + 1'.
|
|
1036 |
self createMethodFor:QWERTZ2 source:'testBasicMethodCreation2 1 + 1'.
|
|
1037 |
method1 := QWERTZ2 compiledMethodAt:#testBasicMethodCreation.
|
|
1038 |
|
|
1039 |
packageManager moveClass:QWERTZ2 toPackage:package1.
|
1276
|
1040 |
self assert:(package1 definesSelector:method1 name forClassNamed:#QWERTZ2).
|
|
1041 |
self assert:(package1 isDependentOnMethodNamed:method1 name forClassNamed:#QWERTZ2).
|
|
1042 |
|
1266
|
1043 |
"This blocks method1 from package1"
|
|
1044 |
packageManager addMethod:method1 toPackage:package2.
|
|
1045 |
|
|
1046 |
self assert:(package1 includesPackagedClassNamed:#QWERTZ2).
|
|
1047 |
"package1 stores method2 as overridden"
|
|
1048 |
self assert:(package1 definesSelector:method1 name forClassNamed:#QWERTZ2).
|
|
1049 |
self shouldnt:(package1 isDependentOnMethodNamed:method1 name forClassNamed:#QWERTZ2).
|
|
1050 |
|
|
1051 |
|
|
1052 |
"Package2 should NOT define the class QWERTZ2 but should define method2 which should also be in Smalltalk!!"
|
|
1053 |
self shouldnt:(package2 includesPackagedClassNamed:#QWERTZ2).
|
|
1054 |
self assert:(package2 definesSelector:method1 name forClassNamed:#QWERTZ2).
|
|
1055 |
packagedMethod1 := (package2 packagedMethodNamed:method1 name forClassNamed:#QWERTZ2).
|
|
1056 |
self assert:(packagedMethod1 isInSmalltalk).
|
|
1057 |
|
|
1058 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
1059 |
QWERTZ2 removeSelector:method1 name.
|
|
1060 |
].
|
|
1061 |
"test that the CLASS is removed from Smalltalk BUT the package1 still retains it!!"
|
|
1062 |
self assert:(package1 includesPackagedClassNamed:#QWERTZ2).
|
|
1063 |
self assert:(package1 definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
1064 |
self shouldnt:(package1 isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
1065 |
|
|
1066 |
"test that the METHOD is still defined but overridden in package1!!"
|
|
1067 |
|
|
1068 |
self assert:(package2 definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
1069 |
self shouldnt:(package2 isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
1070 |
|
|
1071 |
"test that the METHOD is removed from Smalltalk BUT the package2 still retains it!!"
|
|
1072 |
self assert:(package2 definesSelector:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
1073 |
packagedMethod1 := (package2 packagedMethodNamed:#testBasicMethodCreation forClassNamed:#QWERTZ2).
|
|
1074 |
self assert:(packagedMethod1 notNil).
|
|
1075 |
self shouldnt:(packagedMethod1 isInSmalltalk).
|
|
1076 |
|
|
1077 |
|
|
1078 |
] ensure:[
|
1276
|
1079 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
1080 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
1081 |
].
|
1266
|
1082 |
packageManager unloadPackageNamed:#'package1'.
|
|
1083 |
packageManager unloadPackageNamed:#'package2'.
|
|
1084 |
]
|
1277
|
1085 |
!
|
|
1086 |
|
|
1087 |
testMethodRemoveClassSide
|
|
1088 |
"Changes caught my the manager should not affect the packages state.
|
|
1089 |
So a class removal should remove the class in Smalltalk yet the package should still keep hold of the
|
|
1090 |
entire definition INCLUDING the methods it requires!!"
|
|
1091 |
"This one tests if the methods are still kept within the pacakge as packagedMethods"
|
|
1092 |
| package1 package2 packagedMethod1 method1 theClassName workingPackage |
|
|
1093 |
[
|
|
1094 |
package1 := packageManager newPackageNamed:#'package1'.
|
|
1095 |
package2 := packageManager newPackageNamed:#'package2'.
|
|
1096 |
|
|
1097 |
self createClassNamed:#QWERTZ2.
|
|
1098 |
workingPackage := packageManager packageNamed:QWERTZ2 package.
|
|
1099 |
self createMethodFor:QWERTZ2 class source:'testBasicMethodCreation 1 + 1'.
|
|
1100 |
self createMethodFor:QWERTZ2 class source:'testBasicMethodCreation2 1 + 1'.
|
|
1101 |
method1 := QWERTZ2 class compiledMethodAt:#testBasicMethodCreation.
|
|
1102 |
theClassName := (QWERTZ2 class name asSymbol).
|
|
1103 |
|
|
1104 |
packageManager moveClass:QWERTZ2 toPackage:package1.
|
|
1105 |
|
|
1106 |
self assert:(package1 includesPackagedClassNamed:theClassName).
|
|
1107 |
self assert:(package1 definesSelector:method1 name forClassNamed:theClassName).
|
|
1108 |
|
|
1109 |
|
|
1110 |
"This blocks method1 from package1"
|
|
1111 |
packageManager moveMethod:method1 toPackage:package2.
|
|
1112 |
self assert:(package1 includesPackagedClassNamed:theClassName).
|
|
1113 |
"package1 stores method2 as blocked"
|
|
1114 |
self shouldnt:(package1 definesSelector:method1 name forClassNamed:theClassName).
|
|
1115 |
|
|
1116 |
|
|
1117 |
"Package2 should NOT define the class QWERTZ2 class but should define method2 which should also be in Smalltalk!!"
|
|
1118 |
self shouldnt:(package2 includesPackagedClassNamed:theClassName).
|
|
1119 |
self assert:(package2 definesSelector:method1 name forClassNamed:theClassName).
|
|
1120 |
packagedMethod1 := (package2 packagedMethodNamed:method1 name forClassNamed:theClassName).
|
|
1121 |
self assert:(packagedMethod1 isInSmalltalk).
|
|
1122 |
|
|
1123 |
(Smalltalk classNamed:theClassName) ifNotNil:[
|
|
1124 |
(Smalltalk classNamed:theClassName) removeSelector:method1 name.
|
|
1125 |
].
|
|
1126 |
"test that the CLASS is removed from Smalltalk BUT the package1 still retains it!!"
|
|
1127 |
self assert:(package1 includesPackagedClassNamed:theClassName).
|
|
1128 |
self shouldnt:(package1 definesSelector:#testBasicMethodCreation forClassNamed:theClassName).
|
|
1129 |
|
|
1130 |
"test that the METHOD is still blocked in package1!!"
|
|
1131 |
self assert:(package2 definesSelector:#testBasicMethodCreation forClassNamed:theClassName).
|
|
1132 |
|
|
1133 |
"test that the METHOD is removed from Smalltalk BUT the package2 still retains it!!"
|
|
1134 |
self assert:(package2 definesSelector:#testBasicMethodCreation forClassNamed:theClassName).
|
|
1135 |
packagedMethod1 := (package2 packagedMethodNamed:#testBasicMethodCreation forClassNamed:theClassName).
|
|
1136 |
self assert:(packagedMethod1 notNil).
|
|
1137 |
self shouldnt:(packagedMethod1 isInSmalltalk).
|
|
1138 |
|
|
1139 |
|
|
1140 |
] ensure:[
|
|
1141 |
packageManager unloadPackageNamed:#'package1'.
|
|
1142 |
packageManager unloadPackageNamed:#'package2'.
|
|
1143 |
(Smalltalk classNamed:theClassName) ifNotNil:[
|
|
1144 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
1145 |
].
|
|
1146 |
]
|
|
1147 |
!
|
|
1148 |
|
|
1149 |
testMethodRemoveClassSide2
|
|
1150 |
"Changes caught my the manager should not affect the packages state.
|
|
1151 |
So a class removal should remove the class in Smalltalk yet the package should still keep hold of the
|
|
1152 |
entire definition INCLUDING the methods it requires!!"
|
|
1153 |
"This one tests if the methods are still kept within the pacakge as packagedMethods"
|
|
1154 |
| package1 package2 packagedMethod1 method1 theClassSideName |
|
|
1155 |
|
|
1156 |
[
|
|
1157 |
"prerequisites"
|
|
1158 |
self assert:(Smalltalk classNamed:#QWERTZ2) isNil.
|
|
1159 |
|
|
1160 |
package1 := packageManager newPackageNamed:#'package1'.
|
|
1161 |
package2 := packageManager newPackageNamed:#'package2'.
|
|
1162 |
|
|
1163 |
self createClassNamed:#QWERTZ2.
|
|
1164 |
theClassSideName := QWERTZ2 class name asSymbol.
|
|
1165 |
self createMethodFor:QWERTZ2 class source:'testBasicMethodCreation 1 + 1'.
|
|
1166 |
self createMethodFor:QWERTZ2 class source:'testBasicMethodCreation2 1 + 1'.
|
|
1167 |
method1 := QWERTZ2 class compiledMethodAt:#testBasicMethodCreation.
|
|
1168 |
|
|
1169 |
packageManager moveClass:QWERTZ2 toPackage:package1.
|
|
1170 |
self assert:(package1 definesSelector:method1 name forClassNamed:theClassSideName).
|
|
1171 |
self assert:(package1 isDependentOnMethodNamed:method1 name forClassNamed:theClassSideName).
|
|
1172 |
|
|
1173 |
"This blocks method1 from package1"
|
|
1174 |
packageManager addMethod:method1 toPackage:package2.
|
|
1175 |
|
|
1176 |
self assert:(package1 includesPackagedClassNamed:theClassSideName).
|
|
1177 |
"package1 stores method2 as overridden"
|
|
1178 |
self assert:(package1 definesSelector:method1 name forClassNamed:theClassSideName).
|
|
1179 |
self shouldnt:(package1 isDependentOnMethodNamed:method1 name forClassNamed:theClassSideName).
|
|
1180 |
|
|
1181 |
|
|
1182 |
"Package2 should NOT define the class but should define method2 which should also be in Smalltalk!!"
|
|
1183 |
self shouldnt:(package2 includesPackagedClassNamed:theClassSideName).
|
|
1184 |
self assert:(package2 definesSelector:method1 name forClassNamed:theClassSideName).
|
|
1185 |
packagedMethod1 := (package2 packagedMethodNamed:method1 name forClassNamed:theClassSideName).
|
|
1186 |
self assert:(packagedMethod1 isInSmalltalk).
|
|
1187 |
|
|
1188 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
1189 |
QWERTZ2 class removeSelector:method1 name.
|
|
1190 |
].
|
|
1191 |
"test that the CLASS is removed from Smalltalk BUT the package1 still retains it!!"
|
|
1192 |
self assert:(package1 includesPackagedClassNamed:theClassSideName).
|
|
1193 |
self assert:(package1 definesSelector:#testBasicMethodCreation forClassNamed:theClassSideName).
|
|
1194 |
self shouldnt:(package1 isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:theClassSideName).
|
|
1195 |
|
|
1196 |
"test that the METHOD is still defined but overridden in package1!!"
|
|
1197 |
|
|
1198 |
self assert:(package2 definesSelector:#testBasicMethodCreation forClassNamed:theClassSideName).
|
|
1199 |
self shouldnt:(package2 isDependentOnMethodNamed:#testBasicMethodCreation forClassNamed:theClassSideName).
|
|
1200 |
|
|
1201 |
"test that the METHOD is removed from Smalltalk BUT the package2 still retains it!!"
|
|
1202 |
self assert:(package2 definesSelector:#testBasicMethodCreation forClassNamed:theClassSideName).
|
|
1203 |
packagedMethod1 := (package2 packagedMethodNamed:#testBasicMethodCreation forClassNamed:theClassSideName).
|
|
1204 |
self assert:(packagedMethod1 notNil).
|
|
1205 |
self shouldnt:(packagedMethod1 isInSmalltalk).
|
|
1206 |
|
|
1207 |
|
|
1208 |
] ensure:[
|
|
1209 |
(Smalltalk classNamed:#QWERTZ2) ifNotNil:[
|
|
1210 |
(Smalltalk classNamed:#QWERTZ2) removeFromSystem.
|
|
1211 |
].
|
|
1212 |
packageManager unloadPackageNamed:#'package1'.
|
|
1213 |
packageManager unloadPackageNamed:#'package2'.
|
|
1214 |
]
|
1266
|
1215 |
! !
|
|
1216 |
|
|
1217 |
!PackageSmalltalkManipulationTestCases class methodsFor:'documentation'!
|
|
1218 |
|
|
1219 |
version
|
1445
|
1220 |
^ '$Header: /cvs/stx/stx/libbasic3/packages/PackageSmalltalkManipulationTestCases.st,v 1.6 2006-01-10 09:31:41 cg Exp $'
|
1266
|
1221 |
! !
|