Skip to content

Commit 8889884

Browse files
committed
Additional Tests
1 parent 17051a9 commit 8889884

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Tests/TaskTimeoutTests.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,21 @@ final class TaskTimeoutTests: XCTestCase {
5656
}
5757
}
5858

59+
func testSendable_ReturnsValue() async throws {
60+
let sendable = TestActor()
61+
let value = try await withThrowingTimeout(seconds: 1) {
62+
sendable
63+
}
64+
XCTAssertTrue(value === sendable)
65+
}
66+
67+
func testNonSendable_ReturnsValue() async throws {
68+
let ns = try await withThrowingTimeout(seconds: 1) {
69+
NonSendable("chips")
70+
}
71+
XCTAssertEqual(ns.value, "chips")
72+
}
73+
5974
func testActor_ReturnsValue() async throws {
6075
let val = try await TestActor().returningString("Fish")
6176
XCTAssertEqual(val, "Fish")
@@ -74,6 +89,14 @@ final class TaskTimeoutTests: XCTestCase {
7489
}
7590
}
7691

92+
public struct NonSendable<T> {
93+
public var value: T
94+
95+
init(_ value: T) {
96+
self.value = value
97+
}
98+
}
99+
77100
final actor TestActor {
78101

79102
func returningString(_ string: String = "Fish", after sleep: TimeInterval = 0, timeout: TimeInterval = 1) async throws -> String {

0 commit comments

Comments
 (0)