mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-12-04 13:03:59 +01:00
Update to parser tests
This commit is contained in:
parent
7e9e0f6a48
commit
f9652c9621
@ -11,64 +11,68 @@ describe("parse_keyword", function()
|
||||
-- Basic tests
|
||||
it("should work on single axes", function()
|
||||
local ktype, axis, sign = parse_keyword("x")
|
||||
assert.are.equals(ktype, "axis")
|
||||
assert.are.same(axis, {"x"})
|
||||
assert.are.equals(sign, 1)
|
||||
assert.are.equals("axis", ktype)
|
||||
assert.are.same({"x"}, axis)
|
||||
assert.are.equals(1, sign)
|
||||
end)
|
||||
|
||||
it("should work with axis clumping", function()
|
||||
local ktype, axis, sign = parse_keyword("zx")
|
||||
assert.are.equals(ktype, "axis")
|
||||
assert.are.same(axis, {"x", "z"})
|
||||
assert.are.equals(sign, 1)
|
||||
assert.are.equals("axis", ktype)
|
||||
assert.are.same({"x", "z"}, axis)
|
||||
assert.are.equals(1, sign)
|
||||
end)
|
||||
|
||||
it("should work with h and v", function()
|
||||
local ktype, axis, sign = parse_keyword("hv")
|
||||
assert.are.equals(ktype, "axis")
|
||||
assert.are.same(axis, {"h", "v"})
|
||||
assert.are.equals(sign, 1)
|
||||
assert.are.equals("axis", ktype)
|
||||
assert.are.same(
|
||||
{"x", "y", "z", rev={"x", "y", "z"}},
|
||||
axis)
|
||||
assert.are.equals(1, sign)
|
||||
end)
|
||||
|
||||
it("should work with h and v in clumping", function()
|
||||
local ktype, axis, sign = parse_keyword("hyxz")
|
||||
assert.are.equals(ktype, "axis")
|
||||
assert.are.same(axis, {"h", "y"})
|
||||
assert.are.equals(sign, 1)
|
||||
assert.are.equals("axis", ktype)
|
||||
assert.are.same(
|
||||
{"x", "y", "z", rev={"x", "z"}},
|
||||
axis)
|
||||
assert.are.equals(1, sign)
|
||||
end)
|
||||
|
||||
it("should work with negatives", function()
|
||||
local ktype, axis, sign = parse_keyword("-xv")
|
||||
assert.are.equals(ktype, "axis")
|
||||
assert.are.same(axis, {"v", "x"})
|
||||
assert.are.equals(sign, -1)
|
||||
assert.are.equals("axis", ktype)
|
||||
assert.are.same({"x", "y", rev={"y"}}, axis)
|
||||
assert.are.equals(-1, sign)
|
||||
end)
|
||||
|
||||
it("should work with dirs", function()
|
||||
local ktype, axis, sign = parse_keyword("left")
|
||||
assert.are.equals(ktype, "dir")
|
||||
assert.are.equals(axis, "left")
|
||||
assert.are.equals(sign, 1)
|
||||
assert.are.equals("dir", ktype)
|
||||
assert.are.equals("left", axis)
|
||||
assert.are.equals(1, sign)
|
||||
end)
|
||||
|
||||
it("should work with negative dirs", function()
|
||||
local ktype, axis, sign = parse_keyword("-right")
|
||||
assert.are.equals(ktype, "dir")
|
||||
assert.are.equals(axis, "right")
|
||||
assert.are.equals(sign, -1)
|
||||
assert.are.equals("dir", ktype)
|
||||
assert.are.equals("right", axis)
|
||||
assert.are.equals(-1, sign)
|
||||
end)
|
||||
|
||||
it("should work with mirroring", function()
|
||||
local ktype, axis, sign = parse_keyword("m")
|
||||
assert.are.equals(ktype, "rev")
|
||||
assert.are.equals(axis, "mirroring")
|
||||
assert.are.equals(sign, nil)
|
||||
assert.are.equals("rev", ktype)
|
||||
assert.are.equals("mirroring", axis)
|
||||
assert.are.equals(nil, sign)
|
||||
end)
|
||||
|
||||
-- Error tests
|
||||
it("should return error for bad axis", function()
|
||||
local ktype, axis, sign = parse_keyword("-axv")
|
||||
assert.are.equals(ktype, "err")
|
||||
assert.are.equals("err", ktype)
|
||||
end)
|
||||
|
||||
end)
|
||||
|
@ -25,7 +25,7 @@ describe("parse_axes", function()
|
||||
"10",
|
||||
}, facing_dirs.x_pos)
|
||||
assert.is.truthy(minv)
|
||||
assert.are.same(Vector3.new(-3, 0, -3), minv)
|
||||
assert.are.same(Vector3.new(-13, -10, -13), minv)
|
||||
assert.are.same(Vector3.new(10, 10, 10), maxv)
|
||||
end)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user