use of de.neemann.digital.analyse.parser.Parser in project Digital by hneemann.
the class ExpressionListenerOptimizeJKTest method testSimple.
public void testSimple() throws IOException, ParseException, FormatterException, ExpressionException {
TestEL exp = new TestEL();
ExpressionListener elojk = new ExpressionListenerOptimizeJK(exp);
Expression e1, e2;
elojk.resultFound("Sn+1", e1 = new Parser("(Sn*A)+(!Sn*B)").parse().get(0));
elojk.resultFound("Sn+1", e2 = new Parser("(Sn*A)+(!C*B)").parse().get(0));
elojk.close();
assertEquals(1, exp.getList().size());
assertEquals(e1, exp.getList().get(0));
}
use of de.neemann.digital.analyse.parser.Parser in project Digital by hneemann.
the class KarnaughMapTest method testSimple2_singleVar.
public void testSimple2_singleVar() throws IOException, ParseException, KarnaughException {
Expression exp = new Parser("A").parse().get(0);
KarnaughMap c = new KarnaughMap(Variable.vars(2), exp);
assertEquals(1, c.size());
for (KarnaughMap.Cover co : c) assertEquals(2, co.getSize());
}
use of de.neemann.digital.analyse.parser.Parser in project Digital by hneemann.
the class KarnaughMapTest method testSimple4.
public void testSimple4() throws IOException, ParseException, KarnaughException {
Expression exp = new Parser("(¬A ¬C ¬D) ∨ (A B C) ∨ (A ¬B D) ∨ (¬A ¬B C) ∨ (¬B ¬C ¬D)").parse().get(0);
KarnaughMap c = new KarnaughMap(Variable.vars(4), exp);
assertEquals(5, c.size());
for (KarnaughMap.Cover co : c) assertEquals(2, co.getSize());
}
use of de.neemann.digital.analyse.parser.Parser in project Digital by hneemann.
the class KarnaughMapTest method testSimple_BUG.
public void testSimple_BUG() throws IOException, ParseException, KarnaughException {
Expression exp = new Parser("(¬A B ¬C) ∨ (A C) ∨ ¬B").parse().get(0);
KarnaughMap c = new KarnaughMap(Variable.vars(3), exp);
assertEquals(3, c.size());
Iterator<KarnaughMap.Cover> it = c.iterator();
assertEquals(1, it.next().getSize());
assertEquals(2, it.next().getSize());
assertEquals(4, it.next().getSize());
}
use of de.neemann.digital.analyse.parser.Parser in project Digital by hneemann.
the class TestResultTest method getModel.
private Model getModel(String func) throws IOException, ParseException, BuilderException, PinException, NodeException, ElementNotFoundException {
ArrayList<Expression> exp = new Parser(func).parse();
ElementLibrary library = new ElementLibrary();
CircuitBuilder cb = new CircuitBuilder(new ShapeFactory(library));
cb.addCombinatorial("Y", exp.get(0));
Circuit circ = cb.createCircuit();
Model model = new ModelCreator(circ, library).createModel(false);
model.init();
return model;
}
Aggregations