mirror of
https://github.com/apple/swift-async-algorithms
synced 2026-11-30 04:58:44 +00:00
This commit is contained in:
1 parent
9d03d90a13
commit
6a8aec2a1f
3 files changed
+146
-58
No files matched your search
@@ -117,6 +117,36 @@ final class TestChannel: XCTestCase {
|
||||
XCTAssertNil(value)
|
||||
}
|
||||
|
||||
func test_sendCancellation() async {
|
||||
let channel = AsyncChannel<Int>()
|
||||
let notYetDone = expectation(description: "not yet done")
|
||||
notYetDone.isInverted = true
|
||||
let done = expectation(description: "done")
|
||||
let task = Task {
|
||||
await channel.send(1)
|
||||
notYetDone.fulfill()
|
||||
done.fulfill()
|
||||
}
|
||||
wait(for: [notYetDone], timeout: 0.1)
|
||||
task.cancel()
|
||||
wait(for: [done], timeout: 1.0)
|
||||
}
|
||||
|
||||
func test_sendCancellation_throwing() async {
|
||||
let channel = AsyncThrowingChannel<Int, Error>()
|
||||
let notYetDone = expectation(description: "not yet done")
|
||||
notYetDone.isInverted = true
|
||||
let done = expectation(description: "done")
|
||||
let task = Task {
|
||||
await channel.send(1)
|
||||
notYetDone.fulfill()
|
||||
done.fulfill()
|
||||
}
|
||||
wait(for: [notYetDone], timeout: 0.1)
|
||||
task.cancel()
|
||||
wait(for: [done], timeout: 1.0)
|
||||
}
|
||||
|
||||
func test_cancellation_throwing() async throws {
|
||||
let channel = AsyncThrowingChannel<String, Error>()
|
||||
let ready = expectation(description: "ready")
|
||||
|
||||
Reference in new issue
Block a user