mirror of
https://github.com/BlackMATov/evolved.lua.git
synced 2026-03-22 04:44:06 +07:00
additional nr/to spawn/lookup tests
This commit is contained in:
@@ -397,3 +397,165 @@ do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local f1, f2 = evo.id(2)
|
||||
local p = evo.spawn { [f1] = 42, [f2] = 'hello' }
|
||||
|
||||
do
|
||||
local entity_list, entity_count = {}, 2
|
||||
evo.multi_clone_to(entity_list, 1, entity_count, p)
|
||||
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_clone_to(entity_list, 2, entity_count, p)
|
||||
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_clone_to(entity_list, 1, entity_count, p)
|
||||
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_clone_to(entity_list, 2, entity_count, p)
|
||||
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):build()
|
||||
local p = evo.spawn { [f1] = 42, [f2] = 'hello' }
|
||||
|
||||
do
|
||||
assert(select('#', evo.multi_clone_nr(2, p)) == 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 == 3)
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local b = evo.builder():set(f1, 42):set(f2, 'hello')
|
||||
|
||||
assert(select('#', b:multi_clone_nr(2, p)) == 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 == 5)
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local b = evo.builder():set(f1, 42):set(f2, 'hello')
|
||||
|
||||
assert(select('#', b:multi_build_nr(2, p)) == 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 == 7)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local f1, f2 = evo.id(2)
|
||||
local q12 = evo.builder():include(f1, f2):build()
|
||||
local p = evo.spawn { [f1] = 42, [f2] = 'hello' }
|
||||
|
||||
do
|
||||
local entity_list = {}
|
||||
assert(select('#', evo.multi_clone_to(entity_list, 1, 2, p)) == 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 == 3)
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local b = evo.builder():set(f1, 42):set(f2, 'hello')
|
||||
|
||||
local entity_list = {}
|
||||
assert(select('#', b:multi_clone_to(entity_list, 1, 2, p)) == 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 == 5)
|
||||
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, p)) == 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 == 7)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -174,3 +174,22 @@ do
|
||||
assert(entity_list and #entity_list == 0 and entity_count == 0)
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local e1, e2 = evo.id(2)
|
||||
|
||||
evo.set(e1, evo.NAME, 'lookup_e')
|
||||
evo.set(e2, evo.NAME, 'lookup_e')
|
||||
|
||||
do
|
||||
local entity_list = {}
|
||||
local entity_count = evo.multi_lookup_to(entity_list, 1, 'lookup_e')
|
||||
assert(entity_count == 2 and entity_list[1] == e1 and entity_list[2] == e2)
|
||||
end
|
||||
|
||||
do
|
||||
local entity_list = {}
|
||||
local entity_count = evo.multi_lookup_to(entity_list, 2, 'lookup_e')
|
||||
assert(entity_count == 2 and entity_list[2] == e1 and entity_list[3] == e2)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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