Skip to content

Commit

Permalink
Fixed bug where pendingPromiseDeallocated event was incorrectly repor… (
Browse files Browse the repository at this point in the history
mxcl#972)

* Fixed bug where pendingPromiseDeallocated event was incorrectly reported as a waitOnMainThread event. Added test which should have caught this bug in the first place.

* Kick Travis CI
  • Loading branch information
neallester authored and GarthSnyder committed Dec 15, 2018
1 parent 686a1e6 commit d1a38a5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/Resolver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public final class Resolver<T> {

deinit {
if case .pending = box.inspect() {
conf.logHandler(.waitOnMainThread)
conf.logHandler(.pendingPromiseDeallocated)
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions Tests/CorePromise/LoggingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,27 @@ class LoggingTests: XCTestCase {
XCTAssertEqual(logOutput!, "waitOnMainThread")
}

// Verify pendingPromiseDeallocated is logged
func testPendingPromiseDeallocatedIsLogged() {

var logOutput: String? = nil
conf.logHandler = { event in
switch event {
case .waitOnMainThread:
logOutput = "\(event)"
case .pendingPromiseDeallocated:
logOutput = "\(event)"
case .cauterized:
// Using an enum with associated value does not convert to a string properly in
// earlier versions of swift
logOutput = "cauterized"
}
}
do {
let _ = Promise<Int>.pending()
}
XCTAssertEqual ("pendingPromiseDeallocated", logOutput!)
}

//TODO Verify pending promise deallocation is logged
}

0 comments on commit d1a38a5

Please sign in to comment.