diff options
m--------- | external/corert | 0 | ||||
-rw-r--r-- | mcs/class/corlib/Test/System/ArrayTest.cs | 62 |
2 files changed, 62 insertions, 0 deletions
diff --git a/external/corert b/external/corert -Subproject ffcd7990d87e560c63413293c8efe1d1fc4e358 +Subproject 11136ad55767485063226be08cfbd32ed574ca4 diff --git a/mcs/class/corlib/Test/System/ArrayTest.cs b/mcs/class/corlib/Test/System/ArrayTest.cs index 819cb871749..3c168093cc1 100644 --- a/mcs/class/corlib/Test/System/ArrayTest.cs +++ b/mcs/class/corlib/Test/System/ArrayTest.cs @@ -12,6 +12,7 @@ using System; using System.Collections; using System.Globalization; using System.Reflection; +using System.Threading; using System.Collections.Generic; namespace MonoTests.System @@ -3745,5 +3746,66 @@ public class ArrayTest Assert.Throws<NotSupportedException> (() => { var _ = x.GetValue (0); }, "#2"); Assert.Throws<NotSupportedException> (() => { x.SetValue (0, 0); }, "#3"); } + + +#if MONO_FEATURE_THREAD_ABORT + public struct J + { + public int i; + + public J(int i_) { i = i_; } + } + + struct JComp : IComparer<J> + { + public int Compare(J x, J y) + { + int val = 0; + Thread.Sleep (Timeout.Infinite); + return val; + } + } + + class ArraySortAbortData { + internal ManualResetEventSlim mre; + internal bool threw; + + internal ArraySortAbortData () { + mre = new ManualResetEventSlim (); + threw = false; + } + } + + [Test] + public void ArraySortAbort () + { + var d = new ArraySortAbortData(); + var t = new Thread(RunArraySort); + t.Start(d); + d.mre.Wait(); + Thread.Sleep(400); + t.Abort(); + t.Join(); + Assert.IsFalse (d.threw); + } + + public static void RunArraySort(object data) + { + var d = data as ArraySortAbortData; + int n = 10; + var a = new J[n]; + for (int i = 0; i < n; ++i) + { + a[i] = new J(n - i); + } + d.mre.Set(); + try { + Array.Sort(a, 0, n, new JComp()); + } catch (InvalidOperationException) { + // t.Abort in ArraySortAbort should _not_ end up here + d.threw = true; + } + } +#endif } } |