slightlyoff / cassowary.js

Cassowary/JS, better, faster, future-ready
Other
1.69k stars 107 forks source link

Add a correct check for number with default value #46

Closed Timshel closed 10 years ago

Timshel commented 10 years ago

Otherwise on line 116 in Expression.js when n was 0 it was replaced by 1 and then :

var solver = new c.SimplexSolver();
var x = new c.Variable({ name: "x" });
var y = new c.Variable({ name: "y" });
solver.addConstraint( new c.Equation(x, 12));
solver.addConstraint( new c.Equation(y, new c.Expression(x).times(0)) );
solver.resolve();
console.log(x.value + " - " + y.value);

Output :

"12 - 12"