mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-22 23:33:53 +01:00
Make tests Minetest-independent
This commit is contained in:
parent
09e748f37d
commit
f5dd65d772
34
test.lua
34
test.lua
@ -1,5 +1,3 @@
|
|||||||
-- TODO make tests minetest-independent
|
|
||||||
|
|
||||||
local random, huge = math.random, math.huge
|
local random, huge = math.random, math.huge
|
||||||
local parent_env = getfenv(1)
|
local parent_env = getfenv(1)
|
||||||
setfenv(1, setmetatable({}, {
|
setfenv(1, setmetatable({}, {
|
||||||
@ -112,21 +110,6 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- colorspec
|
|
||||||
local colorspec = minetest.colorspec
|
|
||||||
local function test_from_string(string, number)
|
|
||||||
local spec = colorspec.from_string(string)
|
|
||||||
local expected = colorspec.from_number(number)
|
|
||||||
assertdump(table.equals(spec, expected), {expected = expected, actual = spec})
|
|
||||||
end
|
|
||||||
local spec = colorspec.from_number(0xDDCCBBAA)
|
|
||||||
assertdump(table.equals(spec, {a = 0xAA, b = 0xBB, g = 0xCC, r = 0xDD}), spec)
|
|
||||||
test_from_string("aliceblue", 0xf0f8ffff)
|
|
||||||
test_from_string("aliceblue#42", 0xf0f8ff42)
|
|
||||||
test_from_string("#333", 0x333333FF)
|
|
||||||
test_from_string("#694269", 0x694269FF)
|
|
||||||
test_from_string("#11223344", 0x11223344)
|
|
||||||
|
|
||||||
-- k-d-tree
|
-- k-d-tree
|
||||||
local vectors = {}
|
local vectors = {}
|
||||||
for _ = 1, 1000 do
|
for _ = 1, 1000 do
|
||||||
@ -192,6 +175,23 @@ do
|
|||||||
assert_preserves(a)
|
assert_preserves(a)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not _G.minetest then return end
|
||||||
|
|
||||||
|
-- colorspec
|
||||||
|
local colorspec = minetest.colorspec
|
||||||
|
local function test_from_string(string, number)
|
||||||
|
local spec = colorspec.from_string(string)
|
||||||
|
local expected = colorspec.from_number(number)
|
||||||
|
assertdump(table.equals(spec, expected), {expected = expected, actual = spec})
|
||||||
|
end
|
||||||
|
local spec = colorspec.from_number(0xDDCCBBAA)
|
||||||
|
assertdump(table.equals(spec, {a = 0xAA, b = 0xBB, g = 0xCC, r = 0xDD}), spec)
|
||||||
|
test_from_string("aliceblue", 0xf0f8ffff)
|
||||||
|
test_from_string("aliceblue#42", 0xf0f8ff42)
|
||||||
|
test_from_string("#333", 0x333333FF)
|
||||||
|
test_from_string("#694269", 0x694269FF)
|
||||||
|
test_from_string("#11223344", 0x11223344)
|
||||||
|
|
||||||
-- in-game tests & b3d testing
|
-- in-game tests & b3d testing
|
||||||
local tests = {
|
local tests = {
|
||||||
-- depends on player_api
|
-- depends on player_api
|
||||||
|
Loading…
Reference in New Issue
Block a user