mirror of
https://github.com/BlackMATov/evolved.lua.git
synced 2026-09-10 13:17:15 +07:00
additional nr/to spawn/lookup tests
This commit is contained in:
@@ -607,3 +607,164 @@ do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local f1, f2 = evo.id(2)
|
||||
|
||||
do
|
||||
local entity_list, entity_count = {}, 2
|
||||
evo.multi_spawn_to(entity_list, 1, entity_count, { [f1] = 42, [f2] = "hello" })
|
||||
assert(evo.has_all(entity_list[1], f1, f2))
|
||||
assert(evo.has_all(entity_list[2], f1, f2))
|
||||
assert(evo.get(entity_list[1], f1) == 42 and evo.get(entity_list[1], f2) == "hello")
|
||||
assert(evo.get(entity_list[2], f1) == 42 and evo.get(entity_list[2], f2) == "hello")
|
||||
end
|
||||
|
||||
do
|
||||
local entity_list, entity_count = {}, 2
|
||||
evo.multi_spawn_to(entity_list, 2, entity_count, { [f1] = 42, [f2] = "hello" })
|
||||
assert(evo.has_all(entity_list[2], f1, f2))
|
||||
assert(evo.has_all(entity_list[3], f1, f2))
|
||||
assert(evo.get(entity_list[2], f1) == 42 and evo.get(entity_list[2], f2) == "hello")
|
||||
assert(evo.get(entity_list[3], f1) == 42 and evo.get(entity_list[3], f2) == "hello")
|
||||
end
|
||||
|
||||
do
|
||||
local entity_list, entity_count = {}, 2
|
||||
evo.defer()
|
||||
evo.multi_spawn_to(entity_list, 1, entity_count, { [f1] = 42, [f2] = "hello" })
|
||||
assert(entity_list[1] and entity_list[2])
|
||||
assert(evo.empty_all(entity_list[1], entity_list[2]))
|
||||
evo.commit()
|
||||
assert(evo.has_all(entity_list[1], f1, f2))
|
||||
assert(evo.has_all(entity_list[2], f1, f2))
|
||||
assert(evo.get(entity_list[1], f1) == 42 and evo.get(entity_list[1], f2) == "hello")
|
||||
assert(evo.get(entity_list[2], f1) == 42 and evo.get(entity_list[2], f2) == "hello")
|
||||
end
|
||||
|
||||
do
|
||||
local entity_list, entity_count = {}, 2
|
||||
evo.defer()
|
||||
evo.multi_spawn_to(entity_list, 2, entity_count, { [f1] = 42, [f2] = "hello" })
|
||||
assert(entity_list[2] and entity_list[3])
|
||||
assert(evo.empty_all(entity_list[2], entity_list[3]))
|
||||
evo.commit()
|
||||
assert(evo.has_all(entity_list[2], f1, f2))
|
||||
assert(evo.has_all(entity_list[3], f1, f2))
|
||||
assert(evo.get(entity_list[2], f1) == 42 and evo.get(entity_list[2], f2) == "hello")
|
||||
assert(evo.get(entity_list[3], f1) == 42 and evo.get(entity_list[3], f2) == "hello")
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local f1, f2 = evo.id(2)
|
||||
local q12 = evo.builder():include(f1, f2):spawn()
|
||||
|
||||
do
|
||||
assert(select('#', evo.multi_spawn_nr(2, { [f1] = 42, [f2] = "hello" })) == 0)
|
||||
|
||||
do
|
||||
local entity_count = 0
|
||||
|
||||
for chunk in evo.execute(q12) do
|
||||
local _, chunk_entity_count = chunk:entities()
|
||||
entity_count = entity_count + chunk_entity_count
|
||||
end
|
||||
|
||||
assert(entity_count == 2)
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local b = evo.builder():set(f1, 42):set(f2, "hello")
|
||||
|
||||
assert(select('#', b:multi_spawn_nr(2)) == 0)
|
||||
|
||||
do
|
||||
local entity_count = 0
|
||||
|
||||
for chunk in evo.execute(q12) do
|
||||
local _, chunk_entity_count = chunk:entities()
|
||||
entity_count = entity_count + chunk_entity_count
|
||||
end
|
||||
|
||||
assert(entity_count == 4)
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local b = evo.builder():set(f1, 42):set(f2, "hello")
|
||||
|
||||
assert(select('#', b:multi_build_nr(2)) == 0)
|
||||
|
||||
do
|
||||
local entity_count = 0
|
||||
|
||||
for chunk in evo.execute(q12) do
|
||||
local _, chunk_entity_count = chunk:entities()
|
||||
entity_count = entity_count + chunk_entity_count
|
||||
end
|
||||
|
||||
assert(entity_count == 6)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local f1, f2 = evo.id(2)
|
||||
local q12 = evo.builder():include(f1, f2):spawn()
|
||||
|
||||
do
|
||||
local entity_list = {}
|
||||
assert(select('#', evo.multi_spawn_to(entity_list, 1, 2, { [f1] = 42, [f2] = "hello" })) == 0)
|
||||
|
||||
do
|
||||
local entity_count = 0
|
||||
|
||||
for chunk in evo.execute(q12) do
|
||||
local _, chunk_entity_count = chunk:entities()
|
||||
entity_count = entity_count + chunk_entity_count
|
||||
end
|
||||
|
||||
assert(entity_count == 2)
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local b = evo.builder():set(f1, 42):set(f2, "hello")
|
||||
|
||||
|
||||
local entity_list = {}
|
||||
assert(select('#', b:multi_spawn_to(entity_list, 1, 2)) == 0)
|
||||
|
||||
do
|
||||
local entity_count = 0
|
||||
|
||||
for chunk in evo.execute(q12) do
|
||||
local _, chunk_entity_count = chunk:entities()
|
||||
entity_count = entity_count + chunk_entity_count
|
||||
end
|
||||
|
||||
assert(entity_count == 4)
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local b = evo.builder():set(f1, 42):set(f2, "hello")
|
||||
|
||||
|
||||
local entity_list = {}
|
||||
assert(select('#', b:multi_build_to(entity_list, 1, 2)) == 0)
|
||||
|
||||
do
|
||||
local entity_count = 0
|
||||
|
||||
for chunk in evo.execute(q12) do
|
||||
local _, chunk_entity_count = chunk:entities()
|
||||
entity_count = entity_count + chunk_entity_count
|
||||
end
|
||||
|
||||
assert(entity_count == 6)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user