mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 01:20:04 +00:00
Add test for querying more than 8 components
This commit is contained in:
parent
6d9122cfe9
commit
24f9f5868b
2 changed files with 32 additions and 7 deletions
|
@ -739,7 +739,7 @@ do
|
|||
local lastArchetype: number
|
||||
local archetype: Archetype
|
||||
local queryOutput: { any }
|
||||
local queryLength: number
|
||||
|
||||
local entities: { number }
|
||||
local i: number
|
||||
|
||||
|
@ -768,7 +768,6 @@ do
|
|||
end
|
||||
|
||||
queryOutput = {}
|
||||
queryLength = #ids
|
||||
|
||||
entities = archetype.entities
|
||||
i = #entities
|
||||
|
@ -810,7 +809,7 @@ do
|
|||
e = columns[records[E]]
|
||||
f = columns[records[F]]
|
||||
g = columns[records[G]]
|
||||
elseif H then
|
||||
elseif not I then
|
||||
a = columns[records[A]]
|
||||
b = columns[records[B]]
|
||||
c = columns[records[D]]
|
||||
|
@ -873,7 +872,7 @@ do
|
|||
e = columns[records[E]]
|
||||
f = columns[records[F]]
|
||||
g = columns[records[G]]
|
||||
elseif H then
|
||||
elseif not I then
|
||||
a = columns[records[A]]
|
||||
b = columns[records[B]]
|
||||
c = columns[records[D]]
|
||||
|
@ -919,7 +918,7 @@ do
|
|||
e[row],
|
||||
f[row],
|
||||
g[row]
|
||||
elseif H then
|
||||
elseif not I then
|
||||
return entityId,
|
||||
a[row],
|
||||
b[row],
|
||||
|
@ -1108,12 +1107,12 @@ do
|
|||
|
||||
for id in firstArchetypeMap.cache do
|
||||
local compatibleArchetype = archetypes[id]
|
||||
local archetypeRecords = compatibleArchetype.records
|
||||
local tr = compatibleArchetype.records
|
||||
|
||||
local skip = false
|
||||
|
||||
for i, componentId in components do
|
||||
local index = archetypeRecords[componentId]
|
||||
local index = tr[componentId]
|
||||
if not index then
|
||||
skip = true
|
||||
break
|
||||
|
|
|
@ -283,6 +283,32 @@ TEST("world:query()", function()
|
|||
CHECK(counter == 0)
|
||||
end
|
||||
|
||||
do CASE "query more than 8 components"
|
||||
local world = jecs.World.new()
|
||||
local components = {}
|
||||
|
||||
for i = 1, 9 do
|
||||
local id = world:component()
|
||||
components[i] = id
|
||||
end
|
||||
local e = world:entity()
|
||||
for i, id in components do
|
||||
world:set(e, id, 13^i)
|
||||
end
|
||||
|
||||
for entity, a, b, c, d, e, f, g, h, i in world:query(unpack(components)) do
|
||||
CHECK(a == 13^1)
|
||||
CHECK(b == 13^2)
|
||||
CHECK(c == 13^3)
|
||||
CHECK(d == 13^4)
|
||||
CHECK(e == 13^5)
|
||||
CHECK(f == 13^6)
|
||||
CHECK(g == 13^7)
|
||||
CHECK(h == 13^8)
|
||||
CHECK(i == 13^9)
|
||||
end
|
||||
end
|
||||
|
||||
do CASE "should be able to get next results"
|
||||
local world = jecs.World.new() :: World
|
||||
world:component()
|
||||
|
|
Loading…
Reference in a new issue