Fix sorting + add sorting test.

This commit is contained in:
bakpakin
2015-06-18 16:02:16 -04:00
parent 1fd32dab9a
commit cb9ab332d2
2 changed files with 21 additions and 7 deletions
+13
View File
@@ -215,6 +215,19 @@ describe('tiny-ecs:', function()
assert.equals(1, world:getSystemIndex(oneTimeSystem))
end)
it("Sorts Entities in Sorting Systems", function()
local sortsys = tiny.system({}, {"sorted"})
sortsys.filter = tiny.requireAll("vel")
function sortsys:compare(e1, e2)
return e1.vel.x < e2.vel.x
end
world:add(sortsys)
world:update(0)
assert.equals(sortsys.entities[1], entity2)
assert.equals(sortsys.entities[2], entity3)
assert.equals(sortsys.entities[3], entity1)
end)
end)
end)