Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce the overall warnings from tests #274

Merged
merged 3 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/AsyncSequenceValidation/Clock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
6 changes: 6 additions & 0 deletions Sources/AsyncSequenceValidation/Test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down
5 changes: 3 additions & 2 deletions Tests/AsyncAlgorithmsTests/TestAdjacentPairs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
8 changes: 4 additions & 4 deletions Tests/AsyncAlgorithmsTests/TestBuffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions Tests/AsyncAlgorithmsTests/TestBufferedByteIterator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
8 changes: 4 additions & 4 deletions Tests/AsyncAlgorithmsTests/TestChain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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)
}
}
2 changes: 1 addition & 1 deletion Tests/AsyncAlgorithmsTests/TestChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
18 changes: 9 additions & 9 deletions Tests/AsyncAlgorithmsTests/TestCombineLatest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")])
}
Expand Down Expand Up @@ -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")])
}
Expand Down Expand Up @@ -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")])
}
Expand Down Expand Up @@ -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")])
}
Expand Down Expand Up @@ -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")])
}
Expand Down Expand Up @@ -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")])
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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)])
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/AsyncAlgorithmsTests/TestCompacted.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
8 changes: 4 additions & 4 deletions Tests/AsyncAlgorithmsTests/TestJoin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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)
}
}
4 changes: 2 additions & 2 deletions Tests/AsyncAlgorithmsTests/TestLazy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
6 changes: 3 additions & 3 deletions Tests/AsyncAlgorithmsTests/TestManualClock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
}

Expand All @@ -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 })
}
Expand All @@ -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 })
}
Expand Down
8 changes: 4 additions & 4 deletions Tests/AsyncAlgorithmsTests/TestMerge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Tests/AsyncAlgorithmsTests/TestReductions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
4 changes: 2 additions & 2 deletions Tests/AsyncAlgorithmsTests/TestRemoveDuplicates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
2 changes: 1 addition & 1 deletion Tests/AsyncAlgorithmsTests/TestThrowingChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading