diff --git a/.tests/parse/file/testfiles/parse_valid_delta.weaschem b/.tests/parse/file/testfiles/parse_valid_delta.weaschem new file mode 100644 index 0000000..64ce036 --- /dev/null +++ b/.tests/parse/file/testfiles/parse_valid_delta.weaschem @@ -0,0 +1,7 @@ +WEASCHEM 1 +{"name":"Test schematic","description": "Some description","size":{"x":5,"y":3,"z":4},"offset":{"x":1,"y":0,"z":2},"type":"delta","generator": "WorldEditAdditions v1.14"} +{"0":"default:air","5":"default:stone","14":"default:dirt"} +10x5,40x14,0,5,14,5,-1,5x0 +10x0,1,0,2x1,0,5x0,40x1 +10x5,40x-2,0,5,14,5,14,5x0 +10x0,1,0,2x1,0,5x0,40x1 \ No newline at end of file diff --git a/.tests/parse/file/weaschem_parse.test.lua b/.tests/parse/file/weaschem_parse.test.lua index c9fce2f..d12cbdb 100644 --- a/.tests/parse/file/weaschem_parse.test.lua +++ b/.tests/parse/file/weaschem_parse.test.lua @@ -99,4 +99,68 @@ describe("parse.file.weaschem.parse", function() assert.are.same("UNEXPECTED_TOKEN", code) assert.are.same("string", type(result)) end) + + it("should parse a valid delta file", function() + local handle = make_handle("valid_delta") + + local success, code, result = weaschem.parse(handle) + + print("DEBUG:parse", inspect(result)) + + assert.are.same(true, success) + assert.are.same("SUCCESS", code) + assert.are.same("table", type(result)) + assert.are.same({ + id_map = { + [0] = "default:air", [14] = "default:dirt", [5] = "default:stone", }, + header = { + offset = { + y = 0, x = 1, z = 2, }, + type = "delta", + description = "Some description", + generator = "WorldEditAdditions v1.14", + name = "Test schematic", + size = { + y = 3, x = 5, z = 4, } + }, + data_tables = { + data_prev = { + [1] = 5, [2] = 5, [3] = 5, [4] = 5, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 5, [10] = 14, + [11] = 14, [12] = 14, [13] = 14, [14] = 14, [15] = 14, [16] = 14, [17] = 14, [18] = 14, [19] = 14, + [20] = 14, [21] = 14, [22] = 14, [23] = 14, [24] = 14, [25] = 14, [26] = 14, [27] = 14, [28] = 14, + [29] = 14, [30] = 14, [31] = 14, [32] = 14, [33] = 14, [34] = 14, [35] = 14, [36] = 14, [37] = 14, + [38] = 14, [39] = 14, [40] = 14, [41] = 14, [42] = 14, [43] = 14, [44] = 14, [45] = 14, [46] = 14, + [47] = 14, [48] = 14, [49] = 14, [50] = 0, [51] = 5, [52] = 14, [53] = 5, [54] = -1, [55] = 0, + [56] = 0, [57] = 0, [58] = 0, [59] = 0, [0] = 5 + }, + data_current = { + [1] = 5, [2] = 5, [3] = 5, [4] = 5, [5] = 5, [6] = 5, [7] = 5, [8] = 5, [9] = 5, [10] = -2, + [11] = -2, [12] = -2, [13] = -2, [14] = -2, [15] = -2, [16] = -2, [17] = -2, [18] = -2, [19] = -2, + [20] = -2, [21] = -2, [22] = -2, [23] = -2, [24] = -2, [25] = -2, [26] = -2, [27] = -2, [28] = -2, + [29] = -2, [30] = -2, [31] = -2, [32] = -2, [33] = -2, [34] = -2, [35] = -2, [36] = -2, [37] = -2, + [38] = -2, [39] = -2, [40] = -2, [41] = -2, [42] = -2, [43] = -2, [44] = -2, [45] = -2, [46] = -2, + [47] = -2, [48] = -2, [49] = -2, [50] = 0, [51] = 5, [52] = 14, [53] = 5, [54] = 14, [55] = 0, + [56] = 0, [57] = 0, [58] = 0, [59] = 0, [0] = 5 + }, + param2_prev = { + [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0, [10] = 1, [11] = 0, + [12] = 1, [13] = 1, [14] = 0, [15] = 0, [16] = 0, [17] = 0, [18] = 0, [19] = 0, [20] = 1, [21] = 1, + [22] = 1, [23] = 1, [24] = 1, [25] = 1, [26] = 1, [27] = 1, [28] = 1, [29] = 1, [30] = 1, [31] = 1, + [32] = 1, [33] = 1, [34] = 1, [35] = 1, [36] = 1, [37] = 1, [38] = 1, [39] = 1, [40] = 1, [41] = 1, + [42] = 1, [43] = 1, [44] = 1, [45] = 1, [46] = 1, [47] = 1, [48] = 1, [49] = 1, [50] = 1, [51] = 1, + [52] = 1, [53] = 1, [54] = 1, [55] = 1, [56] = 1, [57] = 1, [58] = 1, [59] = 1, [0] = 0 + }, + param2_current = { + [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0, [10] = 1, [11] = 0, + [12] = 1, [13] = 1, [14] = 0, [15] = 0, [16] = 0, [17] = 0, [18] = 0, [19] = 0, [20] = 1, [21] = 1, + [22] = 1, [23] = 1, [24] = 1, [25] = 1, [26] = 1, [27] = 1, [28] = 1, [29] = 1, [30] = 1, [31] = 1, + [32] = 1, [33] = 1, [34] = 1, [35] = 1, [36] = 1, [37] = 1, [38] = 1, [39] = 1, [40] = 1, [41] = 1, + [42] = 1, [43] = 1, [44] = 1, [45] = 1, [46] = 1, [47] = 1, [48] = 1, [49] = 1, [50] = 1, [51] = 1, + [52] = 1, [53] = 1, [54] = 1, [55] = 1, [56] = 1, [57] = 1, [58] = 1, [59] = 1, [0] = 0 + } + } + }, result) + + -- TODO: Test delta_which more thoroughly. + end) end)