Cleanups finished for now
This commit is contained in:
parent
41745a1fa7
commit
22d65c9a6f
|
|
@ -35,35 +35,3 @@ class Velocity: Component {
|
||||||
class Party: Component {
|
class Party: Component {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DebugEventHandler: EventHandler {
|
|
||||||
|
|
||||||
let eventHub = DefaultEventHub()
|
|
||||||
|
|
||||||
var delegate: EventHub?
|
|
||||||
|
|
||||||
init() {
|
|
||||||
delegate = eventHub
|
|
||||||
subscribe(event: handleEntityCreated)
|
|
||||||
subscribe(event: handleEntityDestroyed)
|
|
||||||
subscribe(event: handleComponentAdded)
|
|
||||||
}
|
|
||||||
deinit {
|
|
||||||
unsubscribe(event: handleEntityCreated)
|
|
||||||
unsubscribe(event: handleComponentAdded)
|
|
||||||
unsubscribe(event: handleEntityDestroyed)
|
|
||||||
}
|
|
||||||
|
|
||||||
func handleEntityCreated(ec: EntityCreated) {
|
|
||||||
print(ec)
|
|
||||||
}
|
|
||||||
|
|
||||||
func handleEntityDestroyed(ed: EntityDestroyed) {
|
|
||||||
print(ed)
|
|
||||||
}
|
|
||||||
|
|
||||||
func handleComponentAdded(ca: ComponentAdded) {
|
|
||||||
print(ca)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
//
|
|
||||||
// MemoryTests.swift
|
|
||||||
// FirebladeECS
|
|
||||||
//
|
|
||||||
// Created by Christian Treffs on 09.10.17.
|
|
||||||
//
|
|
||||||
import XCTest
|
|
||||||
@testable import FirebladeECS
|
|
||||||
|
|
||||||
class MemoryTests: XCTestCase {
|
|
||||||
|
|
||||||
func testCheckRetainCount() {
|
|
||||||
|
|
||||||
class MyClass {}
|
|
||||||
let myClass = MyClass()
|
|
||||||
|
|
||||||
let initalCount: Int = FirebladeECS.retainCount(myClass)
|
|
||||||
XCTAssert(initalCount == 3)
|
|
||||||
|
|
||||||
let ownerdSelf: MyClass = myClass
|
|
||||||
_ = ownerdSelf // creates strong reference
|
|
||||||
let ownedOnceCount: Int = FirebladeECS.retainCount(myClass)
|
|
||||||
XCTAssert(ownedOnceCount == initalCount + 1) // 4
|
|
||||||
|
|
||||||
unowned let unownedSelf: MyClass = myClass
|
|
||||||
_ = unownedSelf // creates unowned refrerence
|
|
||||||
let unownedOnceCount: Int = FirebladeECS.retainCount(myClass)
|
|
||||||
let unownedCount: Int = FirebladeECS.retainCount(unownedSelf)
|
|
||||||
XCTAssert(ownedOnceCount == unownedCount)
|
|
||||||
XCTAssert(ownedOnceCount == unownedOnceCount)
|
|
||||||
|
|
||||||
weak var weakSelf: MyClass? = myClass
|
|
||||||
_ = weakSelf // creates weak refrerence
|
|
||||||
let weakOnceCount: Int = FirebladeECS.retainCount(myClass)
|
|
||||||
let weakCount: Int = FirebladeECS.retainCount(weakSelf)
|
|
||||||
XCTAssert(ownedOnceCount == weakCount)
|
|
||||||
XCTAssert(ownedOnceCount == weakOnceCount)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue