File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 11//
2- // Timeout .swift
2+ // withThrowingTimeout .swift
33// swift-timeout
44//
55// Created by Simon Whitty on 31/08/2024.
Original file line number Diff line number Diff line change 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
3434import Foundation
3535import 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
Original file line number Diff line number Diff line change 11//
2- // TimeoutTests .swift
2+ // withThrowingXCTimeout .swift
33// swift-timeout
44//
55// Created by Simon Whitty on 31/08/2024.
3333import Timeout
3434import XCTest
3535
36- final class TimeoutTests : XCTestCase {
36+ final class WithThrowingTimeoutXCTests : XCTestCase {
3737
3838 @MainActor
3939 func testMainActor_ReturnsValue( ) async throws {
You can’t perform that action at this time.
0 commit comments