diff --git a/Sources/AsyncSequenceValidation/Clock.swift b/Sources/AsyncSequenceValidation/Clock.swift index 6f33d15a..e76f5aa9 100644 --- a/Sources/AsyncSequenceValidation/Clock.swift +++ b/Sources/AsyncSequenceValidation/Clock.swift @@ -132,3 +132,7 @@ extension AsyncSequenceValidationDiagram.Clock: TestClock { } @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) extension AsyncSequenceValidationDiagram.Clock: Clock { } + +// placeholders to avoid warnings +extension AsyncSequenceValidationDiagram.Clock.Instant: Hashable { } +extension AsyncSequenceValidationDiagram.Clock.Instant: Comparable { } diff --git a/Sources/AsyncSequenceValidation/Test.swift b/Sources/AsyncSequenceValidation/Test.swift index 35177cf2..0275cc11 100644 --- a/Sources/AsyncSequenceValidation/Test.swift +++ b/Sources/AsyncSequenceValidation/Test.swift @@ -68,6 +68,12 @@ extension AsyncSequenceValidationDiagram { struct Context { final class ClockExecutor: SerialExecutor { + @available(macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0, *) + func enqueue(_ job: __owned ExecutorJob) { + job.runSynchronously(on: asUnownedSerialExecutor()) + } + + @available(*, deprecated) // known deprecation warning func enqueue(_ job: UnownedJob) { job._runSynchronously(on: asUnownedSerialExecutor()) } diff --git a/Tests/AsyncAlgorithmsTests/TestAdjacentPairs.swift b/Tests/AsyncAlgorithmsTests/TestAdjacentPairs.swift index 843624f6..4fea0ef5 100644 --- a/Tests/AsyncAlgorithmsTests/TestAdjacentPairs.swift +++ b/Tests/AsyncAlgorithmsTests/TestAdjacentPairs.swift @@ -88,10 +88,11 @@ final class TestAdjacentPairs: XCTestCase { } // ensure the other task actually starts - wait(for: [iterated], timeout: 1.0) + + await fulfillment(of: [iterated], timeout: 1.0) // cancellation should ensure the loop finishes // without regards to the remaining underlying sequence task.cancel() - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) } } diff --git a/Tests/AsyncAlgorithmsTests/TestBuffer.swift b/Tests/AsyncAlgorithmsTests/TestBuffer.swift index f8ef8a3c..7bb45f89 100644 --- a/Tests/AsyncAlgorithmsTests/TestBuffer.swift +++ b/Tests/AsyncAlgorithmsTests/TestBuffer.swift @@ -190,13 +190,13 @@ final class TestBuffer: XCTestCase { finished.fulfill() } // ensure the task actually starts - wait(for: [iterated], timeout: 1.0) + await fulfillment(of: [iterated], timeout: 1.0) // When task.cancel() // Then - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) } func test_given_a_base_sequence_when_buffering_with_bounded_then_the_buffer_is_filled_in_and_suspends() async { @@ -310,13 +310,13 @@ final class TestBuffer: XCTestCase { finished.fulfill() } // ensure the other task actually starts - wait(for: [iterated], timeout: 1.0) + await fulfillment(of: [iterated], timeout: 1.0) // When task.cancel() // Then - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) } func test_given_a_base_sequence_when_bounded_with_limit_0_then_the_policy_is_transparent() async { diff --git a/Tests/AsyncAlgorithmsTests/TestBufferedByteIterator.swift b/Tests/AsyncAlgorithmsTests/TestBufferedByteIterator.swift index ee6c5d12..2c8841d8 100644 --- a/Tests/AsyncAlgorithmsTests/TestBufferedByteIterator.swift +++ b/Tests/AsyncAlgorithmsTests/TestBufferedByteIterator.swift @@ -199,10 +199,10 @@ final class TestBufferedByteIterator: XCTestCase { } } } - wait(for: [iterated], timeout: 1.0) + await fulfillment(of: [iterated], timeout: 1.0) // cancellation should ensure the loop finishes // without regards to the remaining underlying sequence task.cancel() - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) } } diff --git a/Tests/AsyncAlgorithmsTests/TestChain.swift b/Tests/AsyncAlgorithmsTests/TestChain.swift index b3be90a3..6bb2cb55 100644 --- a/Tests/AsyncAlgorithmsTests/TestChain.swift +++ b/Tests/AsyncAlgorithmsTests/TestChain.swift @@ -87,13 +87,13 @@ final class TestChain2: XCTestCase { } // ensure the other task actually starts - wait(for: [iterated], timeout: 1.0) + await fulfillment(of: [iterated], timeout: 1.0) // cancellation should ensure the loop finishes // without regards to the remaining underlying sequence task.cancel() - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) } } @@ -192,12 +192,12 @@ final class TestChain3: XCTestCase { } // ensure the other task actually starts - wait(for: [iterated], timeout: 1.0) + await fulfillment(of: [iterated], timeout: 1.0) // cancellation should ensure the loop finishes // without regards to the remaining underlying sequence task.cancel() - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) } } diff --git a/Tests/AsyncAlgorithmsTests/TestChannel.swift b/Tests/AsyncAlgorithmsTests/TestChannel.swift index b181bddd..b5d28cd9 100644 --- a/Tests/AsyncAlgorithmsTests/TestChannel.swift +++ b/Tests/AsyncAlgorithmsTests/TestChannel.swift @@ -133,7 +133,7 @@ final class TestChannel: XCTestCase { task1.cancel() // Then: the first sending operation is resumed - wait(for: [send1IsResumed], timeout: 1.0) + await fulfillment(of: [send1IsResumed], timeout: 1.0) // When: collecting elements var iterator = sut.makeAsyncIterator() diff --git a/Tests/AsyncAlgorithmsTests/TestCombineLatest.swift b/Tests/AsyncAlgorithmsTests/TestCombineLatest.swift index f33258c9..cb0f7324 100644 --- a/Tests/AsyncAlgorithmsTests/TestCombineLatest.swift +++ b/Tests/AsyncAlgorithmsTests/TestCombineLatest.swift @@ -84,7 +84,7 @@ final class TestCombineLatest2: XCTestCase { value = await validator.validate() XCTAssertEqual(value, [(1, "a"), (2, "a"), (2, "b"), (3, "b"), (3, "c")]) - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) value = validator.current XCTAssertEqual(value, [(1, "a"), (2, "a"), (2, "b"), (3, "b"), (3, "c")]) } @@ -126,7 +126,7 @@ final class TestCombineLatest2: XCTestCase { value = await validator.validate() XCTAssertEqual(value, [(1, "a"), (1, "b"), (2, "b"), (2, "c"), (3, "c")]) - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) value = validator.current XCTAssertEqual(value, [(1, "a"), (1, "b"), (2, "b"), (2, "c"), (3, "c")]) } @@ -168,7 +168,7 @@ final class TestCombineLatest2: XCTestCase { value = await validator.validate() XCTAssertEqual(value, [(1, "a"), (2, "a"), (3, "a"), (3, "b"), (3, "c")]) - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) value = validator.current XCTAssertEqual(value, [(1, "a"), (2, "a"), (3, "a"), (3, "b"), (3, "c")]) } @@ -210,7 +210,7 @@ final class TestCombineLatest2: XCTestCase { value = await validator.validate() XCTAssertEqual(value, [(1, "a"), (1, "b"), (1, "c"), (2, "c"), (3, "c")]) - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) value = validator.current XCTAssertEqual(value, [(1, "a"), (1, "b"), (1, "c"), (2, "c"), (3, "c")]) } @@ -250,7 +250,7 @@ final class TestCombineLatest2: XCTestCase { XCTAssertEqual(validator.failure as? Failure, Failure()) - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) value = validator.current XCTAssertEqual(value, [(1, "a"), (1, "b")]) } @@ -290,7 +290,7 @@ final class TestCombineLatest2: XCTestCase { XCTAssertEqual(validator.failure as? Failure, Failure()) - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) value = validator.current XCTAssertEqual(value, [(1, "a"), (2, "a")]) } @@ -312,11 +312,11 @@ final class TestCombineLatest2: XCTestCase { finished.fulfill() } // ensure the other task actually starts - wait(for: [iterated], timeout: 1.0) + await fulfillment(of: [iterated], timeout: 1.0) // cancellation should ensure the loop finishes // without regards to the remaining underlying sequence task.cancel() - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) } func test_combineLatest_when_cancelled() async { @@ -389,7 +389,7 @@ final class TestCombineLatest3: XCTestCase { value = await validator.validate() XCTAssertEqual(value, [(1, "a", 4), (2, "a", 4), (2, "b", 4), (2, "b", 5), (3, "b", 5), (3, "c", 5), (3, "c", 6)]) - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) value = validator.current XCTAssertEqual(value, [(1, "a", 4), (2, "a", 4), (2, "b", 4), (2, "b", 5), (3, "b", 5), (3, "c", 5), (3, "c", 6)]) } diff --git a/Tests/AsyncAlgorithmsTests/TestCompacted.swift b/Tests/AsyncAlgorithmsTests/TestCompacted.swift index b82fe31e..3e2e5198 100644 --- a/Tests/AsyncAlgorithmsTests/TestCompacted.swift +++ b/Tests/AsyncAlgorithmsTests/TestCompacted.swift @@ -83,10 +83,10 @@ final class TestCompacted: XCTestCase { finished.fulfill() } // ensure the other task actually starts - wait(for: [iterated], timeout: 1.0) + await fulfillment(of: [iterated], timeout: 1.0) // cancellation should ensure the loop finishes // without regards to the remaining underlying sequence task.cancel() - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) } } diff --git a/Tests/AsyncAlgorithmsTests/TestJoin.swift b/Tests/AsyncAlgorithmsTests/TestJoin.swift index 91de1ef9..c60b71da 100644 --- a/Tests/AsyncAlgorithmsTests/TestJoin.swift +++ b/Tests/AsyncAlgorithmsTests/TestJoin.swift @@ -122,11 +122,11 @@ final class TestJoinedBySeparator: XCTestCase { finished.fulfill() } // ensure the other task actually starts - wait(for: [iterated], timeout: 1.0) + await fulfillment(of: [iterated], timeout: 1.0) // cancellation should ensure the loop finishes // without regards to the remaining underlying sequence task.cancel() - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) } } @@ -206,10 +206,10 @@ final class TestJoined: XCTestCase { finished.fulfill() } // ensure the other task actually starts - wait(for: [iterated], timeout: 1.0) + await fulfillment(of: [iterated], timeout: 1.0) // cancellation should ensure the loop finishes // without regards to the remaining underlying sequence task.cancel() - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) } } diff --git a/Tests/AsyncAlgorithmsTests/TestLazy.swift b/Tests/AsyncAlgorithmsTests/TestLazy.swift index 1ef69d29..3ff8c5c1 100644 --- a/Tests/AsyncAlgorithmsTests/TestLazy.swift +++ b/Tests/AsyncAlgorithmsTests/TestLazy.swift @@ -121,12 +121,12 @@ final class TestLazy: XCTestCase { } // ensure the other task actually starts - wait(for: [iterated], timeout: 1.0) + await fulfillment(of: [iterated], timeout: 1.0) // cancellation should ensure the loop finishes // without regards to the remaining underlying sequence task.cancel() - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) } } diff --git a/Tests/AsyncAlgorithmsTests/TestManualClock.swift b/Tests/AsyncAlgorithmsTests/TestManualClock.swift index 045ba2de..15cc97bb 100644 --- a/Tests/AsyncAlgorithmsTests/TestManualClock.swift +++ b/Tests/AsyncAlgorithmsTests/TestManualClock.swift @@ -29,7 +29,7 @@ final class TestManualClock: XCTestCase { clock.advance() XCTAssertFalse(state.withCriticalRegion { $0 }) clock.advance() - wait(for: [afterSleep], timeout: 1.0) + await fulfillment(of: [afterSleep], timeout: 1.0) XCTAssertTrue(state.withCriticalRegion { $0 }) } @@ -51,7 +51,7 @@ final class TestManualClock: XCTestCase { XCTAssertFalse(state.withCriticalRegion { $0 }) clock.advance() task.cancel() - wait(for: [afterSleep], timeout: 1.0) + await fulfillment(of: [afterSleep], timeout: 1.0) XCTAssertTrue(state.withCriticalRegion { $0 }) XCTAssertTrue(failure.withCriticalRegion { $0 is CancellationError }) } @@ -73,7 +73,7 @@ final class TestManualClock: XCTestCase { } XCTAssertFalse(state.withCriticalRegion { $0 }) task.cancel() - wait(for: [afterSleep], timeout: 1.0) + await fulfillment(of: [afterSleep], timeout: 1.0) XCTAssertTrue(state.withCriticalRegion { $0 }) XCTAssertTrue(failure.withCriticalRegion { $0 is CancellationError }) } diff --git a/Tests/AsyncAlgorithmsTests/TestMerge.swift b/Tests/AsyncAlgorithmsTests/TestMerge.swift index 0bcb3479..c8d5e1ce 100644 --- a/Tests/AsyncAlgorithmsTests/TestMerge.swift +++ b/Tests/AsyncAlgorithmsTests/TestMerge.swift @@ -185,11 +185,11 @@ final class TestMerge2: XCTestCase { finished.fulfill() } // ensure the other task actually starts - wait(for: [iterated], timeout: 1.0) + await fulfillment(of: [iterated], timeout: 1.0) // cancellation should ensure the loop finishes // without regards to the remaining underlying sequence task.cancel() - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) } func test_merge_when_cancelled() async { @@ -509,11 +509,11 @@ final class TestMerge3: XCTestCase { finished.fulfill() } // ensure the other task actually starts - wait(for: [iterated], timeout: 1.0) + await fulfillment(of: [iterated], timeout: 1.0) // cancellation should ensure the loop finishes // without regards to the remaining underlying sequence task.cancel() - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) } // MARK: - IteratorInitialized diff --git a/Tests/AsyncAlgorithmsTests/TestReductions.swift b/Tests/AsyncAlgorithmsTests/TestReductions.swift index ad9cf5ac..24e7e4e4 100644 --- a/Tests/AsyncAlgorithmsTests/TestReductions.swift +++ b/Tests/AsyncAlgorithmsTests/TestReductions.swift @@ -217,10 +217,10 @@ final class TestReductions: XCTestCase { finished.fulfill() } // ensure the other task actually starts - wait(for: [iterated], timeout: 1.0) + await fulfillment(of: [iterated], timeout: 1.0) // cancellation should ensure the loop finishes // without regards to the remaining underlying sequence task.cancel() - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) } } diff --git a/Tests/AsyncAlgorithmsTests/TestRemoveDuplicates.swift b/Tests/AsyncAlgorithmsTests/TestRemoveDuplicates.swift index 01ddf3ff..932585b0 100644 --- a/Tests/AsyncAlgorithmsTests/TestRemoveDuplicates.swift +++ b/Tests/AsyncAlgorithmsTests/TestRemoveDuplicates.swift @@ -95,10 +95,10 @@ final class TestRemoveDuplicates: XCTestCase { finished.fulfill() } // ensure the other task actually starts - wait(for: [iterated], timeout: 1.0) + await fulfillment(of: [iterated], timeout: 1.0) // cancellation should ensure the loop finishes // without regards to the remaining underlying sequence task.cancel() - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) } } diff --git a/Tests/AsyncAlgorithmsTests/TestThrowingChannel.swift b/Tests/AsyncAlgorithmsTests/TestThrowingChannel.swift index 7dd60f18..6110c884 100644 --- a/Tests/AsyncAlgorithmsTests/TestThrowingChannel.swift +++ b/Tests/AsyncAlgorithmsTests/TestThrowingChannel.swift @@ -270,7 +270,7 @@ final class TestThrowingChannel: XCTestCase { task1.cancel() // Then: the first sending operation is resumed - wait(for: [send1IsResumed], timeout: 1.0) + await fulfillment(of: [send1IsResumed], timeout: 1.0) // When: collecting elements var iterator = sut.makeAsyncIterator() diff --git a/Tests/AsyncAlgorithmsTests/TestValidator.swift b/Tests/AsyncAlgorithmsTests/TestValidator.swift index 9c5ef9c2..67d2f37e 100644 --- a/Tests/AsyncAlgorithmsTests/TestValidator.swift +++ b/Tests/AsyncAlgorithmsTests/TestValidator.swift @@ -24,7 +24,7 @@ final class TestValidator: XCTestCase { } XCTAssertFalse(state.withCriticalRegion { $0 }) gate.open() - wait(for: [entered], timeout: 1.0) + await fulfillment(of: [entered], timeout: 1.0) XCTAssertTrue(state.withCriticalRegion { $0 }) } @@ -52,18 +52,18 @@ final class TestValidator: XCTestCase { } finished.fulfill() } - wait(for: [started], timeout: 1.0) + await fulfillment(of: [started], timeout: 1.0) XCTAssertEqual(state.withCriticalRegion { $0 }, []) gated.advance() - wait(for: [expectations[0]], timeout: 1.0) + await fulfillment(of: [expectations[0]], timeout: 1.0) XCTAssertEqual(state.withCriticalRegion { $0 }, [1]) gated.advance() - wait(for: [expectations[1]], timeout: 1.0) + await fulfillment(of: [expectations[1]], timeout: 1.0) XCTAssertEqual(state.withCriticalRegion { $0 }, [1, 2]) gated.advance() - wait(for: [expectations[2]], timeout: 1.0) + await fulfillment(of: [expectations[2]], timeout: 1.0) XCTAssertEqual(state.withCriticalRegion { $0 }, [1, 2, 3]) - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) } func test_gatedSequence_throwing() async { @@ -93,14 +93,14 @@ final class TestValidator: XCTestCase { } finished.fulfill() } - wait(for: [started], timeout: 1.0) + await fulfillment(of: [started], timeout: 1.0) XCTAssertEqual(state.withCriticalRegion { $0 }, []) gated.advance() - wait(for: [expectations[0]], timeout: 1.0) + await fulfillment(of: [expectations[0]], timeout: 1.0) XCTAssertEqual(state.withCriticalRegion { $0 }, [1]) gated.advance() XCTAssertEqual(state.withCriticalRegion { $0 }, [1]) - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) XCTAssertEqual(state.withCriticalRegion { $0 }, [1]) XCTAssertEqual(failure.withCriticalRegion { $0 as? Failure }, Failure()) } @@ -131,7 +131,7 @@ final class TestValidator: XCTestCase { XCTAssertEqual(value, [2, 3, 4]) a.advance() - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) value = validator.current XCTAssertEqual(value, [2, 3, 4]) } diff --git a/Tests/AsyncAlgorithmsTests/TestZip.swift b/Tests/AsyncAlgorithmsTests/TestZip.swift index 25bc9ec7..4c2fb229 100644 --- a/Tests/AsyncAlgorithmsTests/TestZip.swift +++ b/Tests/AsyncAlgorithmsTests/TestZip.swift @@ -152,11 +152,11 @@ final class TestZip2: XCTestCase { finished.fulfill() } // ensure the other task actually starts - wait(for: [iterated], timeout: 1.0) + await fulfillment(of: [iterated], timeout: 1.0) // cancellation should ensure the loop finishes // without regards to the remaining underlying sequence task.cancel() - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) } func test_zip_when_cancelled() async { @@ -370,10 +370,10 @@ final class TestZip3: XCTestCase { finished.fulfill() } // ensure the other task actually starts - wait(for: [iterated], timeout: 1.0) + await fulfillment(of: [iterated], timeout: 1.0) // cancellation should ensure the loop finishes // without regards to the remaining underlying sequence task.cancel() - wait(for: [finished], timeout: 1.0) + await fulfillment(of: [finished], timeout: 1.0) } }