RegressionTests__WeakCollectionTest.st
changeset 868 745b639be55b
parent 266 7abd1fd501a5
child 1061 34aa7fc79330
--- a/RegressionTests__WeakCollectionTest.st	Tue Mar 26 23:09:13 2013 +0100
+++ b/RegressionTests__WeakCollectionTest.st	Sun Mar 31 12:06:13 2013 +0200
@@ -30,6 +30,86 @@
     "
 !
 
+testWeakIdentityDictionary1
+    |w o1 o2|
+
+    w := WeakIdentityDictionary new.
+    o1 := Object new.
+    o2 := Object new.
+
+    w at:o1 put:'o1'.
+    w at:o2 put:'o2'.
+
+    ObjectMemory garbageCollect.
+    ObjectMemory tenure.
+    ObjectMemory garbageCollect.
+    ObjectMemory finalize.
+
+    self assert:(w size == 2).
+
+    o1 := nil.
+    
+    ObjectMemory garbageCollect.
+    ObjectMemory tenure.
+    ObjectMemory garbageCollect.
+    ObjectMemory finalize.
+
+    self assert:(w size == 1).
+
+    o2 := nil.
+
+    ObjectMemory garbageCollect.
+    ObjectMemory tenure.
+    ObjectMemory garbageCollect.
+    ObjectMemory finalize.
+
+    self assert:(w size == 0).
+
+    "
+     self run:#testWeakIdentityDictionary1
+    "
+!
+
+testWeakIdentityDictionary2
+    |w o1 o2|
+
+    w := WeakIdentityDictionary new.
+    o1 := '1' copy.
+    o2 := '2' copy.
+
+    w at:o1 put:'o1'.
+    w at:o2 put:'o2'.
+
+    ObjectMemory garbageCollect.
+    ObjectMemory tenure.
+    ObjectMemory garbageCollect.
+    ObjectMemory finalize.
+
+    self assert:(w size == 2).
+
+    o1 := nil.
+    
+    ObjectMemory garbageCollect.
+    ObjectMemory tenure.
+    ObjectMemory garbageCollect.
+    ObjectMemory finalize.
+
+    self assert:(w size == 1).
+
+    o2 := nil.
+
+    ObjectMemory garbageCollect.
+    ObjectMemory tenure.
+    ObjectMemory garbageCollect.
+    ObjectMemory finalize.
+
+    self assert:(w size == 0).
+
+    "
+     self run:#testWeakIdentityDictionary1
+    "
+!
+
 testWeakValueDictionary1
     |ww N|
 
@@ -119,3 +199,4 @@
 version
     ^ '$Header$'
 ! !
+