Skip to content

Commit 0f5c01d

Browse files
committed
withThrowingTimeout
1 parent 54c8ca7 commit 0f5c01d

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

Sources/Timeout.swift renamed to Sources/withThrowingTimeout.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Timeout.swift
2+
// withThrowingTimeout.swift
33
// swift-timeout
44
//
55
// Created by Simon Whitty on 31/08/2024.

Tests/TimeoutTests.swift renamed to Tests/withThrowingTimeoutTests.swift

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// TimeoutTests.swift
2+
// withThrowingTimeoutTests.swift
33
// swift-timeout
44
//
55
// Created by Simon Whitty on 31/08/2024.
@@ -34,7 +34,9 @@ import Timeout
3434
import Foundation
3535
import Testing
3636

37-
struct TimeoutTests {
37+
struct WithThrowingTimeoutTests {
38+
39+
3840

3941
@Test @MainActor
4042
func mainActor_ReturnsValue() async throws {
@@ -47,6 +49,17 @@ struct TimeoutTests {
4749
#expect(val == "Fish")
4850
}
4951

52+
@Test @MainActor
53+
func mainActor_ExpiresImmediatley() async throws {
54+
await #expect(throws: TimeoutError.self) { @MainActor in
55+
try await withThrowingTimeout(seconds: 1) { timeout in
56+
timeout.expireImmediatley()
57+
// t = timeout
58+
return "fish"
59+
}
60+
}
61+
}
62+
5063
@Test
5164
func mainActorThrowsError_WhenTimeoutExpires() async {
5265
await #expect(throws: TimeoutError.self) { @MainActor in

Tests/TimeoutXCTests.swift renamed to Tests/withThrowingTimeoutXCTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// TimeoutTests.swift
2+
// withThrowingXCTimeout.swift
33
// swift-timeout
44
//
55
// Created by Simon Whitty on 31/08/2024.
@@ -33,7 +33,7 @@
3333
import Timeout
3434
import XCTest
3535

36-
final class TimeoutTests: XCTestCase {
36+
final class WithThrowingTimeoutXCTests: XCTestCase {
3737

3838
@MainActor
3939
func testMainActor_ReturnsValue() async throws {

0 commit comments

Comments
 (0)