Permalink
Browse files

Fixed bug where pendingPromiseDeallocated event was incorrectly repor… (

#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 mxcl committed Dec 14, 2018
1 parent 358ed97 commit 5bb2aae8cc8be4d712f544a69c3940d29aad93a1
Showing with 23 additions and 1 deletion.
  1. +1 −1 Sources/Resolver.swift
  2. +22 −0 Tests/CorePromise/LoggingTests.swift
@@ -8,7 +8,7 @@ public final class Resolver<T> {

deinit {
if case .pending = box.inspect() {
conf.logHandler(.waitOnMainThread)
conf.logHandler(.pendingPromiseDeallocated)
}
}
}
@@ -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 5bb2aae

Please sign in to comment.