Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -12,9 +12,7 @@
using NUnit.Framework;
using System;
using System.Threading;
#if NET_2_0
using Microsoft.Win32.SafeHandles;
#endif
namespace MonoTests.System.Threading
{
@@ -32,7 +30,6 @@ namespace MonoTests.System.Threading
Assert.IsFalse (evt.WaitOne (1000, false), "#3");
}
#if NET_2_0
[Test] // bug #81529
public void SafeWaitHandle ()
{
@@ -115,6 +112,5 @@ namespace MonoTests.System.Threading
are1.Close ();
swh1.Dispose ();
}
#endif
}
}

View File

@@ -28,7 +28,6 @@
// Note: the class existed in 1.1 but the only thing we know about it is that
// it has a finalizer ;-)
#if NET_2_0
using System;
using System.Security;
@@ -106,4 +105,3 @@ namespace MonoCasTests.System.Threading {
}
}
#endif

View File

@@ -26,7 +26,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.Threading;
@@ -47,5 +46,4 @@ namespace MonoTests.System.Threading {
}
}
#endif

View File

@@ -26,7 +26,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.Security;
@@ -169,4 +168,3 @@ namespace MonoCasTests.System.Threading {
}
}
#endif

View File

@@ -27,7 +27,6 @@
//
using System.Runtime.Remoting.Messaging;
#if NET_2_0
using System;
using System.Security;
@@ -292,4 +291,3 @@ namespace MonoTests.System.Threading {
}
}
#endif

View File

@@ -66,7 +66,6 @@ namespace MonoTests.System.Threading
Assert.AreEqual(obj_2, obj);
}
#if NET_2_0
[Test]
public void TestExchange_Int64 ()
{
@@ -90,7 +89,6 @@ namespace MonoTests.System.Threading
Assert.AreEqual(iptr_1, Interlocked.Exchange(ref iptr, iptr_2));
Assert.AreEqual(iptr_2, iptr);
}
#endif
[Test]
public void TestCompareExchange_Int32 ()
@@ -116,7 +114,6 @@ namespace MonoTests.System.Threading
Assert.AreEqual(obj_2, obj);
}
#if NET_2_0
[Test]
public void TestCompareExchange_Int64 ()
{
@@ -140,7 +137,6 @@ namespace MonoTests.System.Threading
Assert.AreEqual(iptr_1, Interlocked.CompareExchange(ref iptr, iptr_2, iptr_1));
Assert.AreEqual(iptr_2, iptr);
}
#endif
[Test]
public void TestCompareExchange_Failed_Int32 ()
@@ -166,7 +162,6 @@ namespace MonoTests.System.Threading
Assert.AreEqual(obj_1, obj);
}
#if NET_2_0
[Test]
public void TestCompareExchange_Failed_Int64 ()
{
@@ -190,7 +185,6 @@ namespace MonoTests.System.Threading
Assert.AreEqual(iptr_1, Interlocked.CompareExchange(ref iptr, iptr_2, iptr_3));
Assert.AreEqual(iptr_1, iptr);
}
#endif
[Test]
public void TestIncrement_Int32 ()
@@ -224,7 +218,6 @@ namespace MonoTests.System.Threading
Assert.AreEqual(int64_1 - 1, int64);
}
#if NET_2_0
[Test]
public void TestAdd_Int32 ()
{
@@ -275,6 +268,5 @@ namespace MonoTests.System.Threading
Assert.AreSame (b, Interlocked.Exchange<object> (ref b, a), "non-null,null");
Assert.AreSame (b, Interlocked.Exchange<object> (ref b, b), "non-null,non-null");
}
#endif
}
}

View File

@@ -230,7 +230,7 @@ namespace MonoTests.System.Threading
int count = 2;
SpinWait wait = new SpinWait ();
ThreadPool.QueueUserWorkItem (_ => { mre.Set (); Interlocked.Decrement (ref count); });
ThreadPool.QueueUserWorkItem (_ => { while (count > 1) wait.SpinOnce (); mre.Set (); Interlocked.Decrement (ref count); });
ThreadPool.QueueUserWorkItem (_ => { mre.Reset (); Interlocked.Decrement (ref count); });
while (count > 0)

View File

@@ -37,21 +37,23 @@ namespace MonoTests.System.Threading
public class SemaphoreSlimTests
{
SemaphoreSlim sem;
SemaphoreSlim semMax;
[SetUp]
public void Setup()
{
sem = new SemaphoreSlim(5);
semMax = new SemaphoreSlim(5, 5);
sem = new SemaphoreSlim(5);
}
[Test]
public void CurrentCountMaxTestCase()
{
semMax.Wait();
semMax.Release(3);
Assert.AreEqual(5, semMax.CurrentCount);
using (var semMax = new SemaphoreSlim(5, 5)) {
semMax.Wait();
try {
semMax.Release(3);
Assert.Fail ();
} catch (SemaphoreFullException) {}
}
}
[Test]

View File

@@ -85,6 +85,9 @@ namespace MonoTests.System.Threading
sl.TryEnter (ref taken2);
Assert.IsTrue (taken2, "#3");
sl.Exit ();
Assert.IsFalse (sl.IsHeld);
}
[Test, ExpectedException (typeof (ArgumentException))]

View File

@@ -260,38 +260,29 @@ namespace MonoTests.System.Threading
C1Test test1 = new C1Test ();
Thread tA = new Thread (new ThreadStart (test1.TestMethod));
int hA1 = tA.GetHashCode ();
#if NET_2_0
Assert.IsTrue (hA1 > 0, "#A1");
#endif
tA.Start ();
int hA2 = tA.GetHashCode ();
Assert.AreEqual (hA1, hA2, "#A2");
tA.Join ();
int hA3 = tA.GetHashCode ();
Assert.AreEqual (hA1, hA3, "#A3");
#if NET_2_0
Assert.AreEqual (hA1, tA.ManagedThreadId, "#A4");
#endif
test1 = new C1Test ();
Thread tB = new Thread (new ThreadStart (test1.TestMethod));
int hB1 = tB.GetHashCode ();
#if NET_2_0
Assert.IsTrue (hB1 > 0, "#B1");
#endif
tB.Start ();
int hB2 = tB.GetHashCode ();
Assert.AreEqual (hB1, hB2, "#B2");
tB.Join ();
int hB3 = tB.GetHashCode ();
Assert.AreEqual (hB1, hB3, "#B3");
#if NET_2_0
Assert.AreEqual (hB1, tB.ManagedThreadId, "#B4");
#endif
Assert.IsFalse (hA2 == hB2, "#B5");
}
#if NET_2_0
[Test] // bug #82700
public void ManagedThreadId ()
{
@@ -316,7 +307,6 @@ namespace MonoTests.System.Threading
Assert.AreEqual (mtB2, mtB3, "#B2");
Assert.IsFalse (mtB1 == mtA1, "#B3");
}
#endif
[Test]
[Category ("NotDotNet")] // it hangs.
@@ -365,11 +355,7 @@ namespace MonoTests.System.Threading
Assert.AreEqual (ApartmentState.Unknown, TestThread.ApartmentState, "#1");
TestThread.Start();
TestUtil.WaitForAlive (TestThread, "wait5");
#if NET_2_0
Assert.AreEqual (ApartmentState.MTA, TestThread.ApartmentState, "#2");
#else
Assert.AreEqual (ApartmentState.Unknown, TestThread.ApartmentState, "#3");
#endif
TestThread.Abort();
}
@@ -1137,11 +1123,7 @@ namespace MonoTests.System.Threading
exception_occured = true;
}
Assert.AreEqual (ApartmentState.Unknown, t3.ApartmentState, "Thread3 Set Invalid");
#if NET_2_0
Assert.IsFalse (exception_occured, "Thread3 Set Invalid Exception Occured");
#else
Assert.IsTrue (exception_occured, "Thread3 Set Invalid Exception Occured");
#endif
t1.Start ();
exception_occured = false;

View File

@@ -26,7 +26,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.Threading;
@@ -399,5 +398,4 @@ namespace MonoTests.System.Threading {
}
}
#endif