diff options
author | sanine-a <sanine.not@pm.me> | 2023-03-28 16:35:22 -0500 |
---|---|---|
committer | sanine-a <sanine.not@pm.me> | 2023-03-28 16:35:22 -0500 |
commit | 45dbe47d17303050cbea7c2c51e838acfe21c2fb (patch) | |
tree | c2827c7aae6cf29286766209af942f16f91ee4c8 /honey/ecs.test.lua | |
parent | d1c2a881f55b80603f6a7772a2c32394d23e795a (diff) |
add cached mesh loading
Diffstat (limited to 'honey/ecs.test.lua')
-rw-r--r-- | honey/ecs.test.lua | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/honey/ecs.test.lua b/honey/ecs.test.lua index 0577dcd..74e27dc 100644 --- a/honey/ecs.test.lua +++ b/honey/ecs.test.lua @@ -229,4 +229,52 @@ test("EntityDb.deleteEntity() correctly removes an entity", function() end) +--===== SystemDb tests =====-- + +local SystemDb = ecs.SystemDb + +test("addSystem() correctly sorts systems", function() + local sdb = SystemDb(nil) + local str = "" + sdb:addSystem(function () return { + update=function(self, dt) str = str .. "c" end, + priority = 3, + } end) + sdb:addSystem{ + update=function(self, dt) str = "a" end, + priority = 1, + } + sdb:addSystem{ + update=function(self, dt) str = str .. "b" end, + priority = 2, + } + sdb:update(0) + assert(str == "abc") +end) + + +test("removeSystem() correctly handles things", function() + local sdb = SystemDb(nil) + local str = "" + sdb:addSystem(function () return { + update=function(self, dt) str = str .. "c" end, + priority = 3, + } end) + sdb:addSystem{ + update=function(self, dt) str = "a" end, + priority = 1, + } + local id = sdb:addSystem{ + update=function(self, dt) str = str .. "b" end, + priority = 2, + } + sdb:update(0) + assert(str == "abc") + + sdb:removeSystem(id) + sdb:update(1) + assert(str == "ac") +end) + + print(string.format("ran %d tests, %d failed", testCount, failCount)) |