Imported Upstream version 6.12.0.102

Former-commit-id: e614926ae5b86d74c564629f26c1f12b72a78823
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-10-10 08:55:28 +00:00
parent d7ffa4a239
commit 0e6f307daf
53 changed files with 828 additions and 737 deletions

View File

@ -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
}
}