Skip to content

Instantly share code, notes, and snippets.

@inamiy
Created October 22, 2020 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inamiy/7d97a439b7914563697868b6fdffa5af to your computer and use it in GitHub Desktop.
Save inamiy/7d97a439b7914563697868b6fdffa5af to your computer and use it in GitHub Desktop.
import XCTest
import Combine
class DeinitTimingTests: XCTestCase {
func testExample() throws {
let publisher = PassthroughSubject<Void, Never>()
var cancellables = Set<AnyCancellable>()
var isDone = false
publisher
.sink {
isDone = true
}
.store(in: &cancellables)
// NOTE: `cancellables` will be deallocated here for release (-O) build.
publisher.send(())
XCTAssertTrue(isDone)
// NOTE: `cancellables` will be deallocated here for debug build.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment