misc Lua Version difference fixes
This commit is contained in:
@@ -4,6 +4,7 @@ end)
|
||||
|
||||
describe("Constraint", function()
|
||||
local kiwi = require("kiwi")
|
||||
local LUA_VERSION = tonumber(_VERSION:match("%d+%.%d+"))
|
||||
|
||||
describe("construction", function()
|
||||
local v, lhs
|
||||
@@ -32,18 +33,31 @@ describe("Constraint", function()
|
||||
assert.equal(kiwi.strength.STRONG, c:strength())
|
||||
end)
|
||||
|
||||
-- TODO: standardize formatting
|
||||
it("formats well", function()
|
||||
local c = kiwi.Constraint(lhs)
|
||||
assert.equal("1 foo + 1 == 0 | required", tostring(c))
|
||||
if LUA_VERSION <= 5.2 then
|
||||
assert.equal("1 foo + 1 == 0 | required", tostring(c))
|
||||
else
|
||||
assert.equal("1.0 foo + 1.0 == 0 | required", tostring(c))
|
||||
end
|
||||
|
||||
c = kiwi.Constraint(lhs * 2, nil, "GE", kiwi.strength.STRONG)
|
||||
assert.equal("2 foo + 2 >= 0 | strong", tostring(c))
|
||||
if LUA_VERSION <= 5.2 then
|
||||
assert.equal("2 foo + 2 >= 0 | strong", tostring(c))
|
||||
else
|
||||
assert.equal("2.0 foo + 2.0 >= 0 | strong", tostring(c))
|
||||
end
|
||||
|
||||
c = kiwi.Constraint(lhs / 2, nil, "LE", kiwi.strength.MEDIUM)
|
||||
assert.equal("0.5 foo + 0.5 <= 0 | medium", tostring(c))
|
||||
|
||||
c = kiwi.Constraint(lhs, kiwi.Expression(3), "GE", kiwi.strength.WEAK)
|
||||
assert.equal("1 foo + -2 >= 0 | weak", tostring(c))
|
||||
if LUA_VERSION <= 5.2 then
|
||||
assert.equal("1 foo + -2 >= 0 | weak", tostring(c))
|
||||
else
|
||||
assert.equal("1.0 foo + -2.0 >= 0 | weak", tostring(c))
|
||||
end
|
||||
end)
|
||||
|
||||
it("rejects invalid args", function()
|
||||
|
||||
Reference in New Issue
Block a user