mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-26 17:23:45 +01:00
Add & use modlib.assertdump
This commit is contained in:
parent
02f24dd59f
commit
2c051cc026
7
init.lua
7
init.lua
@ -43,7 +43,12 @@ modlib = {
|
|||||||
__newindex = function(_, index, value)
|
__newindex = function(_, index, value)
|
||||||
return rawset(_G, index, value)
|
return rawset(_G, index, value)
|
||||||
end
|
end
|
||||||
})
|
}),
|
||||||
|
assertdump = function(v, value)
|
||||||
|
if not v then
|
||||||
|
error(dump(value))
|
||||||
|
end
|
||||||
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
local function get_resource(modname, resource, ...)
|
local function get_resource(modname, resource, ...)
|
||||||
|
7
test.lua
7
test.lua
@ -1,3 +1,5 @@
|
|||||||
|
local assertdump = modlib.assertdump
|
||||||
|
|
||||||
-- string
|
-- string
|
||||||
assert(modlib.string.escape_magic_chars"%" == "%%")
|
assert(modlib.string.escape_magic_chars"%" == "%%")
|
||||||
|
|
||||||
@ -97,7 +99,7 @@ end
|
|||||||
|
|
||||||
-- colorspec
|
-- colorspec
|
||||||
local colorspec = modlib.minetest.colorspec.from_number(0xDDCCBBAA)
|
local colorspec = modlib.minetest.colorspec.from_number(0xDDCCBBAA)
|
||||||
assert(modlib.table.equals(colorspec, {a = 0xAA, b = 0xBB, g = 0xCC, r = 0xDD,}), dump(colorspec))
|
assertdump(modlib.table.equals(colorspec, {a = 0xAA, b = 0xBB, g = 0xCC, r = 0xDD,}), colorspec)
|
||||||
|
|
||||||
-- k-d-tree
|
-- k-d-tree
|
||||||
local vectors = {}
|
local vectors = {}
|
||||||
@ -137,8 +139,7 @@ do
|
|||||||
local remaining = input:read(1000)
|
local remaining = input:read(1000)
|
||||||
assert(not remaining)
|
assert(not remaining)
|
||||||
end)
|
end)
|
||||||
-- TODO assertdump
|
assertdump(modlib.table.equals_references(object, read) and not err, {
|
||||||
assert(modlib.table.equals_references(object, read) and not err, dump{
|
|
||||||
object = object,
|
object = object,
|
||||||
read = read,
|
read = read,
|
||||||
written = written and modlib.text.hexdump(written),
|
written = written and modlib.text.hexdump(written),
|
||||||
|
Loading…
Reference in New Issue
Block a user