using System.Threading;
using System.Linq;
++using MonoTests.System.Threading.Tasks;
using NUnit;
using NUnit.Framework;
}
}
}
--#endif
++#endif
using System;
using System.Threading;
++using MonoTests.System.Threading.Tasks;
using System.Collections.Concurrent;
using NUnit;
//
using System;
--using System.Threading;
using System.Collections.Concurrent;
++using MonoTests.System.Threading.Tasks;
++
using NUnit.Framework;
namespace ParallelFxTests
//
using System;
--using System.Threading;
++using MonoTests.System.Threading.Tasks;
using System.Collections.Concurrent;
using NUnit.Framework;
--- /dev/null
--- /dev/null
++#if NET_4_0
++// TestHelper.cs
++//
++// Copyright (c) 2008 Jérémie "Garuma" Laval
++//
++// Permission is hereby granted, free of charge, to any person obtaining a copy
++// of this software and associated documentation files (the "Software"), to deal
++// in the Software without restriction, including without limitation the rights
++// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
++// copies of the Software, and to permit persons to whom the Software is
++// furnished to do so, subject to the following conditions:
++//
++// The above copyright notice and this permission notice shall be included in
++// all copies or substantial portions of the Software.
++//
++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
++// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
++// THE SOFTWARE.
++//
++//
++
++using System;
++using System.Threading;
++using System.Collections.Concurrent;
++
++namespace MonoTests.System.Threading.Tasks
++{
++ static class ParallelTestHelper
++ {
++ const int NumRun = 100;
++
++ public static void Repeat (Action action)
++ {
++ Repeat (action, NumRun);
++ }
++
++ public static void Repeat (Action action, int numRun)
++ {
++ for (int i = 0; i < numRun; i++) {
++ //Console.WriteLine ("Run " + i.ToString ());
++ action ();
++ }
++ }
++
++ public static void ParallelStressTest<TSource>(TSource obj, Action<TSource> action)
++ {
++ ParallelStressTest(obj, action, Environment.ProcessorCount + 2);
++ }
++
++ public static void ParallelStressTest<TSource>(TSource obj, Action<TSource> action, int numThread)
++ {
++ Thread[] threads = new Thread[numThread];
++ for (int i = 0; i < numThread; i++) {
++ threads[i] = new Thread(new ThreadStart(delegate { action(obj); }));
++ threads[i].Start();
++ }
++
++ // Wait for the completion
++ for (int i = 0; i < numThread; i++)
++ threads[i].Join();
++ }
++
++ public static void ParallelAdder(IProducerConsumerCollection<int> collection, int numThread)
++ {
++ int startIndex = -10;
++ ParallelTestHelper.ParallelStressTest(collection, delegate (IProducerConsumerCollection<int> c) {
++ int start = Interlocked.Add(ref startIndex, 10);
++ for (int i = start; i < start + 10; i++) {
++ c.TryAdd(i);
++ }
++ }, numThread);
++ }
++
++ public static void ParallelRemover(IProducerConsumerCollection<int> collection, int numThread, int times)
++ {
++ int t = -1;
++ ParallelTestHelper.ParallelStressTest(collection, delegate (IProducerConsumerCollection<int> c) {
++ int num = Interlocked.Increment(ref t);
++ int value;
++ if (num < times)
++ c.TryTake (out value);
++ }, numThread);
++ }
++ }
++}
++#endif
--- /dev/null
--- /dev/null
++#if NET_4_0
++// ParallelTests.cs
++//
++// Copyright (c) 2008 Jérémie "Garuma" Laval
++//
++// Permission is hereby granted, free of charge, to any person obtaining a copy
++// of this software and associated documentation files (the "Software"), to deal
++// in the Software without restriction, including without limitation the rights
++// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
++// copies of the Software, and to permit persons to whom the Software is
++// furnished to do so, subject to the following conditions:
++//
++// The above copyright notice and this permission notice shall be included in
++// all copies or substantial portions of the Software.
++//
++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
++// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
++// THE SOFTWARE.
++//
++//
++
++using System;
++using System.Linq;
++using System.Reflection;
++using System.Threading;
++using System.Threading.Tasks;
++using System.IO;
++using System.Xml.Serialization;
++using System.Collections.Generic;
++using System.Collections.Concurrent;
++
++using NUnit;
++using NUnit.Core;
++using NUnit.Framework;
++
++namespace MonoTests.System.Threading.Tasks
++{
++
++ [TestFixture()]
++ public class ParallelTests
++ {
++
++ [Test]
++ public void ParallelForTestCase ()
++ {
++ ParallelTestHelper.Repeat (() => {
++ int[] expected = Enumerable.Range (1, 1000).Select ((e) => e * 2).ToArray ();
++ int[] actual = Enumerable.Range (1, 1000).ToArray ();
++ SpinWait sw = new SpinWait ();
++
++ Parallel.For (0, actual.Length, (i) => { actual[i] *= 2; sw.SpinOnce (); });
++
++ CollectionAssert.AreEquivalent (expected, actual, "#1, same");
++ CollectionAssert.AreEqual (expected, actual, "#2, in order");
++ });
++ }
++
++ [Test, ExpectedException (typeof (AggregateException))]
++ public void ParallelForExceptionTestCase ()
++ {
++ Parallel.For(1, 100, delegate (int i) { throw new Exception("foo"); });
++ }
++
++ [Test]
++ public void ParallelForSmallRangeTest ()
++ {
++ ParallelTestHelper.Repeat (() => {
++ int test = -1;
++ Parallel.For (0, 1, (i) => test = i);
++
++ Assert.AreEqual (0, test, "#1");
++ });
++ }
++
++ [Test]
++ public void ParallelForNoOperationTest ()
++ {
++ bool launched = false;
++ Parallel.For (4, 1, (i) => launched = true);
++ Assert.IsFalse (launched, "#1");
++ }
++
++ [Test]
++ public void ParallelForEachTestCase ()
++ {
++ ParallelTestHelper.Repeat (() => {
++ IEnumerable<int> e = Enumerable.Repeat(1, 500);
++ ConcurrentQueue<int> queue = new ConcurrentQueue<int> ();
++ SpinWait sw = new SpinWait ();
++ int count = 0;
++
++ Parallel.ForEach (e, (element) => { Interlocked.Increment (ref count); queue.Enqueue (element); sw.SpinOnce (); });
++
++ Assert.AreEqual (500, count, "#1");
++ CollectionAssert.AreEquivalent (e, queue, "#2");
++ });
++ }
++
++ [Test, ExpectedException (typeof (AggregateException))]
++ public void ParallelForEachExceptionTestCase ()
++ {
++ IEnumerable<int> e = Enumerable.Repeat (1, 10);
++ Parallel.ForEach (e, delegate (int element) { throw new Exception ("foo"); });
++ }
++
++ /* Disabled as this is an API addition
++ [Test]
++ public void ParallelWhileTestCase()
++ {
++ ParallelTestHelper.Repeat (() => {
++ int i = 0;
++ int count = 0;
++
++ Parallel.While (() => Interlocked.Increment (ref i) <= 10, () => Interlocked.Increment (ref count));
++
++ Assert.Greater(i, 10, "#1");
++ Assert.AreEqual(10, count, "#2");
++ });
++ }*/
++ }
++}
++#endif
--- /dev/null
--- /dev/null
++#if NET_4_0
++//
++// SnziTests.cs
++//
++// Author:
++// Jérémie "Garuma" Laval <jeremie.laval@gmail.com>
++//
++// Copyright (c) 2009 Jérémie "Garuma" Laval
++//
++// Permission is hereby granted, free of charge, to any person obtaining a copy
++// of this software and associated documentation files (the "Software"), to deal
++// in the Software without restriction, including without limitation the rights
++// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
++// copies of the Software, and to permit persons to whom the Software is
++// furnished to do so, subject to the following conditions:
++//
++// The above copyright notice and this permission notice shall be included in
++// all copies or substantial portions of the Software.
++//
++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
++// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
++// THE SOFTWARE.
++
++using System;
++using System.Threading;
++
++using NUnit.Framework;
++
++namespace ParallelFxTests
++{
++ [TestFixtureAttribute]
++ public class SnziTests
++ {
++ Snzi snzi;
++
++ [SetUpAttribute]
++ public void Setup ()
++ {
++ snzi = new Snzi ();
++ }
++
++ [Test]
++ public void InitialTest ()
++ {
++ Assert.IsTrue (snzi.IsSet, "#1");
++
++ }
++
++ [Test]
++ public void SimpleOperationTest ()
++ {
++ snzi.Increment ();
++
++ snzi.Decrement ();
++
++ Assert.IsTrue (snzi.IsSet, "#1");
++
++ }
++
++ [Test]
++ public void SimpleZeroTest ()
++ {
++ for (int i = 0; i < 10; i++) {
++ if (i % 2 == 0)
++ snzi.Increment ();
++ else
++ snzi.Decrement ();
++ }
++
++ Assert.IsTrue (snzi.IsSet, "#1");
++ }
++
++ [Test]
++ public void SimpleNonZeroTest ()
++ {
++ snzi.Increment ();
++
++ for (int i = 0; i < 20; i++) {
++ if (i % 2 == 0)
++ snzi.Increment ();
++ else
++ snzi.Decrement ();
++ if (i % 5 == 0)
++ Thread.Sleep (0);
++ }
++
++ Assert.IsFalse (snzi.IsSet, "#1");
++ }
++
++ [Test]
++ public void StressZeroTest ()
++ {
++ ParallelTestHelper.Repeat (delegate {
++ int times = 0;
++
++ ParallelTestHelper.ParallelStressTest (snzi, (s) => {
++ int t = Interlocked.Increment (ref times);
++
++ for (int i = 0; i < 20; i++) {
++ if (i % 2 == 0)
++ snzi.Increment ();
++ else
++ snzi.Decrement ();
++ if (i % (3 * t) == 0)
++ Thread.Sleep (0);
++ }
++ });
++
++ Assert.IsTrue (snzi.IsSet, "#1");
++ });
++ }
++
++ [Test]
++ public void StressNonZeroTest ()
++ {
++ ParallelTestHelper.Repeat (delegate {
++ ParallelTestHelper.ParallelStressTest (snzi, (s) => {
++ snzi.Increment ();
++ for (int i = 0; i < 1; i++) {
++ if (i % 2 == 0)
++ snzi.Increment ();
++ else
++ snzi.Decrement ();
++ }
++ });
++
++ Assert.IsFalse (snzi.IsSet, "#1");
++ });
++ }
++ }
++}
++#endif
using NUnit.Framework;
--namespace ParallelFxTests
++namespace MonoTests.System.Threading.Tasks
{
[TestFixture()]
public class TaskTests
using NUnit.Framework;
--namespace ParallelFxTests
++using MonoTests.System.Threading.Tasks;
++
++namespace MonoTests.System.Threading
{
[TestFixtureAttribute]
public class CountdownEventTests
using NUnit.Framework;
--namespace ParallelFxTests
++using MonoTests.System.Threading.Tasks;
++
++namespace MonoTests.System.Threading
{
[TestFixture]
+++ /dev/null
--#if NET_4_0
--// TestHelper.cs
--//
--// Copyright (c) 2008 Jérémie "Garuma" Laval
--//
--// Permission is hereby granted, free of charge, to any person obtaining a copy
--// of this software and associated documentation files (the "Software"), to deal
--// in the Software without restriction, including without limitation the rights
--// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
--// copies of the Software, and to permit persons to whom the Software is
--// furnished to do so, subject to the following conditions:
--//
--// The above copyright notice and this permission notice shall be included in
--// all copies or substantial portions of the Software.
--//
--// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
--// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
--// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
--// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
--// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
--// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
--// THE SOFTWARE.
--//
--//
--
--using System;
--using System.Threading;
--using System.Collections.Concurrent;
--
--namespace ParallelFxTests
--{
-- public static class ParallelTestHelper
-- {
-- const int NumRun = 100;
--
-- public static void Repeat (Action action)
-- {
-- Repeat (action, NumRun);
-- }
--
-- public static void Repeat (Action action, int numRun)
-- {
-- for (int i = 0; i < numRun; i++) {
-- //Console.WriteLine ("Run " + i.ToString ());
-- action ();
-- }
-- }
--
-- public static void ParallelStressTest<TSource>(TSource obj, Action<TSource> action)
-- {
-- ParallelStressTest(obj, action, Environment.ProcessorCount + 2);
-- }
--
-- public static void ParallelStressTest<TSource>(TSource obj, Action<TSource> action, int numThread)
-- {
-- Thread[] threads = new Thread[numThread];
-- for (int i = 0; i < numThread; i++) {
-- threads[i] = new Thread(new ThreadStart(delegate { action(obj); }));
-- threads[i].Start();
-- }
--
-- // Wait for the completion
-- for (int i = 0; i < numThread; i++)
-- threads[i].Join();
-- }
--
-- public static void ParallelAdder(IProducerConsumerCollection<int> collection, int numThread)
-- {
-- int startIndex = -10;
-- ParallelTestHelper.ParallelStressTest(collection, delegate (IProducerConsumerCollection<int> c) {
-- int start = Interlocked.Add(ref startIndex, 10);
-- for (int i = start; i < start + 10; i++) {
-- c.TryAdd(i);
-- }
-- }, numThread);
-- }
--
-- public static void ParallelRemover(IProducerConsumerCollection<int> collection, int numThread, int times)
-- {
-- int t = -1;
-- ParallelTestHelper.ParallelStressTest(collection, delegate (IProducerConsumerCollection<int> c) {
-- int num = Interlocked.Increment(ref t);
-- int value;
-- if (num < times)
-- c.TryTake (out value);
-- }, numThread);
-- }
-- }
--}
--#endif
+++ /dev/null
--#if NET_4_0
--// ParallelTests.cs
--//
--// Copyright (c) 2008 Jérémie "Garuma" Laval
--//
--// Permission is hereby granted, free of charge, to any person obtaining a copy
--// of this software and associated documentation files (the "Software"), to deal
--// in the Software without restriction, including without limitation the rights
--// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
--// copies of the Software, and to permit persons to whom the Software is
--// furnished to do so, subject to the following conditions:
--//
--// The above copyright notice and this permission notice shall be included in
--// all copies or substantial portions of the Software.
--//
--// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
--// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
--// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
--// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
--// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
--// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
--// THE SOFTWARE.
--//
--//
--
--using System;
--using System.Linq;
--using System.Reflection;
--using System.Threading;
--using System.IO;
--using System.Xml.Serialization;
--using System.Collections.Generic;
--using System.Collections.Concurrent;
--
--using NUnit;
--using NUnit.Core;
--using NUnit.Framework;
--
--namespace ParallelFxTests
--{
--
-- [TestFixture()]
-- public class ParallelTests
-- {
--
-- [Test]
-- public void ParallelForTestCase ()
-- {
-- ParallelTestHelper.Repeat (() => {
-- int[] expected = Enumerable.Range (1, 1000).Select ((e) => e * 2).ToArray ();
-- int[] actual = Enumerable.Range (1, 1000).ToArray ();
-- SpinWait sw = new SpinWait ();
--
-- Parallel.For (0, actual.Length, (i) => { actual[i] *= 2; sw.SpinOnce (); });
--
-- CollectionAssert.AreEquivalent (expected, actual, "#1, same");
-- CollectionAssert.AreEqual (expected, actual, "#2, in order");
-- });
-- }
--
-- [Test, ExpectedException (typeof (AggregateException))]
-- public void ParallelForExceptionTestCase ()
-- {
-- Parallel.For(1, 100, delegate (int i) { throw new Exception("foo"); });
-- }
--
-- [Test]
-- public void ParallelForSmallRangeTest ()
-- {
-- ParallelTestHelper.Repeat (() => {
-- int test = -1;
-- Parallel.For (0, 1, (i) => test = i);
--
-- Assert.AreEqual (0, test, "#1");
-- });
-- }
--
-- [Test]
-- public void ParallelForNoOperationTest ()
-- {
-- bool launched = false;
-- Parallel.For (4, 1, (i) => launched = true);
-- Assert.IsFalse (launched, "#1");
-- }
--
-- [Test]
-- public void ParallelForEachTestCase ()
-- {
-- ParallelTestHelper.Repeat (() => {
-- IEnumerable<int> e = Enumerable.Repeat(1, 500);
-- ConcurrentQueue<int> queue = new ConcurrentQueue<int> ();
-- SpinWait sw = new SpinWait ();
-- int count = 0;
--
-- Parallel.ForEach (e, (element) => { Interlocked.Increment (ref count); queue.Enqueue (element); sw.SpinOnce (); });
--
-- Assert.AreEqual (500, count, "#1");
-- CollectionAssert.AreEquivalent (e, queue, "#2");
-- });
-- }
--
-- [Test, ExpectedException (typeof (AggregateException))]
-- public void ParallelForEachExceptionTestCase ()
-- {
-- IEnumerable<int> e = Enumerable.Repeat (1, 10);
-- Parallel.ForEach (e, delegate (int element) { throw new Exception ("foo"); });
-- }
--
-- /* Disabled as this is an API addition
-- [Test]
-- public void ParallelWhileTestCase()
-- {
-- ParallelTestHelper.Repeat (() => {
-- int i = 0;
-- int count = 0;
--
-- Parallel.While (() => Interlocked.Increment (ref i) <= 10, () => Interlocked.Increment (ref count));
--
-- Assert.Greater(i, 10, "#1");
-- Assert.AreEqual(10, count, "#2");
-- });
-- }*/
-- }
--}
--#endif
using System.Linq;
using System.Threading;
++using MonoTests.System.Threading.Tasks;
++
using NUnit.Framework;
--namespace ParallelFxTests
++namespace MonoTests.System.Threading
{
[TestFixture]
public class SemaphoreSlimTests
+++ /dev/null
--#if NET_4_0
--//
--// SnziTests.cs
--//
--// Author:
--// Jérémie "Garuma" Laval <jeremie.laval@gmail.com>
--//
--// Copyright (c) 2009 Jérémie "Garuma" Laval
--//
--// Permission is hereby granted, free of charge, to any person obtaining a copy
--// of this software and associated documentation files (the "Software"), to deal
--// in the Software without restriction, including without limitation the rights
--// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
--// copies of the Software, and to permit persons to whom the Software is
--// furnished to do so, subject to the following conditions:
--//
--// The above copyright notice and this permission notice shall be included in
--// all copies or substantial portions of the Software.
--//
--// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
--// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
--// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
--// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
--// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
--// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
--// THE SOFTWARE.
--
--using System;
--using System.Threading;
--
--using NUnit.Framework;
--
--namespace ParallelFxTests
--{
-- [TestFixtureAttribute]
-- public class SnziTests
-- {
-- Snzi snzi;
--
-- [SetUpAttribute]
-- public void Setup ()
-- {
-- snzi = new Snzi ();
-- }
--
-- [Test]
-- public void InitialTest ()
-- {
-- Assert.IsTrue (snzi.IsSet, "#1");
--
-- }
--
-- [Test]
-- public void SimpleOperationTest ()
-- {
-- snzi.Increment ();
--
-- snzi.Decrement ();
--
-- Assert.IsTrue (snzi.IsSet, "#1");
--
-- }
--
-- [Test]
-- public void SimpleZeroTest ()
-- {
-- for (int i = 0; i < 10; i++) {
-- if (i % 2 == 0)
-- snzi.Increment ();
-- else
-- snzi.Decrement ();
-- }
--
-- Assert.IsTrue (snzi.IsSet, "#1");
-- }
--
-- [Test]
-- public void SimpleNonZeroTest ()
-- {
-- snzi.Increment ();
--
-- for (int i = 0; i < 20; i++) {
-- if (i % 2 == 0)
-- snzi.Increment ();
-- else
-- snzi.Decrement ();
-- if (i % 5 == 0)
-- Thread.Sleep (0);
-- }
--
-- Assert.IsFalse (snzi.IsSet, "#1");
-- }
--
-- [Test]
-- public void StressZeroTest ()
-- {
-- ParallelTestHelper.Repeat (delegate {
-- int times = 0;
--
-- ParallelTestHelper.ParallelStressTest (snzi, (s) => {
-- int t = Interlocked.Increment (ref times);
--
-- for (int i = 0; i < 20; i++) {
-- if (i % 2 == 0)
-- snzi.Increment ();
-- else
-- snzi.Decrement ();
-- if (i % (3 * t) == 0)
-- Thread.Sleep (0);
-- }
-- });
--
-- Assert.IsTrue (snzi.IsSet, "#1");
-- });
-- }
--
-- [Test]
-- public void StressNonZeroTest ()
-- {
-- ParallelTestHelper.Repeat (delegate {
-- ParallelTestHelper.ParallelStressTest (snzi, (s) => {
-- snzi.Increment ();
-- for (int i = 0; i < 1; i++) {
-- if (i % 2 == 0)
-- snzi.Increment ();
-- else
-- snzi.Decrement ();
-- }
-- });
--
-- Assert.IsFalse (snzi.IsSet, "#1");
-- });
-- }
-- }
--}
--#endif
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void Ctor_Null_2 () {
-- new Lazy<int> (null, LazyExecutionMode.NotThreadSafe);
++ new Lazy<int> (null, false);
}
[Test]
}
[Test]
-- [ExpectedException (typeof (MissingMemberException))]
public void NoDefaultCtor () {
var l1 = new Lazy<NoDefaultCtorClass> ();
-- var o = l1.Value;
++ try {
++ var o = l1.Value;
++ Assert.Fail ();
++ } catch (MissingMemberException) {
++ }
}
class NoDefaultCtorClass {
counter = 42;
//var l = new Lazy<int> (delegate () { return counter ++; }, LazyExecutionMode.NotThreadSafe);
-- var l = new Lazy<int> (delegate () { return counter ++; }, LazyExecutionMode.EnsureSingleThreadSafeExecution);
++ var l = new Lazy<int> (delegate () { return counter ++; }, true);
object monitor = new object ();
var threads = new Thread [10];
Monitor.PulseAll (monitor);
Assert.AreEqual (42, l.Value);
-- }
++ }
++
++ [Test]
++ public void InitRecursion ()
++ {
++ Lazy<DefaultCtorClass> c = null;
++ c = new Lazy<DefaultCtorClass> (() => { Console.WriteLine (c.Value); return null; });
++
++ try {
++ var r = c.Value;
++ Assert.Fail ();
++ } catch (InvalidOperationException) {
++ }
++ }
}
}
System.Threading/MutexCas.cs
System.Threading/ThreadCas.cs
System.Threading/WaitHandleCas.cs
--
System.Threading.Tasks/TaskTest.cs
System.Threading.Tasks/FutureTests.cs
System.Threading.Tasks/TaskCompletionSourceTests.cs
++System.Threading.Tasks/ParallelTestHelper.cs
++System.Threading.Tasks/ParallelTests.cs
System.Collections.Concurrent/ParallelConcurrentStackTests.cs
System.Collections.Concurrent/ConcurrentSkipListTests.cs
../System.Collections.Concurrent/ConcurrentSkipList.cs
System.Threading/CancellationTokenTests.cs
System.Threading/ManualResetEventSlimTests.cs
System.Threading/SemaphoreSlimTests.cs
--System.Threading/ParallelTests.cs
System.Threading/CountdownEventTests.cs
System/AggregateExceptionTests.cs
System.Threading/ThreadLazyTests.cs
--System.Threading/ParallelTestHelper.cs