WeakRegistry>>finalizeValues & WeakKeyDictionary
Igor Stasenko
siguctua at gmail.com
Thu Jul 26 22:38:40 UTC 2007
Just as follow-up, i wrote test which fails randomly:
weakIdentityKeysTestFor: aClass
| d k1 k2 |
d := aClass new.
k1 := 'x' copy.
k2 := k1 copy.
d at: k1 put: 1.
d at: k2 put: 2.
self assert: (d at: k1) == 1 .
self assert: (d at: k2) == 2 .
d at: k1 put: k2.
k1 := nil.
k2 := nil.
Smalltalk garbageCollect.
self assert: d size = 2 .
self assert: (d includesKey: nil) not. <<< fails here randomly
self assert: ( d values includes: 2).
self assert: ( d values includes: 1) not.
d finalizeValues.
self assert: d size = 1 .
Smalltalk garbageCollect.
d finalizeValues.
self assert: d size = 0 .
an argument passed to function is WeakIdentityKeyDictionary.
So, the question is: can WeakKeyDictionary show keys=nil for any
requests or not?
I suggest, that since nil reserved for GCed key values, it must raise
an error whenever someone going to put/get value with nil key.
--
Best regards,
Igor Stasenko AKA sig.
More information about the Squeak-dev
mailing list
|