Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CancellablePromise bridge initializer should run 'catch' on CurrentThreadDispatcher() #1050

Merged
merged 1 commit into from
Apr 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Cancellation/CancellablePromise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class CancellablePromise<T>: CancellableThenable, CancellableCatchMixin {
reject = seal.reject
bridge.done(on: CurrentThreadDispatcher()) {
seal.fulfill($0)
}.catch(policy: .allErrors) {
}.catch(on: CurrentThreadDispatcher(), policy: .allErrors) {
seal.reject($0)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Cancel/CatchableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ extension CatchableTests {
return promise
}
promise.catch(policy: .allErrors) { err in
err.isCancelled ? x.fulfill() : XCTFail()
err.isCancelled ? XCTFail() : x.fulfill()
}
promise.cancel()

Expand Down
2 changes: 1 addition & 1 deletion Tests/Cancel/ThenableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class ThenableTests: XCTestCase {
XCTFail()
return .value(x)
}.catch(policy: .allErrors) {
$0.isCancelled ? ex.fulfill() : XCTFail()
$0.isCancelled ? XCTFail() : ex.fulfill()
}.cancel()
wait(for: [ex], timeout: 1)
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Cancel/WhenConcurrentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class WhenConcurrentTestCase_Swift: XCTestCase {
when(fulfilled: generator, concurrently: 1).done {
XCTFail("\($0)")
}.catch(policy: .allErrors) {
$0.isCancelled ? ex.fulfill() : XCTFail()
$0.isCancelled ? XCTFail() : ex.fulfill()
}.cancel()

waitForExpectations(timeout: 3)
Expand Down
6 changes: 3 additions & 3 deletions Tests/Cancel/WhenTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class WhenTests: XCTestCase {
let p1 = CancellablePromise<Int>(error: Error.test)
let p2 = after(.milliseconds(100)).cancellize()
cancellableWhen(fulfilled: p1, p2).done{ _ in XCTFail() }.catch(policy: .allErrors) {
$0.isCancelled ? ex.fulfill() : XCTFail()
$0.isCancelled ? XCTFail() : ex.fulfill()
}.cancel()

waitForExpectations(timeout: 1, handler: nil)
Expand All @@ -300,7 +300,7 @@ class WhenTests: XCTestCase {
let p3 = after(.milliseconds(200)).cancellize().done { throw Error.straggler }

cancellableWhen(fulfilled: p1, p2, p3).catch(policy: .allErrors) {
$0.isCancelled ? ex1.fulfill() : XCTFail()
$0.isCancelled ? XCTFail() : ex1.fulfill()
}.cancel()

p2.ensure { after(.milliseconds(100)).done(ex2.fulfill) }.silenceWarning()
Expand All @@ -322,7 +322,7 @@ class WhenTests: XCTestCase {
let p3 = CancellablePromise<Void>(error: Error.test3)

when(fulfilled: p1, p2, p3).catch(policy: .allErrors) {
$0.isCancelled ? ex.fulfill() : XCTFail()
$0.isCancelled ? XCTFail() : ex.fulfill()
}.cancel()

waitForExpectations(timeout: 1)
Expand Down