Skip to content

Instantly share code, notes, and snippets.

@polac24
Last active February 24, 2019 10:57
Show Gist options
  • Save polac24/e0cc3c1dc52d5716432695beed728719 to your computer and use it in GitHub Desktop.
Save polac24/e0cc3c1dc52d5716432695beed728719 to your computer and use it in GitHub Desktop.
func testListenerKeptWithWeakReference() {
// Arrange
let sut = MasterClass()
var listener: MasterClassListener? = MasterListener()
weak var weakListener = listener
// Act
sut.add(listener!)
listener = nil
// Assert
XCTAssertNil(weakListener)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment