mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-24 17:10:03 +00:00
Fix table.move usage in query_cached (#173)
Some checks failed
Analysis / Run Luau Analyze (push) Has been cancelled
Deploy VitePress site to Pages / build (push) Has been cancelled
Publish to NPM / publish (push) Has been cancelled
Unit Testing / Run Luau Tests (push) Has been cancelled
Deploy VitePress site to Pages / Deploy (push) Has been cancelled
Some checks failed
Analysis / Run Luau Analyze (push) Has been cancelled
Deploy VitePress site to Pages / build (push) Has been cancelled
Publish to NPM / publish (push) Has been cancelled
Unit Testing / Run Luau Tests (push) Has been cancelled
Deploy VitePress site to Pages / Deploy (push) Has been cancelled
* Fix table.move usage in query_cached * Add test case
This commit is contained in:
parent
aafafc90b2
commit
509048b9df
2 changed files with 18 additions and 1 deletions
|
@ -1589,7 +1589,7 @@ local function query_cached(query: QueryInner)
|
||||||
local with = query.filter_with
|
local with = query.filter_with
|
||||||
local ids = query.ids
|
local ids = query.ids
|
||||||
if with then
|
if with then
|
||||||
table.move(ids, 1, #ids, #with, with)
|
table.move(ids, 1, #ids, #with + 1, with)
|
||||||
else
|
else
|
||||||
query.filter_with = ids
|
query.filter_with = ids
|
||||||
end
|
end
|
||||||
|
|
|
@ -1495,5 +1495,22 @@ TEST("repro", function()
|
||||||
end
|
end
|
||||||
CHECK(counter == 1)
|
CHECK(counter == 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
do CASE "#3" -- ISSUE #171
|
||||||
|
local world = world_new()
|
||||||
|
local component1 = world:component()
|
||||||
|
local tag1 = world:entity()
|
||||||
|
|
||||||
|
local query = world:query(component1):with(tag1):cached()
|
||||||
|
|
||||||
|
local entity = world:entity()
|
||||||
|
world:set(entity, component1, "some data")
|
||||||
|
|
||||||
|
local counter = 0
|
||||||
|
for x in query:iter() do
|
||||||
|
counter += 1
|
||||||
|
end
|
||||||
|
CHECK(counter == 0)
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
FINISH()
|
FINISH()
|
||||||
|
|
Loading…
Reference in a new issue