You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2019/12/06 15:08:02 UTC

[plc4x] 05/07: added test for parent expression

This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch feature/ams_ads_mpsec
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit 836638fc8b9f7baa80ae091f534d46108876eb78
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Dec 5 11:49:27 2019 +0100

    added test for parent expression
---
 .../expression/ExpressionStringParserTest.java     | 23 ++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/build-utils/protocol-base-mspec/src/test/java/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/ExpressionStringParserTest.java b/build-utils/protocol-base-mspec/src/test/java/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/ExpressionStringParserTest.java
index 606885b..a89065f 100644
--- a/build-utils/protocol-base-mspec/src/test/java/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/ExpressionStringParserTest.java
+++ b/build-utils/protocol-base-mspec/src/test/java/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/ExpressionStringParserTest.java
@@ -20,10 +20,7 @@
 package org.apache.plc4x.plugins.codegenerator.language.mspec.expression;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.plc4x.plugins.codegenerator.types.terms.BinaryTerm;
-import org.apache.plc4x.plugins.codegenerator.types.terms.NumericLiteral;
-import org.apache.plc4x.plugins.codegenerator.types.terms.Term;
-import org.apache.plc4x.plugins.codegenerator.types.terms.VariableLiteral;
+import org.apache.plc4x.plugins.codegenerator.types.terms.*;
 import org.junit.jupiter.api.Test;
 
 import java.nio.charset.Charset;
@@ -98,7 +95,8 @@ class ExpressionStringParserTest {
                     outerCast.get(1),
                     "S7ParameterUserDataItemCPUFunctions"
                 );
-            }, variableLiteral -> {
+            },
+            variableLiteral -> {
                 assertVariableLiteral(
                     variableLiteral,
                     "cpuFunctionType"
@@ -123,7 +121,8 @@ class ExpressionStringParserTest {
                     terms.get(1),
                     "S7ParameterUserData"
                 );
-            }, variableLiteral -> {
+            },
+            variableLiteral -> {
                 assertVariableLiteral(
                     variableLiteral,
                     "items",
@@ -145,6 +144,18 @@ class ExpressionStringParserTest {
     void testParentReference() {
         Term term = SUT.parse(IOUtils.toInputStream("../data.lengthInBytes", Charset.defaultCharset()));
         assertThat(term, not(nullValue()));
+        assertThat(term, instanceOf(UnaryTerm.class));
+        UnaryTerm unaryTerm = (UnaryTerm) term;
+        assertThat(unaryTerm.getOperation(), is(".."));
+        assertVariableLiteral(
+            unaryTerm.getA(),
+            "data",
+            null,
+            variableLiteral -> assertVariableLiteral(
+                variableLiteral,
+                "lengthInBytes"
+            )
+        );
     }
 
     void assertNumericLiteral(Term term, Number number) {