tests/model: comments: specs only
This commit is contained in:
1 parent
5f7f6005f6
commit
fe7566cbba
37 files changed
+72
-440
No files matched your search
@@ -1,9 +1,5 @@
|
||||
-- model/schematic tests: .litematic files written by litemapy (several regions, negative sizes, a 40-state palette,
|
||||
-- tile entities), Sponge .schem v2 (litemapy) and v1 / v3 (nbtlib, by the spec; two-byte varints), MCEdit
|
||||
-- .schematic (legacy ids + data, WorldEdit AddBlocks, a Schematica name table): every cell's block state, placement,
|
||||
-- block entities; our re-encodings give the same NBT for the same variant, and the reference readers (litemapy /
|
||||
-- nbtlib, in the fixture step) read our output, across variants and from colour-only grids, to the same cells;
|
||||
-- detection, the api, error codes and the fuzz pass. Fixtures: tools/fixtures/schematic.py.
|
||||
-- model/schematic tests: litemapy / nbtlib-written .litematic, .schem v1-v3 and MCEdit .schematic files; they read ours.
|
||||
-- Fixtures: tools/fixtures/schematic.py.
|
||||
local T = require("@tests/T")
|
||||
local F = require("@rosetta")
|
||||
local Schematic = require("@rosetta/model/schematic")
|
||||
@@ -61,7 +57,6 @@ local function sameRegion(got: any, want: any, label: string)
|
||||
end
|
||||
end
|
||||
|
||||
-- 1. reference files
|
||||
local decoded: { [string]: Types.Scene } = {}
|
||||
for _, c in Fx.cases do
|
||||
local scene, err = dec(c.data)
|
||||
@@ -108,13 +103,11 @@ for _, c in Fx.cases do
|
||||
for i, r in regions(again) do
|
||||
sameRegion(r, regs[i], c.name .. " again region " .. i)
|
||||
end
|
||||
-- api: detection by content (the flavour) and loading
|
||||
t:eq(F.detect(c.data), c.variant, c.name .. ": F.detect")
|
||||
local viaApi = F.load(c.data)
|
||||
t:check(viaApi and viaApi.kind == "scene", c.name .. ": F.load")
|
||||
end
|
||||
|
||||
-- 2. our encodings read back by litemapy / nbtlib (fixture step)
|
||||
local outputs: { [string]: () -> (buffer?, any) } = {}
|
||||
local function colorGrid(): Types.Voxels
|
||||
local v = Types.Voxels.new(4, 3, 2)
|
||||
@@ -156,7 +149,6 @@ for name, ref in Ours do
|
||||
count += 1
|
||||
end
|
||||
t:eq(count, 14, "every output checked")
|
||||
-- the source cells survive the conversions
|
||||
do
|
||||
local function cellsVia(name: string): string
|
||||
return regions(assert(dec(assert(outputs[name]()))))[1].cells
|
||||
@@ -177,7 +169,6 @@ do
|
||||
t:eq(first[4], "minecraft:light_blue_stained_glass", "translucent blue -> stained glass")
|
||||
end
|
||||
|
||||
-- 3. through the api
|
||||
do
|
||||
local scene = assert(F.load(Fx.cases[1].data, { name = "x.litematic" }))
|
||||
local schem = assert(F.save(scene, nil, { format = "schem" })) :: buffer
|
||||
@@ -193,7 +184,6 @@ do
|
||||
t:check(F.save(g, nil, { format = "schem" }) ~= nil, "save a bare Voxels")
|
||||
end
|
||||
|
||||
-- 4. errors
|
||||
do
|
||||
local _, e1 = dec(assert(Nbt.encode(Nbt.compound({ a = 1 }, { "a" }))))
|
||||
t:check(e1 and e1.code == Err.CORRUPT, "not a schematic")
|
||||
@@ -208,7 +198,7 @@ do
|
||||
t:check(e5 and e5.code == Err.TRUNCATED, "short Blocks")
|
||||
end
|
||||
|
||||
-- 5. fuzz (the uncompressed NBT too, so mutations reach the layouts, not just gzip's CRC)
|
||||
-- fuzz the uncompressed NBT too, so mutations reach the layouts, not just gzip's CRC
|
||||
local samples = {}
|
||||
for _, c in Fx.cases do
|
||||
local s = assert(dec(c.data))
|
||||
|
||||
Reference in new issue
Block a user