| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- // Licensed to the .NET Foundation under one or more agreements.
- // The .NET Foundation licenses this file to you under the Apache 2.0 License.
- // See the LICENSE file in the project root for more information.
- using System.Linq;
- using Xunit;
- namespace Tests
- {
- public class Optimizations : AsyncEnumerableTests
- {
- [Fact]
- public void SelectWhere2()
- {
- var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable();
- var ys = xs.Select(i => i + 2).Where(i => i % 2 == 0);
- var e = ys.GetAsyncEnumerator();
- HasNext(e, 2);
- HasNext(e, 4);
- NoNext(e);
- }
- [Fact]
- public void WhereSelect2()
- {
- var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable();
- var ys = xs.Where(i => i % 2 == 0).Select(i => i + 2);
- var e = ys.GetAsyncEnumerator();
- HasNext(e, 2);
- HasNext(e, 4);
- NoNext(e);
- }
- [Fact]
- public void WhereSelect3()
- {
- var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable();
- var ys = xs.Where(i => i % 2 == 0).Select(i => i + 2).Select(i => i + 2);
- var e = ys.GetAsyncEnumerator();
- HasNext(e, 4);
- HasNext(e, 6);
- NoNext(e);
- }
- }
- }
|