Update to parser tests

This commit is contained in:
VorTechnix 2024-09-11 16:52:37 -07:00
parent 7e9e0f6a48
commit f9652c9621
No known key found for this signature in database
GPG Key ID: 091E91A69545D5BA
2 changed files with 30 additions and 26 deletions

@ -11,64 +11,68 @@ describe("parse_keyword", function()
-- Basic tests -- Basic tests
it("should work on single axes", function() it("should work on single axes", function()
local ktype, axis, sign = parse_keyword("x") local ktype, axis, sign = parse_keyword("x")
assert.are.equals(ktype, "axis") assert.are.equals("axis", ktype)
assert.are.same(axis, {"x"}) assert.are.same({"x"}, axis)
assert.are.equals(sign, 1) assert.are.equals(1, sign)
end) end)
it("should work with axis clumping", function() it("should work with axis clumping", function()
local ktype, axis, sign = parse_keyword("zx") local ktype, axis, sign = parse_keyword("zx")
assert.are.equals(ktype, "axis") assert.are.equals("axis", ktype)
assert.are.same(axis, {"x", "z"}) assert.are.same({"x", "z"}, axis)
assert.are.equals(sign, 1) assert.are.equals(1, sign)
end) end)
it("should work with h and v", function() it("should work with h and v", function()
local ktype, axis, sign = parse_keyword("hv") local ktype, axis, sign = parse_keyword("hv")
assert.are.equals(ktype, "axis") assert.are.equals("axis", ktype)
assert.are.same(axis, {"h", "v"}) assert.are.same(
assert.are.equals(sign, 1) {"x", "y", "z", rev={"x", "y", "z"}},
axis)
assert.are.equals(1, sign)
end) end)
it("should work with h and v in clumping", function() it("should work with h and v in clumping", function()
local ktype, axis, sign = parse_keyword("hyxz") local ktype, axis, sign = parse_keyword("hyxz")
assert.are.equals(ktype, "axis") assert.are.equals("axis", ktype)
assert.are.same(axis, {"h", "y"}) assert.are.same(
assert.are.equals(sign, 1) {"x", "y", "z", rev={"x", "z"}},
axis)
assert.are.equals(1, sign)
end) end)
it("should work with negatives", function() it("should work with negatives", function()
local ktype, axis, sign = parse_keyword("-xv") local ktype, axis, sign = parse_keyword("-xv")
assert.are.equals(ktype, "axis") assert.are.equals("axis", ktype)
assert.are.same(axis, {"v", "x"}) assert.are.same({"x", "y", rev={"y"}}, axis)
assert.are.equals(sign, -1) assert.are.equals(-1, sign)
end) end)
it("should work with dirs", function() it("should work with dirs", function()
local ktype, axis, sign = parse_keyword("left") local ktype, axis, sign = parse_keyword("left")
assert.are.equals(ktype, "dir") assert.are.equals("dir", ktype)
assert.are.equals(axis, "left") assert.are.equals("left", axis)
assert.are.equals(sign, 1) assert.are.equals(1, sign)
end) end)
it("should work with negative dirs", function() it("should work with negative dirs", function()
local ktype, axis, sign = parse_keyword("-right") local ktype, axis, sign = parse_keyword("-right")
assert.are.equals(ktype, "dir") assert.are.equals("dir", ktype)
assert.are.equals(axis, "right") assert.are.equals("right", axis)
assert.are.equals(sign, -1) assert.are.equals(-1, sign)
end) end)
it("should work with mirroring", function() it("should work with mirroring", function()
local ktype, axis, sign = parse_keyword("m") local ktype, axis, sign = parse_keyword("m")
assert.are.equals(ktype, "rev") assert.are.equals("rev", ktype)
assert.are.equals(axis, "mirroring") assert.are.equals("mirroring", axis)
assert.are.equals(sign, nil) assert.are.equals(nil, sign)
end) end)
-- Error tests -- Error tests
it("should return error for bad axis", function() it("should return error for bad axis", function()
local ktype, axis, sign = parse_keyword("-axv") local ktype, axis, sign = parse_keyword("-axv")
assert.are.equals(ktype, "err") assert.are.equals("err", ktype)
end) end)
end) end)

@ -25,7 +25,7 @@ describe("parse_axes", function()
"10", "10",
}, facing_dirs.x_pos) }, facing_dirs.x_pos)
assert.is.truthy(minv) 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) assert.are.same(Vector3.new(10, 10, 10), maxv)
end) end)