Skip to content

Commit

Permalink
Modify Rust extension incompatible tests
Browse files Browse the repository at this point in the history
Rust library does not reduce constraint expressions, and there is little
reason we have to test for it.
  • Loading branch information
jkl1337 committed Mar 7, 2024
1 parent 506519c commit 8328fe6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion kiwi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ do
---@return string
---@nodiscard
function Var_cls:name()
return ffi_string(self.name_)
return self.name_ ~= nil and ffi_string(self.name_) or ""
end

--- Get the current value of the variable.
Expand Down
16 changes: 5 additions & 11 deletions spec/constraint_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,12 @@ describe("Constraint", function()
local v2 = kiwi.Var("bar")
local rhs = kiwi.Expression(3, 5 * v2, 3 * v)
local c = kiwi.Constraint(lhs, rhs)
assert.True(c:violated())
v:set(9)
v2:set(-4)
assert.False(c:violated())

local e = c:expression()
local t = e:terms()
assert.equal(2, #t)
if t[1].var ~= v then
t[1], t[2] = t[2], t[1]
end
assert.equal(v, t[1].var)
assert.equal(-2.0, t[1].coefficient)
assert.equal(v2, t[2].var)
assert.equal(-5.0, t[2].coefficient)
assert.equal(-2.0, e.constant)
assert.equal(-2.0, c:expression().constant)
end)
end)

Expand Down

0 comments on commit 8328fe6

Please sign in to comment.