Levente Uzonyi uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-ul.149.mcz ==================== Summary ==================== Name: CollectionsTests-ul.149 Author: ul Time: 26 February 2010, 2:52:41.068 pm UUID: e3b6a9b3-8465-6549-9ac4-6be40534a68d Ancestors: CollectionsTests-ar.147 - added a new test for WeakRegistry to test multiple finalizers per object =============== Diff against CollectionsTests-ar.147 =============== Item was added: + ----- Method: WeakRegistryTest>>testFinalizationWithMultipleFinalizersPerObject (in category 'tests') ----- + testFinalizationWithMultipleFinalizersPerObject + + | object registry counter | + registry := WeakRegistry new. + object := Object new. + counter := 0. + 5 timesRepeat: [ + registry add: object executor: (ObjectFinalizer + receiver: [ counter := counter + 1 ] + selector: #value) ]. + self assert: registry size = 1. + object := nil. + Smalltalk garbageCollect. + registry finalizeValues. + self assert: registry isEmpty. + self assert: counter = 5 + ! Item was changed: + ----- Method: WeakRegistryTest>>testRemovingDoesntLeak (in category 'tests') ----- - ----- 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 - executor := ObjectFinalizer new receiver: block selector: #value: + argument: true. - 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 changed: + ----- Method: WeakRegistryTest>>testRemovingByAHighPriorityProcessDoesntLeak (in category 'tests') ----- - ----- 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 - executor := ObjectFinalizer new receiver: block selector: #value: + argument: true. - 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 isEmpty. self assert: finalized! Item was changed: + ----- Method: WeakRegistryTest>>testGrowingByAHighPriorityProcessDoesntLeak (in category 'tests') ----- - ----- Method: WeakRegistryTest>>testGrowingByAHighPriorityProcessDoesntLeak (in category 'as yet unclassified') ----- testGrowingByAHighPriorityProcessDoesntLeak | w finalized block object executor semaphore | w := WeakRegistry new: 1. finalized := false. block := [ :v | finalized := v ]. object := Object new. + executor := ObjectFinalizer - executor := ObjectFinalizer new receiver: block selector: #value: + argument: true. - argument: true; - yourself. w add: object executor: executor. semaphore := Semaphore new. [ object := nil. "let it go" w addAll: (1 to: 1000). "force growing" semaphore signal ] forkAt: WeakArray runningFinalizationProcess priority + 1. semaphore wait. Smalltalk garbageCollect. "finalize it" self assert: w size = 1000. self assert: finalized! Item was changed: + ----- Method: WeakRegistryTest>>testFinalization (in category 'tests') ----- - ----- Method: WeakRegistryTest>>testFinalization (in category 'as yet unclassified') ----- testFinalization | w finalized block object | w := WeakRegistry new: 1. finalized := false. block := [ :v | finalized := v ]. + object := ObjectFinalizer "an object that responds to #finalize" - object := ObjectFinalizer new "an object that responds to #finalize" receiver: block selector: #value: + argument: true. - argument: true; - yourself. w add: object. object := nil. "let it go" Smalltalk garbageCollect. "finalize it" self assert: w isEmpty. self assert: finalized! Item was changed: + ----- Method: WeakRegistryTest>>testGrowingDoesntLeak (in category 'tests') ----- - ----- Method: WeakRegistryTest>>testGrowingDoesntLeak (in category 'as yet unclassified') ----- testGrowingDoesntLeak | w finalized block object executor | w := WeakRegistry new: 1. finalized := false. block := [ :v | finalized := v ]. object := Object new. + executor := ObjectFinalizer - executor := ObjectFinalizer new receiver: block selector: #value: + argument: true. - argument: true; - yourself. w add: object executor: executor. object := nil. "let it go" w addAll: (1 to: 1000). "force growing" Smalltalk garbageCollect. "finalize it" self assert: w size = 1000. self assert: finalized! |
Free forum by Nabble | Edit this page |