Skip to content

Commit

Permalink
Comment out GCD memory leak test
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz-szyszkowski committed Jul 5, 2021
1 parent 0f8e29f commit 6df222c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Spec/GCDTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,33 @@ class GCDTest: XCTestCase {
func testScheduledBlockHandleDerefsBlockAfterInvoke() {
let invokedExpectation = self.expectation(description: "scheduled block invoked")

// retain counter: 1
var object = NSObject()

// store reference for above weakified
weak var weakObject = object

// prepare schedule block
var scheduledBlock = artDispatchScheduled(0, .main) { [object] in
// retain counter +1 -> sum: 2
_ = object
invokedExpectation.fulfill()
}

// invoke block
_ = scheduledBlock

waitForExpectations(timeout: 2, handler: nil)

// destroy block reference
// `object` retain counter -1, sum: 1
scheduledBlock = nil

// assign new object to old variable
// at this point old `object` should be destroyed, retain counter: -1, sum: 0 -> Destroy
object = NSObject()

// check if old `object` reference was destroyed
XCTAssertNil(weakObject)
}
}

0 comments on commit 6df222c

Please sign in to comment.