1
0
mirror of https://github.com/minetest/minetest.git synced 2025-07-01 07:30:23 +02:00

Rename minetest.register_async_metatable to minetest.register_portable_metatable (#14895)

This commit is contained in:
y5nw
2024-08-02 00:13:25 +02:00
committed by GitHub
parent d566b0e280
commit 8bff2f23c6
4 changed files with 18 additions and 12 deletions

View File

@ -167,18 +167,18 @@ local function test_userdata_passing2(cb, _, pos)
end
unittests.register("test_userdata_passing2", test_userdata_passing2, {map=true, async=true})
local function test_async_metatable_override()
assert(pcall(core.register_async_metatable, "__builtin:vector", vector.metatable),
local function test_portable_metatable_override()
assert(pcall(core.register_portable_metatable, "__builtin:vector", vector.metatable),
"Metatable name aliasing throws an error when it should be allowed")
assert(not pcall(core.register_async_metatable, "__builtin:vector", {}),
assert(not pcall(core.register_portable_metatable, "__builtin:vector", {}),
"Illegal metatable overriding allowed")
end
unittests.register("test_async_metatable_override", test_async_metatable_override)
unittests.register("test_portable_metatable_override", test_portable_metatable_override)
local function test_async_metatable_registration(cb)
local function test_portable_metatable_registration(cb)
local custom_metatable = {}
core.register_async_metatable("unittests:custom_metatable", custom_metatable)
core.register_portable_metatable("unittests:custom_metatable", custom_metatable)
core.handle_async(function(x)
-- unittests.custom_metatable is registered in inside_async_env.lua
@ -193,7 +193,7 @@ local function test_async_metatable_registration(cb)
cb()
end, setmetatable({}, custom_metatable))
end
unittests.register("test_async_metatable_registration", test_async_metatable_registration, {async=true})
unittests.register("test_portable_metatable_registration", test_portable_metatable_registration, {async=true})
local function test_vector_preserve(cb)
local vec = vector.new(1, 2, 3)

View File

@ -3,7 +3,7 @@ unittests = {}
core.log("info", "Hello World")
unittests.custom_metatable = {}
core.register_async_metatable("unittests:custom_metatable", unittests.custom_metatable)
core.register_portable_metatable("unittests:custom_metatable", unittests.custom_metatable)
local function do_tests()
assert(core == minetest)