Skip to content

Commit

Permalink
clock test
Browse files Browse the repository at this point in the history
  • Loading branch information
swhitty committed Sep 8, 2024
1 parent 1896b58 commit f93f952
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Tests/TimeoutTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,24 @@ struct TimeoutTests {
try await TestActor("Fish").returningValue(after: 0.1, before: .now)
}
}

@Test
func returnsValueWithClock_beforeDeadlineExpires() async throws {
#expect(
try await withThrowingTimeout(after: .now + .seconds(2), clock: ContinuousClock()) {
"Fish"
} == "Fish"
)
}

@Test
func throwsErrorWithClock_WhenDeadlineExpires() async {
await #expect(throws: TimeoutError.self) {
try await withThrowingTimeout(after: .now, clock: ContinuousClock()) {
try await Task.sleep(for: .seconds(2))
}
}
}
}

public struct NonSendable<T> {
Expand Down

0 comments on commit f93f952

Please sign in to comment.