Skip to content

Commit 4a9422f

Browse files
committed
wip: add more tests
1 parent 8048f3c commit 4a9422f

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

Sources/AsyncObjects/TaskOperation.swift

+7-4
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,9 @@ public final class TaskOperation<R: Sendable>: Operation, AsyncObject, Loggable,
273273
) async throws {
274274
let key = UUID()
275275
log("Waiting", id: key, file: file, function: function, line: line)
276-
for await _ in event { break }
276+
var iter = event.makeAsyncIterator()
277+
await iter.next()
278+
277279
do {
278280
try Task.checkCancellation()
279281
} catch {
@@ -283,10 +285,11 @@ public final class TaskOperation<R: Sendable>: Operation, AsyncObject, Loggable,
283285
)
284286
throw error
285287
}
286-
do {
287-
let _ = try await execTask?.value
288+
289+
switch await self.result {
290+
case .success:
288291
log("Finished", id: key, file: file, function: function, line: line)
289-
} catch {
292+
case .failure(let error):
290293
log(
291294
"Finished with error: \(error)", id: key,
292295
file: file, function: function, line: line

Tests/AsyncObjectsTests/TaskOperationTests.swift

+4
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@ class TaskOperationTaskManagementTests: XCTestCase {
276276
XCTAssertFalse(error.localizedDescription.isEmpty)
277277
default: XCTFail("Unexpected operation result")
278278
}
279+
do {
280+
try await operation.wait(forSeconds: 3)
281+
XCTFail("Unexpected task progression")
282+
} catch is CancellationError {}
279283
}
280284
}
281285

0 commit comments

Comments
 (0)