more bits for version

This commit is contained in:
BlackMATov
2025-03-15 00:51:00 +07:00
parent e84111a0f7
commit dca3bd0f67
2 changed files with 40 additions and 12 deletions

View File

@@ -4,15 +4,10 @@ local evo = require 'evolved'
evo.debug_mode(true)
do
local e1, e2 = evo.id(), evo.id()
assert(e1 ~= e2)
end
do
local i = evo.id()
for _ = 1, 0xFFE do
for _ = 1, 0xFFFFE do
local _, v0 = evo.unpack(i)
evo.destroy(i)
i = evo.id()
@@ -22,7 +17,7 @@ do
do
local _, v = evo.unpack(i)
assert(v == 0xFFF)
assert(v == 0xFFFFF)
end
evo.destroy(i)
@@ -34,6 +29,31 @@ do
end
end
do
local e1, e2 = evo.id(), evo.id()
assert(e1 ~= e2)
assert(evo.is_alive(e1))
assert(evo.is_alive(e2))
assert(evo.destroy(e1))
assert(not evo.is_alive(e1))
assert(evo.is_alive(e2))
assert(evo.destroy(e1))
assert(evo.destroy(e2))
assert(not evo.is_alive(e1))
assert(not evo.is_alive(e2))
assert(evo.destroy(e1))
assert(evo.destroy(e2))
assert(not evo.is_alive(e1))
assert(not evo.is_alive(e2))
end
do
do
local i0 = evo.id(0)
@@ -5076,9 +5096,15 @@ do
end
do
local id = evo.pack(0xFFFFF, 0xFFF)
local id = evo.pack(0xBCDEF, 0xFEDCB)
local index, version = evo.unpack(id)
assert(index == 0xFFFFF and version == 0xFFF)
assert(index == 0xBCDEF and version == 0xFEDCB)
end
do
local id = evo.pack(0xFFFFF, 0xFFFFF)
local index, version = evo.unpack(id)
assert(index == 0xFFFFF and version == 0xFFFFF)
end
do

View File

@@ -269,7 +269,7 @@ local function __release_id(id)
__error_fmt('id is not acquired or already released')
end
shifted_version = shifted_version == 0xFFF00000
shifted_version = shifted_version == 0xFFFFF00000
and 0x100000
or shifted_version + 0x100000
@@ -4621,8 +4621,8 @@ __evolved_pack = function(index, version)
__error_fmt('id index out of range [1;0xFFFFF]')
end
if version < 1 or version > 0xFFF then
__error_fmt('id version out of range [1;0xFFF]')
if version < 1 or version > 0xFFFFF then
__error_fmt('id version out of range [1;0xFFFFF]')
end
local shifted_version = version * 0x100000
@@ -7989,4 +7989,6 @@ evolved.query = __evolved_query
evolved.phase = __evolved_phase
evolved.system = __evolved_system
evolved.collect_garbage()
return evolved