Add & use modlib.assertdump

This commit is contained in:
Lars Mueller 2021-03-24 20:27:02 +01:00
parent 02f24dd59f
commit 2c051cc026
2 changed files with 10 additions and 4 deletions

@ -43,7 +43,12 @@ modlib = {
__newindex = function(_, index, value)
return rawset(_G, index, value)
end
})
}),
assertdump = function(v, value)
if not v then
error(dump(value))
end
end
}
local function get_resource(modname, resource, ...)

@ -1,3 +1,5 @@
local assertdump = modlib.assertdump
-- string
assert(modlib.string.escape_magic_chars"%" == "%%")
@ -97,7 +99,7 @@ end
-- colorspec
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
local vectors = {}
@ -137,8 +139,7 @@ do
local remaining = input:read(1000)
assert(not remaining)
end)
-- TODO assertdump
assert(modlib.table.equals_references(object, read) and not err, dump{
assertdump(modlib.table.equals_references(object, read) and not err, {
object = object,
read = read,
written = written and modlib.text.hexdump(written),