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.bak/ecs.test.lua | |
parent | d1c2a881f55b80603f6a7772a2c32394d23e795a (diff) |
add cached mesh loading
Diffstat (limited to 'honey.bak/ecs.test.lua')
-rw-r--r-- | honey.bak/ecs.test.lua | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/honey.bak/ecs.test.lua b/honey.bak/ecs.test.lua new file mode 100644 index 0000000..7814097 --- /dev/null +++ b/honey.bak/ecs.test.lua @@ -0,0 +1,51 @@ +local function test(msg, f) + local success, error = pcall(f) + if success then + print(msg .. "\t\t[OK]") + else + print(msg .. "\t\t[FAIL]") + print(error) + end +end + + +local ecs = require 'ecs' +local Filter = ecs.Filter + + +test("Filter.AND correctly matches basic keys", function() + local filter = Filter.AND{"hello", "world"} + + assert(filter{hello=true} == false) + assert(filter{world=true} == false) + assert(filter{hello=true, world=true} == true) + assert(filter{asm=true, hello=true, world=true} == true) +end) +test("Filter.AND correctly matches subfilters", function() + local subfilter = Filter.AND{"hello"} + local filter = Filter.AND{subfilter, "world"} + + assert(filter{hello=true} == false) + assert(filter{world=true} == false) + assert(filter{hello=true, world=true} == true) + assert(filter{asm=true, hello=true, world=true} == true) +end) + + +test("Filter.OR correctly matches basic keys", function() + local filter = Filter.OR{"hello", "world"} + + assert(filter{hello=true} == true) + assert(filter{world=true} == true) + assert(filter{hello=true, world=true} == true) + assert(filter{asm=true} == false) +end) +test("Filter.OR correctly matches subfilters", function() + local subfilter = Filter.OR{"hello"} + local filter = Filter.OR{subfilter, "world"} + + assert(filter{hello=true} == true) + assert(filter{world=true} == true) + assert(filter{hello=true, world=true} == true) + assert(filter{asm=true} == false) +end) |