/// <summary> /// Zip with ordering on showed issues, but it was due to the ordering component. /// This is included as a regression test for that particular repro. /// </summary> private static void ZipAndOrderingCore(int range) { //Console.Write(" DOP: "); for (int dop = 1; dop <= 30; dop++) { AggregateException ex = null; try { var enum1 = Enumerable.Range(1, range); var enum2 = Enumerable.Repeat(1, range * 2); var query1 = enum1 .AsParallel() .AsOrdered().WithDegreeOfParallelism(dop) .Zip(enum2.AsParallel().AsOrdered(), (a, b) => UserDelegateException.Throw <int, int, int>(a, b)); var output = query1.ToArray(); } catch (AggregateException ae) { ex = ae; } Assert.NotNull(ex != null); Assert.False(AggregateExceptionContains(ex, typeof(OperationCanceledException)), string.Format("PLinqDelegateExceptions.ZipAndOrdering Range: {0}: the wrong exception was inside the aggregate exception.", range)); Assert.True(AggregateExceptionContains(ex, typeof(UserDelegateException)), string.Format("PLinqDelegateExceptions.ZipAndOrdering Range: {0}: the wrong exception was inside the aggregate exception.", range)); } }
/// <summary> /// Zip with ordering on showed issues, but it was due to the ordering component. /// This is included as a regression test for that particular repro. /// </summary> /// <param name="range"></param> /// <returns></returns> internal static bool ZipAndOrdering(int range) { TestHarness.TestLog(String.Format("* ZipAndOrdering({0})", range)); bool success = true; Console.Write(" DOP: "); for (int dop = 1; dop <= 30; dop++) { Console.Write(dop.ToString("00") + ".. "); if (dop % 10 == 0) { Console.Write(Environment.NewLine + " "); } AggregateException ex = null; try { var enum1 = Enumerable.Range(1, range); var enum2 = Enumerable.Repeat(1, range * 2); var query1 = enum1 .AsParallel() .AsOrdered().WithDegreeOfParallelism(dop) .Zip(enum2.AsParallel().AsOrdered(), (a, b) => UserDelegateException.Throw <int, int, int>(a, b)); var output = query1.ToArray(); } catch (AggregateException ae) { ex = ae; } success &= (ex != null); success &= (false == PlinqDelegateExceptionHelpers.AggregateExceptionContains(ex, typeof(OperationCanceledException))); success &= (PlinqDelegateExceptionHelpers.AggregateExceptionContains(ex, typeof(UserDelegateException))); } Console.WriteLine(); return(success); }
public static void SelectJoin() { Exception caughtAggregateException = null; try { var query = new int[] { 1, 2, 3 }.AsParallel() .Select(i => UserDelegateException.Throw <int, int>(i)) .Join(new int[] { 1 }.AsParallel(), i => i, j => j, (i, j) => 0); foreach (var x in query) { } } catch (AggregateException e) { caughtAggregateException = e; } Assert.NotNull(caughtAggregateException); }
public static void DistintOrderBySelect() { Exception caughtAggregateException = null; try { var query2 = new int[] { 1, 2, 3 }.AsParallel() .Distinct() .OrderBy(i => i) .Select(i => UserDelegateException.Throw <int, int>(i)); foreach (var x in query2) { } } catch (AggregateException e) { caughtAggregateException = e; } Assert.NotNull(caughtAggregateException); }
/// <summary> /// Another basic test for a query that throws user delegate exceptions /// </summary> /// <returns></returns> internal static bool SelectJoin() { TestHarness.TestLog("* SelectJoin()"); Exception caughtAggregateException = null; try { var query = new int[] { 1, 2, 3 }.AsParallel() .Select(i => UserDelegateException.Throw <int, int>(i)) .Join(new int[] { 1 }.AsParallel(), i => i, j => j, (i, j) => 0); foreach (var x in query) { } } catch (AggregateException e) { caughtAggregateException = e; } return(caughtAggregateException != null); }
/// <summary> /// A basic test for a query that throws user delegate exceptions /// </summary> /// <returns></returns> internal static bool DistintOrderBySelect() { TestHarness.TestLog("* DistintOrderBySelect()"); Exception caughtAggregateException = null; try { var query2 = new int[] { 1, 2, 3 }.AsParallel() .Distinct() .OrderBy(i => i) .Select(i => UserDelegateException.Throw <int, int>(i)); foreach (var x in query2) { } } catch (AggregateException e) { caughtAggregateException = e; } return(caughtAggregateException != null); }
/// <summary> /// Heavily exercises OrderBy in the face of user-delegate exceptions. /// On CTP-M1, this would deadlock for DOP=7,9,11,... on 4-core, but works for DOP=1..6 and 8,10,12, ... /// /// In this test, every call to the key-selector delegate throws. /// </summary> private static void OrderByCore(int range) { for (int dop = 1; dop <= 30; dop++) { AggregateException caughtAggregateException = null; try { var query = Enumerable.Range(0, range) .AsParallel().WithDegreeOfParallelism(dop) .OrderBy(i => UserDelegateException.Throw <int, int>(i)); foreach (int i in query) { } } catch (AggregateException e) { caughtAggregateException = e; } Assert.NotNull(caughtAggregateException); } }
/// <summary> /// Heavily exercises OrderBy in the face of user-delegate exceptions. /// On CTP-M1, this would deadlock for DOP=7,9,11,... on 4-core, but works for DOP=1..6 and 8,10,12, ... /// /// In this test, every call to the key-selector delegate throws. /// </summary> internal static bool OrderBy(int range) { TestHarness.TestLog(String.Format("* OrderBy({0})", range)); bool success = true; Console.Write(" DOP: "); for (int dop = 1; dop <= 30; dop++) { Console.Write(dop.ToString("00") + ".. "); if (dop % 10 == 0) { Console.Write(Environment.NewLine + " "); } AggregateException caughtAggregateException = null; try { var query = Enumerable.Range(0, range) .AsParallel().WithDegreeOfParallelism(dop) .OrderBy(i => UserDelegateException.Throw <int, int>(i)); foreach (int i in query) { } } catch (AggregateException e) { caughtAggregateException = e; } success &= (caughtAggregateException != null); } Console.WriteLine(); return(success); }