Finish Logic.or

This commit is contained in:
David Greenspan
2014-12-21 19:37:33 -08:00
parent fae2ef8d4b
commit 4f983b15a1
2 changed files with 7 additions and 3 deletions

View File

@@ -190,6 +190,8 @@ Meteor._inherits(Logic.OrFormula, Logic.Formula);
Logic.OrFormula.prototype._genTrue = function (solver) {
return [new Logic.Clause(solver._toN(this.terms))];
};
//Logic.OrFormula.prototype._genFalse = function (solver) {
// XXX
//};
Logic.OrFormula.prototype._genFalse = function (solver) {
return _.map(this.terms, function (t) {
return [new Logic.Clause(-solver._toN(t))];
});
};

View File

@@ -20,4 +20,6 @@ Tinytest.add("logic-solver - Logic.Or", function (test) {
s.require(Logic.or('-c', 'd', 3));
test.equal(s._clauseData(), [[3, 4], [-5, 6, 3]]);
s.forbid(Logic.or('a', '-b'));
test.equal(s._clauseData(), [[3, 4], [-5, 6, 3], [-3], [4]]);
});