Skip to content

Commit

Permalink
Regression test for dotnet/coreclr#8580
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotas committed Dec 10, 2016
1 parent 227c654 commit fc6211c
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,28 @@ public static void Concurrent_GetValue_Read_Remove_SameObject()
});
}

[Fact]
public static void AddRemove_DropValue()
{
var key = new object();
var value = new object();

var cwt = new ConditionalWeakTable<object, object>();

cwt.Add(key, value);
cwt.Remove(key);

// Verify that the removed entry is not keeping the value alive
var wrValue = new WeakReference(value);
value = null;

GC.Collect();
Assert.False(wrValue.IsAlive);

GC.KeepAlive(cwt);
GC.KeepAlive(key);
}

[Fact]
public static void GetOrCreateValue()
{
Expand Down

0 comments on commit fc6211c

Please sign in to comment.