Levente Uzonyi uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-ul.140.mcz==================== Summary ====================
Name: CollectionsTests-ul.140
Author: ul
Time: 5 February 2010, 1:42:49.932 am
UUID: 93584d88-6938-7949-9e89-68087688897c
Ancestors: CollectionsTests-ul.139
- two more tests for WeakRegistry
=============== Diff against CollectionsTests-ul.139 ===============
Item was added:
+ ----- Method: WeakRegistryTest>>testRemovingDoesntLeak (in category 'as yet unclassified') -----
+ testRemovingDoesntLeak
+
+ | w finalized block hash object executor |
+ w := WeakRegistry new: 1.
+ finalized := false.
+ block := [ :v | finalized := v ].
+ object := Object new.
+ executor := ObjectFinalizer new
+ receiver: block
+ selector: #value:
+ argument: true;
+ yourself.
+ hash := object hash.
+ w add: hash.
+ w add: object executor: executor.
+ object := nil. "let it go"
+ w remove: hash.
+ Smalltalk garbageCollect. "finalize it"
+ self assert: w isEmpty.
+ self assert: finalized!
Item was added:
+ ----- Method: WeakRegistryTest>>testRemovingByAHighPriorityProcessDoesntLeak (in category 'as yet unclassified') -----
+ testRemovingByAHighPriorityProcessDoesntLeak
+
+ | w finalized block hash object executor semaphore |
+ w := WeakRegistry new: 1.
+ finalized := false.
+ block := [ :v | finalized := v ].
+ object := Object new.
+ executor := ObjectFinalizer new
+ receiver: block
+ selector: #value:
+ argument: true;
+ yourself.
+ hash := object hash.
+ w add: hash.
+ w add: object executor: executor.
+ semaphore := Semaphore new.
+ [
+ object := nil. "let it go"
+ w remove: hash.
+ semaphore signal ]
+ forkAt: WeakArray runningFinalizationProcess priority + 1.
+ semaphore wait.
+ Smalltalk garbageCollect. "finalize it"
+ self assert: w size = 1000.
+ self assert: finalized!