Skip to content

Commit

Permalink
Fix bug in case a value was GC
Browse files Browse the repository at this point in the history
  • Loading branch information
jecisc committed Aug 25, 2019
1 parent ff9bf69 commit 81c77de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/Collections-Tests/WeakValueDictionaryTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ WeakValueDictionaryTest >> testRehashDoesNotTransformAssociations [
self assert: (d privateAssociations anyOne isKindOf: WeakValueAssociation)
]

{ #category : #'tests - size capacity' }
WeakValueDictionaryTest >> testSize [
| d |
d := self classToBeTested new.
self assert: d size equals: 0.
d at: 1 put: 2.
d at: 2 put: nil.
self assert: d size equals: 2
]

{ #category : #tests }
WeakValueDictionaryTest >> testSizeWithGarbageCollectedValue [

Expand Down
2 changes: 1 addition & 1 deletion src/Collections-Weak/WeakValueDictionary.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ WeakValueDictionary >> at: key put: anObject [
WeakValueDictionary >> rehash [
| newSelf |
newSelf := self species new: self size.
array do: [ :each | each ifNotNil: [ :asso | newSelf noCheckAdd: asso ] ].
array do: [ :each | each value ifNotNil: [ :asso | newSelf noCheckAdd: asso ] ].
array := newSelf array
]

Expand Down

0 comments on commit 81c77de

Please sign in to comment.