diff options
author | Russ Keldorph <russ.keldorph@microsoft.com> | 2016-06-09 16:57:42 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-09 16:57:42 -0700 |
commit | a248e24a876058460db2581b84dbd566ba2a3980 (patch) | |
tree | 3a7e159450ef136f50d8ef349e438976b13c6e39 /tests | |
parent | e65961687e6de279aca3d839273c9e3a29a64151 (diff) | |
parent | e784d4d1c82adea07d6e5e118b1ae6624c7e0d8b (diff) | |
download | coreclr-a248e24a876058460db2581b84dbd566ba2a3980.tar.gz coreclr-a248e24a876058460db2581b84dbd566ba2a3980.tar.bz2 coreclr-a248e24a876058460db2581b84dbd566ba2a3980.zip |
Merge pull request #5652 from RussKeldorph/5555
Fix WeakReference tests depending on JIT not extending lifetimes
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/GC/API/WeakReference/IsAlive_neg.cs | 8 | ||||
-rw-r--r-- | tests/src/GC/API/WeakReference/Target.cs | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/tests/src/GC/API/WeakReference/IsAlive_neg.cs b/tests/src/GC/API/WeakReference/IsAlive_neg.cs index c1b9ba8407..d229f59805 100644 --- a/tests/src/GC/API/WeakReference/IsAlive_neg.cs +++ b/tests/src/GC/API/WeakReference/IsAlive_neg.cs @@ -16,6 +16,12 @@ public class Test { public static void CreateArray() { array = new int[50]; } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static WeakReference CreateArrayWeakReference() + { + return new WeakReference(array); + } [MethodImplAttribute(MethodImplOptions.NoInlining)] public static void DestroyArray() { @@ -25,7 +31,7 @@ public class Test { public static int Main() { CreateArray(); - WeakReference weak = new WeakReference(array); // array has ONLY a weakreference + WeakReference weak = CreateArrayWeakReference(); // array has ONLY a weakreference // ensuring that GC happens even with /debug mode DestroyArray(); diff --git a/tests/src/GC/API/WeakReference/Target.cs b/tests/src/GC/API/WeakReference/Target.cs index 64d2a2bb36..91eb16168b 100644 --- a/tests/src/GC/API/WeakReference/Target.cs +++ b/tests/src/GC/API/WeakReference/Target.cs @@ -32,6 +32,12 @@ public class Test } [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static WeakReference CreateArrayWeakReference() + { + return new WeakReference(array); + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] public static void DestroyArrays() { array = null; @@ -41,7 +47,7 @@ public class Test public bool GetTargetTest() { CreateArrays(); - WeakReference weakarray = new WeakReference(array); // array has only weak reference + WeakReference weakarray = CreateArrayWeakReference(); // array has only weak reference // obj has both strong and weak ref and so should not get collected |