From 45dbe47d17303050cbea7c2c51e838acfe21c2fb Mon Sep 17 00:00:00 2001 From: sanine-a Date: Tue, 28 Mar 2023 16:35:22 -0500 Subject: add cached mesh loading --- honey/ecs.test.lua | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'honey/ecs.test.lua') 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)) -- cgit v1.2.1