From 899d15a3a6604c07600a29036b980f4cabde97a4 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Wed, 27 Jan 2016 18:01:42 -0500 Subject: [PATCH] auto-sync --- .../autsia/bracer/test/BracerParserTest.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/java_console/models/src/com/autsia/bracer/test/BracerParserTest.java b/java_console/models/src/com/autsia/bracer/test/BracerParserTest.java index cba6343f6f..74559beb93 100644 --- a/java_console/models/src/com/autsia/bracer/test/BracerParserTest.java +++ b/java_console/models/src/com/autsia/bracer/test/BracerParserTest.java @@ -32,10 +32,8 @@ import static org.junit.Assert.assertEquals; * Test class. * User: Dmytro * Date: 23.01.13 - * Time: 12:52 */ public class BracerParserTest { - private final String INPUT_NOVAR = "-sin(3+4+cos(6)/exp(10/pow(22,-1)))"; private BracerParser bracerParser; @Before @@ -43,13 +41,6 @@ public class BracerParserTest { bracerParser = new BracerParser(); } - @Test - @Ignore - public void testEvaluateNoVar() throws Exception { - bracerParser.parse(INPUT_NOVAR); - assertEquals("-0.6570194619480038", bracerParser.evaluate()); - } - @Test public void testSimpleBoolean() throws Exception { bracerParser.parse("true or false"); @@ -63,7 +54,10 @@ public class BracerParserTest { bracerParser.parse("(true > false)"); assertEquals("1", bracerParser.evaluate()); assertEquals("1 0 >", bracerParser.getRusEfi()); + } + @Test + public void testBooleanConversion() throws ParseException { bracerParser.parse("rpm > false"); assertEquals("rpm 0 >", bracerParser.getRusEfi()); @@ -84,6 +78,7 @@ public class BracerParserTest { @Test @Ignore public void testBooleanNot1() throws Exception { + // todo: why EmptyStackException? is the issue with the test or with us? bracerParser.parse("not( ( true and ( false or ( true and ( not( true ) or ( false ) ) ) ) ) and ( ( false ) ) )"); assertEquals("1", bracerParser.evaluate()); } @@ -108,9 +103,16 @@ public class BracerParserTest { @Test public void testBooleanNot2() throws Exception { + bracerParser.parse("1 & not(false)"); + assertEquals("0", bracerParser.evaluate());// todo: this does not seem right + assertEquals("1 not 0 &", bracerParser.getRusEfi()); // todo: this does not seem right + +// bracerParser.parse("not(false)"); // todo: this is broken +// assertEquals("1", bracerParser.evaluate()); +// assertEquals("1 0 | not 0 & 1 0 | |", bracerParser.getRusEfi()); + bracerParser.parse("(((true | false) & not(false)) | (true | false))"); assertEquals("1", bracerParser.evaluate()); - assertEquals("1 0 | not 0 & 1 0 | |", bracerParser.getRusEfi()); } }