added additional parser test case

This commit is contained in:
hneemann 2017-07-10 09:07:51 +02:00
parent 32da3e7d9b
commit 9db4942e2e
2 changed files with 17 additions and 3 deletions

View File

@ -8,7 +8,7 @@ HEAD, planned as v0.13
CAUTION: All default values are lost! If you have built a circuit that contains CAUTION: All default values are lost! If you have built a circuit that contains
test cases that depend on a non-null default value, this tests will fail. To test cases that depend on a non-null default value, this tests will fail. To
resolve this issue, reset the default value. resolve this issue, reset the default value.
- added an enable input to the T flip-flop - Added an enable input to the T flip-flop
CAUTION: By default this input is activated now. In circuits which used the T flip-flop CAUTION: By default this input is activated now. In circuits which used the T flip-flop
in the past, the new input needs to be disabled. in the past, the new input needs to be disabled.
- A warning message shows up if a circuit with unnamed inputs is analysed. - A warning message shows up if a circuit with unnamed inputs is analysed.

View File

@ -74,8 +74,8 @@ public class ParserTest extends TestCase {
public void testParseLet() throws Exception { public void testParseLet() throws Exception {
Expression exp = createSingle("let u=a+b"); Expression exp = createSingle("let u=a+b");
assertTrue(exp instanceof NamedExpression); assertTrue(exp instanceof NamedExpression);
assertEquals("u", ((NamedExpression)exp).getName()); assertEquals("u", ((NamedExpression) exp).getName());
assertTrue(((NamedExpression)exp).getExpression() instanceof Operation.Or); assertTrue(((NamedExpression) exp).getExpression() instanceof Operation.Or);
} }
public void testParseLetError() throws Exception { public void testParseLetError() throws Exception {
@ -95,6 +95,20 @@ public class ParserTest extends TestCase {
assertEquals(new Variable("c"), expList.get(2)); assertEquals(new Variable("c"), expList.get(2));
} }
public void testParseList2() throws Exception {
ArrayList<Expression> expList = new Parser("let u=a,let v=b,let w=c").parse();
assertEquals(3, expList.size());
assertTrue(expList.get(0) instanceof NamedExpression);
assertEquals(((NamedExpression) expList.get(0)).getName(), "u");
assertEquals(((NamedExpression) expList.get(0)).getExpression(), new Variable("a"));
assertTrue(expList.get(1) instanceof NamedExpression);
assertEquals(((NamedExpression) expList.get(1)).getName(), "v");
assertEquals(((NamedExpression) expList.get(1)).getExpression(), new Variable("b"));
assertTrue(expList.get(2) instanceof NamedExpression);
assertEquals(((NamedExpression) expList.get(2)).getName(), "w");
assertEquals(((NamedExpression) expList.get(2)).getExpression(), new Variable("c"));
}
public void testParseRegression() throws Exception { public void testParseRegression() throws Exception {
Expression e = createSingle("B*(B+A)*(B+C)*(A+B+C)"); Expression e = createSingle("B*(B+A)*(B+C)*(A+B+C)");
Expression simplified = QuineMcCluskey.simplify(e); Expression simplified = QuineMcCluskey.simplify(e);