var assert = require('assert');
var CnfFormula = require('../src/CnfFormula');
var Solver = require('../src/Solver');

describe('Solver', function() {
    describe('#solve', function() {
        it('should return a Map which is the solution (random selection)', function() {
            var formula = new CnfFormula();
            var a = {};
            var b = {};
            var c = {};
            var d = {};
            var e = {};
            // (a | b) & (-b | c | -d) & (d | -e)
            formula.openClause(a).or(b).close().openClauseNot(b).or(c).orNot(d).close().openClause(d).orNot(e).close();
            var solver = new Solver(formula);
            var solution = solver.solve();
            assert.equal(5, solution.size());
        });
        
        it('should return a Map which is the solution (highest occurrence selection)', function() {
            var formula = new CnfFormula();
            var a = {};
            var b = {};
            var c = {};
            var d = {};
            var e = {};
            // (a | b) & (-b | c | -d) & (d | -e)
            formula.openClause(a).or(b).close().openClauseNot(b).or(c).orNot(d).close().openClause(d).orNot(e).close();
            var solver = new Solver(formula);
            var solution = solver.highestOccurrenceVariableSelection().solve();
            assert.equal(5, solution.size());
        });

        it('should return a Map which is the solution but provide no value for x', function() {
            var formula = new CnfFormula();
            var a = {};
            var b = {};
            var c = {};
            var d = {};
            var e = {};
            var x = {};
            // will be optimized away
            // (a | b | x | -x) & (-b | c | -d) & (d | -e)
            formula.openClause(a).or(b).or(x).orNot(x).close().openClauseNot(b).or(c).orNot(d).close().openClause(d).orNot(e).close();
            var solver = new Solver(formula);
            var solution = solver.solve();
            assert.equal(5, solution.size());
            assert.equal(undefined, solution.get(x));
        });

    });

});

@@ -749,20 +749,341 @@
     
-%7D);%0A        
+    var aVal = solution.get(a);%0A            var bVal = solution.get(b);%0A            var cVal = solution.get(c);%0A            var dVal = solution.get(d);%0A            var eVal = solution.get(e);%0A            var actual = (aVal %7C%7C bVal) && (!bVal %7C%7C cVal %7C%7C !dVal) && (dVal %7C%7C !eVal);%0A            assert.equal(true, actual);%0A%0A        %7D);%0A
 %0A   
@@ -1631,32 +1631,32 @@
 tion().solve();%0A
-
             asse
@@ -1677,32 +1677,360 @@
 lution.size());%0A
+            var aVal = solution.get(a);%0A            var bVal = solution.get(b);%0A            var cVal = solution.get(c);%0A            var dVal = solution.get(d);%0A            var eVal = solution.get(e);%0A            var actual = (aVal %7C%7C bVal) && (!bVal %7C%7C cVal %7C%7C !dVal) && (dVal %7C%7C !eVal);%0A            assert.equal(true, actual);%0A
         %7D);%0A%0A   

Improve UT by evaluating manually solution