tests/codecs (m-z): comments: specs only
This commit is contained in:
1 parent
98b4ce533e
commit
a6732d45f2
23 files changed
+46
-177
No files matched your search
@@ -1,6 +1,4 @@
|
||||
-- codecs/model/Minecraft tests: packed index arrays (spanning and not, 1..16 bits, against a bit-by-bit reference),
|
||||
-- Sponge varints, nibble arrays, YZX reordering, block-state strings and their NBT form, every legacy id / data pair
|
||||
-- through legacyState / legacyId, colours (air, families, fallbacks), voxels / blocksOf and nearest-colour blocks.
|
||||
-- codecs/model/Minecraft tests: packed arrays, varints, nibbles, block states, legacy ids, colours, voxels.
|
||||
-- The formats using it: tests/model/schematic.luau, tests/model/mca.luau.
|
||||
local T = require("@tests/T")
|
||||
local Mc = require("@rosetta/codecs/model/Minecraft")
|
||||
@@ -10,7 +8,7 @@ local t = T.suite("minecraft")
|
||||
local P = Mc.Packed
|
||||
local rand = T.rng(3)
|
||||
|
||||
-- 1. packed arrays against a reference that walks the bits one at a time
|
||||
-- packed arrays against a reference that walks the bits one at a time
|
||||
local function refBit(longs: buffer, p: number): number
|
||||
return bit32.extract(buffer.readu8(longs, p // 8), p % 8, 1)
|
||||
end
|
||||
@@ -52,7 +50,6 @@ do
|
||||
t:eq(P.bitsFor(1, 2), 2, "bitsFor minimum")
|
||||
end
|
||||
|
||||
-- 2. varints, nibbles, YZX
|
||||
do
|
||||
local idx = buffer.create(400)
|
||||
for i = 0, 199 do
|
||||
@@ -84,7 +81,6 @@ do
|
||||
t:eq(buffer.tostring(P.toYzx(vox, sx, sy, sz)), buffer.tostring(yzx), "toYzx")
|
||||
end
|
||||
|
||||
-- 3. states
|
||||
do
|
||||
local name, props = Mc.parseState("oak_log[axis=y, foo = bar]")
|
||||
t:eq(name, "minecraft:oak_log", "namespace added")
|
||||
@@ -97,7 +93,7 @@ do
|
||||
t:check(Mc.isAir("minecraft:cave_air") and not Mc.isAir("minecraft:stone"), "isAir")
|
||||
end
|
||||
|
||||
-- 4. legacy ids: every id / data pair reads back exactly
|
||||
-- legacy ids: every id / data pair reads back exactly
|
||||
do
|
||||
local bad = 0
|
||||
for id = 0, 255 do
|
||||
@@ -116,7 +112,6 @@ do
|
||||
t:eq(select(1, Mc.legacyId("minecraft:white_concrete")), 251, "modern name -> legacy id")
|
||||
end
|
||||
|
||||
-- 5. colours
|
||||
do
|
||||
t:eq(Mc.color("minecraft:air"), nil, "air")
|
||||
local function hex(s: string): string
|
||||
@@ -132,7 +127,6 @@ do
|
||||
t:eq(hex("mod:something_odd"), "909090ff", "fallback")
|
||||
end
|
||||
|
||||
-- 6. voxels / blocksOf
|
||||
do
|
||||
local states = { "minecraft:air", "minecraft:stone", "minecraft:red_wool", "minecraft:stone" }
|
||||
local idx = buffer.create(8 * 2)
|
||||
|
||||
Reference in new issue
Block a user