Skip to content
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/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
}