This commit is contained in:
Christian Treffs 2020-08-05 09:49:07 +02:00
parent 040d1197b0
commit 66eac2898d
No known key found for this signature in database
GPG Key ID: 49A4B4B460BE3ED4
18 changed files with 30 additions and 54 deletions

View File

@ -5,7 +5,7 @@
// Created by Christian Treffs on 20.08.19.
//
public protocol NexusEventDelegate: class {
public protocol NexusEventDelegate: AnyObject {
func nexusEvent(_ event: NexusEvent)
func nexusNonFatalError(_ message: String)
}

View File

@ -8,11 +8,9 @@
import FirebladeECS
class EmptyComponent: Component {
}
class Name: Component {
var name: String
init(name: String) {
self.name = name
@ -20,7 +18,6 @@ class Name: Component {
}
class Position: Component {
var x: Int
var y: Int
init(x: Int, y: Int) {
@ -30,7 +27,6 @@ class Position: Component {
}
class Velocity: Component {
var a: Float
init(a: Float) {
self.a = a
@ -38,7 +34,6 @@ class Velocity: Component {
}
class Party: Component {
var partying: Bool
init(partying: Bool) {
self.partying = partying
@ -46,7 +41,6 @@ class Party: Component {
}
class Color: Component {
var r: UInt8 = 0
var g: UInt8 = 0
var b: UInt8 = 0

View File

@ -9,7 +9,6 @@ import FirebladeECS
import XCTest
class ComponentIdentifierTests: XCTestCase {
/// release: 0.034 sec
/// debug: 0.456 sec
func testMeasureStaticComponentIdentifier() {

View File

@ -9,7 +9,6 @@ import FirebladeECS
import XCTest
class HashingPerformanceTests: XCTestCase {
/// release: 0.726 sec
/// debug: 3.179 sec
func testMeasureCombineHash() {
@ -97,5 +96,4 @@ class HashingPerformanceTests: XCTestCase {
}
#endif
}
}

View File

@ -90,5 +90,4 @@ final class TypeIdentifierPerformanceTests: XCTestCase {
}
}
}
}

View File

@ -69,7 +69,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
_ = entity
loopCount += 1
}
}
}
XCTAssertEqual(loopCount, family.count * 10)
@ -86,7 +86,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
.forEach { (position: Position) in
_ = position
loopCount += 1
}
}
}
XCTAssertEqual(loopCount, numEntities * 10)
@ -110,7 +110,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
_ = position
loopCount += 1
}
}
}
XCTAssertEqual(loopCount, family.count * 10)
@ -136,7 +136,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
_ = position
loopCount += 1
}
}
}
XCTAssertEqual(loopCount, family.count * 10)
@ -161,7 +161,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
_ = velocity
loopCount += 1
}
}
}
XCTAssertEqual(loopCount, family.count * 10)
@ -187,7 +187,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
_ = velocity
loopCount += 1
}
}
}
XCTAssertEqual(loopCount, family.count * 10)
@ -212,7 +212,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
_ = name
loopCount += 1
}
}
}
XCTAssertEqual(loopCount, family.count * 10)
@ -239,7 +239,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
_ = name
loopCount += 1
}
}
}
XCTAssertEqual(loopCount, family.count * 10)
@ -265,7 +265,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
_ = color
loopCount += 1
}
}
}
XCTAssertEqual(loopCount, family.count * 10)
@ -293,7 +293,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
_ = color
loopCount += 1
}
}
}
XCTAssertEqual(loopCount, family.count * 10)
@ -348,7 +348,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
_ = empty
loopCount += 1
}
}
}
XCTAssertEqual(loopCount, family.count * 10)

View File

@ -60,7 +60,7 @@ extension TypedFamilyPerformanceTests {
}
public func __allTests() -> [XCTestCaseEntry] {
return [
[
testCase(ComponentIdentifierTests.__allTests__ComponentIdentifierTests),
testCase(HashingPerformanceTests.__allTests__HashingPerformanceTests),
testCase(TypeIdentifierPerformanceTests.__allTests__TypeIdentifierPerformanceTests),

View File

@ -8,7 +8,6 @@
import FirebladeECS
class EmptyComponent: Component {
}
class Name: Component {
@ -122,7 +121,7 @@ class ColorSystem {
color.r = 1
color.g = 2
color.b = 3
}
}
}
}
@ -136,7 +135,7 @@ class PositionSystem {
}
func randNorm() -> Double {
return 4.0
4.0
}
func update() {
@ -149,6 +148,6 @@ class PositionSystem {
pos.x = x
pos.y = y
}
}
}
}

View File

@ -7,7 +7,6 @@
import XCTest
final class ComponentIdentifierTests: XCTestCase {
func testMirrorAsStableIdentifier() {
let m = String(reflecting: Position.self)
let identifier: String = m

View File

@ -9,7 +9,6 @@ import FirebladeECS
import XCTest
final class EntityCreationTests: XCTestCase {
func testCreateEntityOneComponent() throws {
let nexus = Nexus()
let entity = nexus.createEntity {
@ -76,5 +75,4 @@ final class EntityCreationTests: XCTestCase {
XCTAssertEqual(nexus.numComponents, 200)
XCTAssertEqual(nexus.numFamilies, 0)
}
}

View File

@ -107,7 +107,6 @@ class EntityTests: XCTestCase {
XCTAssertEqual(entity[Position.self]?.x, 1234)
XCTAssertNil(entity[Velocity.self]?.a)
}
}
extension Sequence {

View File

@ -9,7 +9,6 @@ import FirebladeECS
import XCTest
final class FamilyCodingTests: XCTestCase {
func testEncodingFamily1() throws {
let nexus = Nexus()
@ -49,7 +48,6 @@ final class FamilyCodingTests: XCTestCase {
let newEntities = try family.decodeMembers(from: jsonData, using: &jsonDecoder)
XCTAssertEqual(newEntities.count, 2)
XCTAssertEqual(family.count, 2)
}
func testEncodeFamily2() throws {
@ -301,7 +299,6 @@ final class FamilyCodingTests: XCTestCase {
}
func testFailDecodingFamily() {
let jsonString = """
[
{

View File

@ -119,7 +119,7 @@ class FamilyTests: XCTestCase {
.forEach { (entity: Entity, _: Position) in
entity.assign(Velocity(a: 3.14))
entity.remove(Position.self)
}
}
XCTAssertEqual(familyA.count, 0)
XCTAssertEqual(familyB.count, 10)
@ -129,7 +129,7 @@ class FamilyTests: XCTestCase {
.forEach { (entity: Entity, velocity: Velocity) in
entity.assign(Position(x: 1, y: 2))
entity.remove(velocity)
}
}
XCTAssertEqual(familyA.count, 10)
XCTAssertEqual(familyB.count, 0)
@ -174,7 +174,7 @@ class FamilyTests: XCTestCase {
.prefix(currentCount)
.forEach { (entity: Entity) in
entity.destroy()
}
}
XCTAssertEqual(family.memberIds.count, (count / 2))

View File

@ -54,13 +54,12 @@ class HashingTests: XCTestCase {
func testStringHashes() throws {
let string = "EiMersaufEn1"
XCTAssertEqual(StringHashing.bernstein_djb2(string), 13447802024599246090)
XCTAssertEqual(StringHashing.singer_djb2(string), 5428736256651916664)
XCTAssertEqual(StringHashing.sdbm(string), 15559770072020577201)
XCTAssertEqual(StringHashing.bernstein_djb2("gamedev"), 229466792000542)
XCTAssertEqual(StringHashing.singer_djb2("gamedev"), 2867840411746895486)
XCTAssertEqual(StringHashing.sdbm("gamedev"), 2761443862055442870)
XCTAssertEqual(StringHashing.bernstein_djb2(string), 13_447_802_024_599_246_090)
XCTAssertEqual(StringHashing.singer_djb2(string), 5_428_736_256_651_916_664)
XCTAssertEqual(StringHashing.sdbm(string), 15_559_770_072_020_577_201)
XCTAssertEqual(StringHashing.bernstein_djb2("gamedev"), 229_466_792_000_542)
XCTAssertEqual(StringHashing.singer_djb2("gamedev"), 2_867_840_411_746_895_486)
XCTAssertEqual(StringHashing.sdbm("gamedev"), 2_761_443_862_055_442_870)
}
}

View File

@ -5,12 +5,11 @@
// Created by Christian Treffs on 30.09.19.
//
import XCTest
import FirebladeECS
import XCTest
@available(*, deprecated, message: "This will be removed in the next minor update.")
class SceneGraphTests: XCTestCase {
var nexus: Nexus!
override func setUp() {
@ -83,7 +82,7 @@ class SceneGraphTests: XCTestCase {
child.x += parent.x
child.y += parent.y
}
}
XCTAssertEqual(counter, 1)
XCTAssertEqual(child1Pos.x, 3)
@ -125,10 +124,9 @@ class SceneGraphTests: XCTestCase {
lastIndex = parent.index
parentSum += parent.index
childSum += child.index
}
}
XCTAssertEqual(parentSum, 36)
XCTAssertEqual(childSum, 45)
}
}

View File

@ -540,7 +540,6 @@ class SparseSetTests: XCTestCase {
}
func testAlternativeKey() {
let set = UnorderedSparseSet<Character, String>()
set.insert("A", at: "a")
@ -554,11 +553,9 @@ class SparseSetTests: XCTestCase {
XCTAssertEqual(a.0, b.0)
XCTAssertEqual(a.1, b.1)
}
}
func testEquality() {
let setA = UnorderedSparseSet<Int, String>()
let setB = UnorderedSparseSet<Int, String>()

View File

@ -121,6 +121,6 @@ class SystemsTests: XCTestCase {
.prefix(count)
.forEach { (entity: Entity) in
entity.destroy()
}
}
}
}

View File

@ -172,7 +172,7 @@ extension SystemsTests {
}
public func __allTests() -> [XCTestCaseEntry] {
return [
[
testCase(ComponentIdentifierTests.__allTests__ComponentIdentifierTests),
testCase(ComponentTests.__allTests__ComponentTests),
testCase(EntityCreationTests.__allTests__EntityCreationTests),