|
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license.
|
3 | 3 |
|
4 | 4 | using System.Collections.Generic;
|
| 5 | +using Microsoft.DotNet.RemoteExecutor; |
5 | 6 | using Xunit;
|
6 | 7 |
|
7 | 8 | namespace System.Linq.Tests
|
@@ -62,14 +63,33 @@ public void RunOnce()
|
62 | 63 | Assert.Equal(Enumerable.Range(10, 10), Enumerable.Range(0, 20).RunOnce().SkipWhile((i, idx) => idx < 10));
|
63 | 64 | }
|
64 | 65 |
|
65 |
| - [Fact] |
66 |
| - public void SkipErrorWhenSourceErrors() |
| 66 | + [ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))] |
| 67 | + public static void SkipErrorWhenSourceErrors_TrimFriendlySelectTrue() |
67 | 68 | {
|
68 |
| - var source = NumberRangeGuaranteedNotCollectionType(-2, 5).Select(i => (decimal)i).Select(m => 1 / m).Skip(4); |
69 |
| - using(var en = source.GetEnumerator()) |
| 69 | + RemoteExecutor.Invoke(() => |
70 | 70 | {
|
71 |
| - Assert.Throws<DivideByZeroException>(() => en.MoveNext()); |
72 |
| - } |
| 71 | + AppContext.SetSwitch("System.Linq.Enumerable.ValueTypeTrimFriendlySelect", true); |
| 72 | + |
| 73 | + var source = NumberRangeGuaranteedNotCollectionType(-2, 5).Select(i => (decimal)i).Select(m => 1 / m).Skip(4); |
| 74 | + var valuesFromEnumerable = source.ToList(); |
| 75 | + List<decimal> expectedValues = [(decimal)1/2]; |
| 76 | + Assert.Equal(expectedValues, valuesFromEnumerable); |
| 77 | + }).Dispose(); |
| 78 | + } |
| 79 | + |
| 80 | + [ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))] |
| 81 | + public void SkipErrorWhenSourceErrors_TrimFriendlySelectFalse() |
| 82 | + { |
| 83 | + RemoteExecutor.Invoke(() => |
| 84 | + { |
| 85 | + AppContext.SetSwitch("System.Linq.Enumerable.ValueTypeTrimFriendlySelect", false); |
| 86 | + |
| 87 | + var source = NumberRangeGuaranteedNotCollectionType(-2, 5).Select(i => (decimal)i).Select(m => 1 / m).Skip(4); |
| 88 | + using (var en = source.GetEnumerator()) |
| 89 | + { |
| 90 | + Assert.Throws<DivideByZeroException>(() => en.MoveNext()); |
| 91 | + } |
| 92 | + }).Dispose(); |
73 | 93 | }
|
74 | 94 |
|
75 | 95 | [Fact]
|
|
0 commit comments