mirror of
https://github.com/BlackMATov/evolved.lua.git
synced 2025-12-13 11:38:15 +07:00
49 lines
1.3 KiB
Lua
49 lines
1.3 KiB
Lua
local evo = require 'evolved'
|
|
|
|
do
|
|
local e1, e2, f1, f2 = evo.id(4)
|
|
|
|
do
|
|
local chunk, place = evo.locate(e1)
|
|
assert(chunk == nil and place == 0)
|
|
end
|
|
|
|
evo.set(e1, f1, 42)
|
|
|
|
do
|
|
local chunk, place = evo.locate(e1)
|
|
assert(chunk and chunk == evo.chunk(f1) and place == 1)
|
|
assert(chunk:components(f1)[place] == 42)
|
|
|
|
chunk, place = evo.locate(e2)
|
|
assert(chunk == nil and place == 0)
|
|
end
|
|
|
|
evo.set(e1, f2, 'hello')
|
|
|
|
do
|
|
local chunk, place = evo.locate(e1)
|
|
assert(chunk and chunk == evo.chunk(f1, f2) and place == 1)
|
|
assert(chunk:components(f1)[place] == 42)
|
|
assert(chunk:components(f2)[place] == 'hello')
|
|
|
|
chunk, place = evo.locate(e2)
|
|
assert(chunk == nil and place == 0)
|
|
end
|
|
|
|
evo.set(e2, f1, 84)
|
|
evo.set(e2, f2, 'world')
|
|
|
|
do
|
|
local chunk, place = evo.locate(e1)
|
|
assert(chunk and chunk == evo.chunk(f1, f2) and place == 1)
|
|
assert(chunk:components(f1)[place] == 42)
|
|
assert(chunk:components(f2)[place] == 'hello')
|
|
|
|
chunk, place = evo.locate(e2)
|
|
assert(chunk and chunk == evo.chunk(f1, f2) and place == 2)
|
|
assert(chunk:components(f1)[place] == 84)
|
|
assert(chunk:components(f2)[place] == 'world')
|
|
end
|
|
end
|