deferred spawning support

This commit is contained in:
BlackMATov
2025-01-18 01:31:20 +07:00
parent 76afc420f4
commit 253d9e2246
4 changed files with 584 additions and 446 deletions

View File

@@ -669,128 +669,6 @@ basics.describe_bench(string.format('create and destroy %d entities with 5 compo
print '----------------------------------------'
basics.describe_bench(string.format('create and destroy %d entities / spawn', N),
---@param entities evolved.id[]
function(entities)
local spawn = evo.spawn
local destroy = evo.destroy
local fragments = {}
local components = {}
for i = 1, N do
entities[i] = spawn(fragments, components)
end
for i = 1, #entities do
destroy(entities[i])
end
end, function()
return {}
end)
basics.describe_bench(string.format('create and destroy %d entities with 1 components / spawn', N),
---@param entities evolved.id[]
function(entities)
local spawn = evo.spawn
local destroy = evo.destroy
local fragments = { F1 }
local components = { true }
for i = 1, N do
entities[i] = spawn(fragments, components)
end
for i = 1, #entities do
destroy(entities[i])
end
end, function()
return {}
end)
basics.describe_bench(string.format('create and destroy %d entities with 2 components / spawn', N),
---@param entities evolved.id[]
function(entities)
local spawn = evo.spawn
local destroy = evo.destroy
local fragments = { F1, F2 }
local components = { true, true }
for i = 1, N do
entities[i] = spawn(fragments, components)
end
for i = 1, #entities do
destroy(entities[i])
end
end, function()
return {}
end)
basics.describe_bench(string.format('create and destroy %d entities with 3 components / spawn', N),
---@param entities evolved.id[]
function(entities)
local spawn = evo.spawn
local destroy = evo.destroy
local fragments = { F1, F2, F3 }
local components = { true, true, true }
for i = 1, N do
entities[i] = spawn(fragments, components)
end
for i = 1, #entities do
destroy(entities[i])
end
end, function()
return {}
end)
basics.describe_bench(string.format('create and destroy %d entities with 4 components / spawn', N),
---@param entities evolved.id[]
function(entities)
local spawn = evo.spawn
local destroy = evo.destroy
local fragments = { F1, F2, F3, F4 }
local components = { true, true, true, true }
for i = 1, N do
entities[i] = spawn(fragments, components)
end
for i = 1, #entities do
destroy(entities[i])
end
end, function()
return {}
end)
basics.describe_bench(string.format('create and destroy %d entities with 5 components / spawn', N),
---@param entities evolved.id[]
function(entities)
local spawn = evo.spawn
local destroy = evo.destroy
local fragments = { F1, F2, F3, F4, F5 }
local components = { true, true, true, true, true }
for i = 1, N do
entities[i] = spawn(fragments, components)
end
for i = 1, #entities do
destroy(entities[i])
end
end, function()
return {}
end)
print '----------------------------------------'
basics.describe_bench(string.format('create and destroy %d entities / spawn_at', N),
---@param entities evolved.id[]
function(entities)
@@ -925,132 +803,124 @@ basics.describe_bench(string.format('create and destroy %d entities with 5 compo
print '----------------------------------------'
---
--- initial
---
basics.describe_bench(string.format('create and destroy %d entities / spawn_with', N),
---@param entities evolved.id[]
function(entities)
local spawn_with = evo.spawn_with
local destroy = evo.destroy
--[[ lua 5.1
| create and destroy 1k entities ... |
PASS | us: 312.60 | op/s: 3199.00 | kb/i: 0.05
| create and destroy 1k entities with 1 component ... |
PASS | us: 1570.31 | op/s: 636.82 | kb/i: 0.63
| create and destroy 1k entities with 2 components ... |
PASS | us: 2780.82 | op/s: 359.61 | kb/i: 0.91
| create and destroy 1k entities with 3 components ... |
PASS | us: 4060.00 | op/s: 246.31 | kb/i: 1.67
]]
local fragments = {}
local components = {}
--[[ luajit 2.1
| create and destroy 1k entities ... |
PASS | us: 12.22 | op/s: 81840.80 | kb/i: 0.00
| create and destroy 1k entities with 1 component ... |
PASS | us: 56.22 | op/s: 17786.07 | kb/i: 0.02
| create and destroy 1k entities with 2 components ... |
PASS | us: 412.73 | op/s: 2422.89 | kb/i: 0.11
| create and destroy 1k entities with 3 components ... |
PASS | us: 611.62 | op/s: 1635.00 | kb/i: 0.17
]]
for i = 1, N do
entities[i] = spawn_with(fragments, components)
end
---
--- unpack ids without dedicated functions
---
for i = 1, #entities do
destroy(entities[i])
end
end, function()
return {}
end)
--[[ lua 5.1
| create and destroy 1k entities ... |
PASS | us: 255.40 | op/s: 3915.42 | kb/i: 0.04
| create and destroy 1k entities with 1 component ... |
PASS | us: 1248.45 | op/s: 801.00 | kb/i: 0.50
| create and destroy 1k entities with 2 components ... |
PASS | us: 2208.79 | op/s: 452.74 | kb/i: 0.73
| create and destroy 1k entities with 3 components ... |
PASS | us: 3278.69 | op/s: 305.00 | kb/i: 1.37
]]
basics.describe_bench(string.format('create and destroy %d entities with 1 components / spawn_with', N),
---@param entities evolved.id[]
function(entities)
local spawn_with = evo.spawn_with
local destroy = evo.destroy
--[[ luajit 2.1
| create and destroy 1k entities ... |
PASS | us: 12.12 | op/s: 82482.59 | kb/i: 0.00
| create and destroy 1k entities with 1 component ... |
PASS | us: 69.05 | op/s: 14482.59 | kb/i: 0.03
| create and destroy 1k entities with 2 components ... |
PASS | us: 400.40 | op/s: 2497.51 | kb/i: 0.09
| create and destroy 1k entities with 3 components ... |
PASS | us: 574.71 | op/s: 1740.00 | kb/i: 0.14
]]
local fragments = { F1 }
local components = { true }
---
--- hook flags for chunks
---
for i = 1, N do
entities[i] = spawn_with(fragments, components)
end
--[[ lua 5.1
| create and destroy 1k entities ... |
PASS | us: 255.40 | op/s: 3915.42 | kb/i: 0.04
| create and destroy 1k entities with 1 component ... |
PASS | us: 1005.03 | op/s: 995.00 | kb/i: 0.41
| create and destroy 1k entities with 2 components ... |
PASS | us: 1747.83 | op/s: 572.14 | kb/i: 0.59
| create and destroy 1k entities with 3 components ... |
PASS | us: 2576.92 | op/s: 388.06 | kb/i: 1.08
]]
for i = 1, #entities do
destroy(entities[i])
end
end, function()
return {}
end)
--[[ luajit 2.1
| create and destroy 1k entities ... |
PASS | us: 12.20 | op/s: 81940.30 | kb/i: 0.00
| create and destroy 1k entities with 1 component ... |
PASS | us: 53.66 | op/s: 18636.82 | kb/i: 0.02
| create and destroy 1k entities with 2 components ... |
PASS | us: 357.02 | op/s: 2801.00 | kb/i: 0.09
| create and destroy 1k entities with 3 components ... |
PASS | us: 533.33 | op/s: 1875.00 | kb/i: 0.15
]]
basics.describe_bench(string.format('create and destroy %d entities with 2 components / spawn_with', N),
---@param entities evolved.id[]
function(entities)
local spawn_with = evo.spawn_with
local destroy = evo.destroy
---
--- construct flags for chunks
---
local fragments = { F1, F2 }
local components = { true, true }
--[[ lua 5.1
| create and destroy 1k entities ... |
PASS | us: 253.49 | op/s: 3945.00 | kb/i: 0.04
| create and destroy 1k entities with 1 component ... |
PASS | us: 913.64 | op/s: 1094.53 | kb/i: 0.37
| create and destroy 1k entities with 2 components ... |
PASS | us: 1562.50 | op/s: 640.00 | kb/i: 0.53
| create and destroy 1k entities with 3 components ... |
PASS | us: 2280.90 | op/s: 438.42 | kb/i: 0.97
]]
for i = 1, N do
entities[i] = spawn_with(fragments, components)
end
--[[ luajit 2.1
| create and destroy 1k entities ... |
PASS | us: 12.05 | op/s: 82995.02 | kb/i: 0.00
| create and destroy 1k entities with 1 component ... |
PASS | us: 53.61 | op/s: 18651.74 | kb/i: 0.02
| create and destroy 1k entities with 2 components ... |
PASS | us: 232.02 | op/s: 4310.00 | kb/i: 0.06
| create and destroy 1k entities with 3 components ... |
PASS | us: 329.49 | op/s: 3035.00 | kb/i: 0.10
]]
for i = 1, #entities do
destroy(entities[i])
end
end, function()
return {}
end)
---
--- after chunks refactoring
---
basics.describe_bench(string.format('create and destroy %d entities with 3 components / spawn_with', N),
---@param entities evolved.id[]
function(entities)
local spawn_with = evo.spawn_with
local destroy = evo.destroy
--[[ lua 5.1
| create and destroy 1k entities ... |
PASS | us: 254.45 | op/s: 3930.00 | kb/i: 0.04
| create and destroy 1k entities with 1 component ... |
PASS | us: 897.32 | op/s: 1114.43 | kb/i: 0.36
| create and destroy 1k entities with 2 components ... |
PASS | us: 1481.48 | op/s: 675.00 | kb/i: 0.49
| create and destroy 1k entities with 3 components ... |
PASS | us: 2126.32 | op/s: 470.30 | kb/i: 0.90
]]
local fragments = { F1, F2, F3 }
local components = { true, true, true }
--[[ luajit 2.1
| create and destroy 1k entities ... |
PASS | us: 12.31 | op/s: 81248.76 | kb/i: 0.00
| create and destroy 1k entities with 1 component ... |
PASS | us: 46.97 | op/s: 21288.56 | kb/i: 0.02
| create and destroy 1k entities with 2 components ... |
PASS | us: 75.19 | op/s: 13300.00 | kb/i: 0.03
| create and destroy 1k entities with 3 components ... |
PASS | us: 108.28 | op/s: 9235.00 | kb/i: 0.06
]]
for i = 1, N do
entities[i] = spawn_with(fragments, components)
end
for i = 1, #entities do
destroy(entities[i])
end
end, function()
return {}
end)
basics.describe_bench(string.format('create and destroy %d entities with 4 components / spawn_with', N),
---@param entities evolved.id[]
function(entities)
local spawn_with = evo.spawn_with
local destroy = evo.destroy
local fragments = { F1, F2, F3, F4 }
local components = { true, true, true, true }
for i = 1, N do
entities[i] = spawn_with(fragments, components)
end
for i = 1, #entities do
destroy(entities[i])
end
end, function()
return {}
end)
basics.describe_bench(string.format('create and destroy %d entities with 5 components / spawn_with', N),
---@param entities evolved.id[]
function(entities)
local spawn_with = evo.spawn_with
local destroy = evo.destroy
local fragments = { F1, F2, F3, F4, F5 }
local components = { true, true, true, true, true }
for i = 1, N do
entities[i] = spawn_with(fragments, components)
end
for i = 1, #entities do
destroy(entities[i])
end
end, function()
return {}
end)
print '----------------------------------------'

View File

@@ -3153,66 +3153,66 @@ do
evo.set(f3, evo.TAG)
do
local e = evo.spawn()
local e = evo.spawn_with()
assert(evo.is_alive(e) and evo.is_empty(e))
end
do
local e = evo.spawn({})
local e = evo.spawn_with({})
assert(evo.is_alive(e) and evo.is_empty(e))
end
do
local e1 = evo.spawn({ f1 })
local e1 = evo.spawn_with({ f1 })
assert(evo.has(e1, f1) and evo.get(e1, f1) == true)
local e2 = evo.spawn({ f1 }, {})
local e2 = evo.spawn_with({ f1 }, {})
assert(evo.has(e2, f1) and evo.get(e2, f1) == true)
local e3 = evo.spawn({ f1 }, { 41 })
local e3 = evo.spawn_with({ f1 }, { 41 })
assert(evo.has(e3, f1) and evo.get(e3, f1) == 41)
end
do
local e1 = evo.spawn({ f1, f2 })
local e1 = evo.spawn_with({ f1, f2 })
assert(evo.has_all(e1, f1, f2))
assert(evo.get(e1, f1) == true and evo.get(e1, f2) == true)
local e2 = evo.spawn({ f1, f2 }, {})
local e2 = evo.spawn_with({ f1, f2 }, {})
assert(evo.has_all(e2, f1, f2))
assert(evo.get(e2, f1) == true and evo.get(e2, f2) == true)
local e3 = evo.spawn({ f1, f2 }, { 41 })
local e3 = evo.spawn_with({ f1, f2 }, { 41 })
assert(evo.has_all(e3, f1, f2))
assert(evo.get(e3, f1) == 41 and evo.get(e3, f2) == true)
local e4 = evo.spawn({ f1, f2 }, { nil, 42 })
local e4 = evo.spawn_with({ f1, f2 }, { nil, 42 })
assert(evo.has_all(e4, f1, f2))
assert(evo.get(e4, f1) == true and evo.get(e4, f2) == 42)
local e5 = evo.spawn({ f1, f2 }, { 41, 42 })
local e5 = evo.spawn_with({ f1, f2 }, { 41, 42 })
assert(evo.has_all(e5, f1, f2))
assert(evo.get(e5, f1) == 41 and evo.get(e5, f2) == 42)
local e6 = evo.spawn({ f1, f2 }, { 41, 42, 43 })
local e6 = evo.spawn_with({ f1, f2 }, { 41, 42, 43 })
assert(evo.has_all(e6, f1, f2))
assert(evo.get(e6, f1) == 41 and evo.get(e6, f2) == 42)
end
do
local e1 = evo.spawn({ f3 })
local e1 = evo.spawn_with({ f3 })
assert(evo.has(e1, f3))
assert(evo.get(e1, f3) == nil)
local e2 = evo.spawn({ f2, f3 })
local e2 = evo.spawn_with({ f2, f3 })
assert(evo.has_all(e2, f2, f3))
assert(evo.get(e2, f2) == true and evo.get(e2, f3) == nil)
local e3 = evo.spawn({ f2, f3 }, { 42 })
local e3 = evo.spawn_with({ f2, f3 }, { 42 })
assert(evo.has_all(e3, f2, f3))
assert(evo.get(e3, f2) == 42 and evo.get(e3, f3) == nil)
local e4 = evo.spawn({ f2, f3 }, { 42, 43, 44 })
local e4 = evo.spawn_with({ f2, f3 }, { 42, 43, 44 })
assert(evo.has_all(e4, f2, f3))
assert(evo.get(e4, f2) == 42 and evo.get(e4, f3) == nil)
end
@@ -3225,66 +3225,66 @@ do
evo.set(f3, evo.TAG)
do
local e = evo.spawn()
local e = evo.spawn_with()
assert(evo.is_alive(e) and evo.is_empty(e))
end
do
local e = evo.spawn({})
local e = evo.spawn_with({})
assert(evo.is_alive(e) and evo.is_empty(e))
end
do
local e1 = evo.spawn({ f1 })
local e1 = evo.spawn_with({ f1 })
assert(evo.has(e1, f1) and evo.get(e1, f1) == true)
local e2 = evo.spawn({ f1 }, {})
local e2 = evo.spawn_with({ f1 }, {})
assert(evo.has(e2, f1) and evo.get(e2, f1) == true)
local e3 = evo.spawn({ f1 }, { 41 })
local e3 = evo.spawn_with({ f1 }, { 41 })
assert(evo.has(e3, f1) and evo.get(e3, f1) == 41)
end
do
local e1 = evo.spawn({ f1, f2 })
local e1 = evo.spawn_with({ f1, f2 })
assert(evo.has_all(e1, f1, f2))
assert(evo.get(e1, f1) == true and evo.get(e1, f2) == 21)
local e2 = evo.spawn({ f1, f2 }, {})
local e2 = evo.spawn_with({ f1, f2 }, {})
assert(evo.has_all(e2, f1, f2))
assert(evo.get(e2, f1) == true and evo.get(e2, f2) == 21)
local e3 = evo.spawn({ f1, f2 }, { 41 })
local e3 = evo.spawn_with({ f1, f2 }, { 41 })
assert(evo.has_all(e3, f1, f2))
assert(evo.get(e3, f1) == 41 and evo.get(e3, f2) == 21)
local e4 = evo.spawn({ f1, f2 }, { nil, 42 })
local e4 = evo.spawn_with({ f1, f2 }, { nil, 42 })
assert(evo.has_all(e4, f1, f2))
assert(evo.get(e4, f1) == true and evo.get(e4, f2) == 42)
local e5 = evo.spawn({ f1, f2 }, { 41, 42 })
local e5 = evo.spawn_with({ f1, f2 }, { 41, 42 })
assert(evo.has_all(e5, f1, f2))
assert(evo.get(e5, f1) == 41 and evo.get(e5, f2) == 42)
local e6 = evo.spawn({ f1, f2 }, { 41, 42, 43 })
local e6 = evo.spawn_with({ f1, f2 }, { 41, 42, 43 })
assert(evo.has_all(e6, f1, f2))
assert(evo.get(e6, f1) == 41 and evo.get(e6, f2) == 42)
end
do
local e1 = evo.spawn({ f3 })
local e1 = evo.spawn_with({ f3 })
assert(evo.has(e1, f3))
assert(evo.get(e1, f3) == nil)
local e2 = evo.spawn({ f2, f3 })
local e2 = evo.spawn_with({ f2, f3 })
assert(evo.has_all(e2, f2, f3))
assert(evo.get(e2, f2) == 21 and evo.get(e2, f3) == nil)
local e3 = evo.spawn({ f2, f3 }, { 42 })
local e3 = evo.spawn_with({ f2, f3 }, { 42 })
assert(evo.has_all(e3, f2, f3))
assert(evo.get(e3, f2) == 42 and evo.get(e3, f3) == nil)
local e4 = evo.spawn({ f2, f3 }, { 42, 43, 44 })
local e4 = evo.spawn_with({ f2, f3 }, { 42, 43, 44 })
assert(evo.has_all(e4, f2, f3))
assert(evo.get(e4, f2) == 42 and evo.get(e4, f3) == nil)
end
@@ -3292,12 +3292,14 @@ end
do
local cf = evo.id()
local f1, f2 = evo.id(2)
local f1, f2, f3 = evo.id(3)
evo.set(f1, cf)
evo.set(f2, cf)
evo.set(f3, cf)
evo.set(f2, evo.DEFAULT, 21)
evo.set(f3, evo.TAG)
local set_count = 0
local insert_count = 0
@@ -3311,14 +3313,14 @@ do
evo.batch_set(q, evo.ON_SET, function(e, f, c)
last_set_entity = e
assert(f == f1 or f == f2)
assert(f == f1 or f == f2 or f == f3)
last_set_component = c
set_count = set_count + 1
end)
evo.batch_set(q, evo.ON_INSERT, function(e, f, c)
last_insert_entity = e
assert(f == f1 or f == f2)
assert(f == f1 or f == f2 or f == f3)
last_insert_component = c
insert_count = insert_count + 1
end)
@@ -3331,7 +3333,7 @@ do
set_count, insert_count = 0, 0
last_set_entity, last_set_component = 0, 0
last_insert_entity, last_insert_component = 0, 0
local e = evo.spawn({ f1 })
local e = evo.spawn_with({ f1 })
assert(set_count == 1 and insert_count == 1)
assert(last_set_entity == e and last_set_component == true)
assert(last_insert_entity == e and last_insert_component == true)
@@ -3341,7 +3343,7 @@ do
set_count, insert_count = 0, 0
last_set_entity, last_set_component = 0, 0
last_insert_entity, last_insert_component = 0, 0
local e = evo.spawn({ f2 })
local e = evo.spawn_with({ f2 })
assert(set_count == 1 and insert_count == 1)
assert(last_set_entity == e and last_set_component == 21)
assert(last_insert_entity == e and last_insert_component == 21)
@@ -3351,11 +3353,31 @@ do
set_count, insert_count = 0, 0
last_set_entity, last_set_component = 0, 0
last_insert_entity, last_insert_component = 0, 0
local e = evo.spawn({ f1, f2 })
local e = evo.spawn_with({ f1, f2 })
assert(set_count == 2 and insert_count == 2)
assert(last_set_entity == e and last_set_component == 21)
assert(last_insert_entity == e and last_insert_component == 21)
end
do
set_count, insert_count = 0, 0
last_set_entity, last_set_component = 0, 0
last_insert_entity, last_insert_component = 0, 0
local e = evo.spawn_with({ f3 }, { 33 })
assert(set_count == 1 and insert_count == 1)
assert(last_set_entity == e and last_set_component == nil)
assert(last_insert_entity == e and last_insert_component == nil)
end
do
set_count, insert_count = 0, 0
last_set_entity, last_set_component = 0, 0
last_insert_entity, last_insert_component = 0, 0
local e = evo.spawn_with({ f3, f2 }, { 33, 22 })
assert(set_count == 2 and insert_count == 2)
assert(last_set_entity == e and last_set_component == nil)
assert(last_insert_entity == e and last_insert_component == nil)
end
end
do
@@ -3469,12 +3491,14 @@ end
do
local cf = evo.id()
local f1, f2 = evo.id(2)
local f1, f2, f3 = evo.id(3)
evo.set(f1, cf)
evo.set(f2, cf)
evo.set(f3, cf)
evo.set(f2, evo.DEFAULT, 22)
evo.set(f3, evo.TAG)
local set_count = 0
local insert_count = 0
@@ -3488,14 +3512,14 @@ do
evo.batch_set(q, evo.ON_SET, function(e, f, c)
last_set_entity = e
assert(f == f1 or f == f2)
assert(f == f1 or f == f2 or f == f3)
last_set_component = c
set_count = set_count + 1
end)
evo.batch_set(q, evo.ON_INSERT, function(e, f, c)
last_insert_entity = e
assert(f == f1 or f == f2)
assert(f == f1 or f == f2 or f == f3)
last_insert_component = c
insert_count = insert_count + 1
end)
@@ -3536,4 +3560,153 @@ do
assert(last_set_entity == e and last_set_component == 22)
assert(last_insert_entity == e and last_insert_component == 22)
end
do
set_count, insert_count = 0, 0
last_set_entity, last_set_component = 0, 0
last_insert_entity, last_insert_component = 0, 0
local c = evo.chunk(f3)
local e = evo.spawn_at(c)
assert(set_count == 1 and insert_count == 1)
assert(last_set_entity == e and last_set_component == nil)
assert(last_insert_entity == e and last_insert_component == nil)
end
do
set_count, insert_count = 0, 0
last_set_entity, last_set_component = 0, 0
last_insert_entity, last_insert_component = 0, 0
local c = evo.chunk(f3, f2)
local e = evo.spawn_at(c, { f3, f2 }, { 33, 22 })
assert(set_count == 2 and insert_count == 2)
assert(last_set_entity == e and last_set_component == nil)
assert(last_insert_entity == e and last_insert_component == nil)
end
end
do
local f1, f2, f3, f4 = evo.id(4)
evo.set(f3, evo.DEFAULT, 3)
evo.set(f4, evo.TAG)
do
assert(evo.defer())
local e, d = evo.spawn_with()
assert(evo.is_alive(e) and evo.is_empty(e))
assert(not d)
assert(evo.commit())
assert(evo.is_alive(e) and evo.is_empty(e))
end
do
assert(evo.defer())
local e, d = evo.spawn_with({})
assert(evo.is_alive(e) and evo.is_empty(e))
assert(not d)
assert(evo.commit())
assert(evo.is_alive(e) and evo.is_empty(e))
end
do
assert(evo.defer())
local e1, d1 = evo.spawn_with({ f1 })
assert(evo.is_alive(e1) and evo.is_empty(e1))
assert(d1)
assert(evo.commit())
assert(evo.is_alive(e1) and not evo.is_empty(e1))
assert(evo.has(e1, f1) and evo.get(e1, f1) == true)
assert(evo.defer())
local e2, d2 = evo.spawn_with({ f1 }, {})
assert(evo.is_alive(e2) and evo.is_empty(e2))
assert(d2)
assert(evo.commit())
assert(evo.is_alive(e2) and not evo.is_empty(e2))
assert(evo.has(e2, f1) and evo.get(e2, f1) == true)
assert(evo.defer())
local e3, d3 = evo.spawn_with({ f1 }, { 41 })
assert(evo.is_alive(e3) and evo.is_empty(e3))
assert(d3)
assert(evo.commit())
assert(evo.is_alive(e3) and not evo.is_empty(e3))
assert(evo.has(e3, f1) and evo.get(e3, f1) == 41)
end
do
assert(evo.defer())
local e1, d1 = evo.spawn_with({ f1, f2 })
assert(evo.is_alive(e1) and evo.is_empty(e1))
assert(d1)
assert(evo.commit())
assert(evo.is_alive(e1) and not evo.is_empty(e1))
assert(evo.has(e1, f1) and evo.get(e1, f1) == true)
assert(evo.has(e1, f2) and evo.get(e1, f2) == true)
assert(evo.defer())
local e2, d2 = evo.spawn_with({ f1, f2 }, {})
assert(evo.is_alive(e2) and evo.is_empty(e2))
assert(d2)
assert(evo.commit())
assert(evo.is_alive(e2) and not evo.is_empty(e2))
assert(evo.has(e2, f1) and evo.get(e2, f1) == true)
assert(evo.has(e2, f2) and evo.get(e2, f2) == true)
assert(evo.defer())
local e3, d3 = evo.spawn_with({ f1, f2 }, { 41 })
assert(evo.is_alive(e3) and evo.is_empty(e3))
assert(d3)
assert(evo.commit())
assert(evo.is_alive(e3) and not evo.is_empty(e3))
assert(evo.has(e3, f1) and evo.get(e3, f1) == 41)
assert(evo.has(e3, f2) and evo.get(e3, f2) == true)
assert(evo.defer())
local e4, d4 = evo.spawn_with({ f1, f2 }, { nil, 42 })
assert(evo.is_alive(e4) and evo.is_empty(e4))
assert(d4)
assert(evo.commit())
assert(evo.is_alive(e4) and not evo.is_empty(e4))
assert(evo.has(e4, f1) and evo.get(e4, f1) == true)
assert(evo.has(e4, f2) and evo.get(e4, f2) == 42)
assert(evo.defer())
local e5, d5 = evo.spawn_with({ f1, f2 }, { 41, 42 })
assert(evo.is_alive(e5) and evo.is_empty(e5))
assert(d5)
assert(evo.commit())
assert(evo.is_alive(e5) and not evo.is_empty(e5))
assert(evo.has(e5, f1) and evo.get(e5, f1) == 41)
assert(evo.has(e5, f2) and evo.get(e5, f2) == 42)
assert(evo.defer())
local e6, d6 = evo.spawn_with({ f1, f2 }, { 41, 42, 43 })
assert(evo.is_alive(e6) and evo.is_empty(e6))
assert(d6)
assert(evo.commit())
assert(evo.is_alive(e6) and not evo.is_empty(e6))
assert(evo.has(e6, f1) and evo.get(e6, f1) == 41)
assert(evo.has(e6, f2) and evo.get(e6, f2) == 42)
end
do
assert(evo.defer())
local e1, d1 = evo.spawn_with({ f3, f4 })
assert(evo.is_alive(e1) and evo.is_empty(e1))
assert(d1)
assert(evo.commit())
assert(evo.is_alive(e1) and not evo.is_empty(e1))
assert(evo.has(e1, f3) and evo.get(e1, f3) == 3)
assert(evo.has(e1, f4) and evo.get(e1, f4) == nil)
assert(evo.defer())
local e2, d2 = evo.spawn_with({ f3, f4 }, { 33, 44 })
assert(evo.is_alive(e2) and evo.is_empty(e2))
assert(d2)
assert(evo.commit())
assert(evo.is_alive(e2) and not evo.is_empty(e2))
assert(evo.has(e2, f3) and evo.get(e2, f3) == 33)
assert(evo.has(e2, f4) and evo.get(e2, f4) == nil)
end
end