You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by ld...@apache.org on 2024/08/23 13:01:56 UTC

(plc4x) 01/01: Add more tests for mspec parser and code generator.

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

ldywicki pushed a commit to branch generator-hardening
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit 54f4d312c4a9740f357384611618df3f44586ed5
Author: Łukasz Dywicki <lu...@code-house.org>
AuthorDate: Fri Aug 23 15:01:39 2024 +0200

    Add more tests for mspec parser and code generator.
    
    Signed-off-by: Łukasz Dywicki <lu...@code-house.org>
---
 .../src/main/resources/protocols/test/test.mspec   | 28 ++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/code-generation/protocol-test/src/main/resources/protocols/test/test.mspec b/code-generation/protocol-test/src/main/resources/protocols/test/test.mspec
index d07acc5cc7..9933bfa785 100644
--- a/code-generation/protocol-test/src/main/resources/protocols/test/test.mspec
+++ b/code-generation/protocol-test/src/main/resources/protocols/test/test.mspec
@@ -212,6 +212,17 @@
     ]
 ]
 
+// Check field with arguments
+[type Struct(bit signed, byte data)
+]
+
+[type StructContainer
+    [simple bit signed]
+    [simple byte data]
+    [virtual Struct('signed', 'data') struct]
+]
+
+
 // TODO: So far only trouble in GO, C seems OK.
 [type VirtualFieldTest
     [simple  uint 8 simpleField]
@@ -475,7 +486,7 @@
 // TypeSwitch in TypeSwitch
 ////////////////////////////////////////////////////////////////
 
-/* Needs to be ported to C and GO
+/* Needs to be ported to C and GO */
 [discriminatedType TypeSwitchInTypeSwitchParentType
     [discriminator uint 8 typeNumber]
     [simple uint 8 parentFieldHurz]
@@ -535,7 +546,20 @@
             ]
         ]
     ]
-]*/
+]
+[discriminatedType TypeSwitchWithArg(bit arg1, uint 8 arg2)
+    [abstract bit isItTrue]
+    [discriminator uint 8 typeNumber]
+    [typeSwitch arg1
+        ['true' TrustfulTypeSwitch(bit arg1, uint 8 arg2)
+            [virtual bit isItTrue 'true']
+        ]
+        ['false' UnTrustfulTypeSwitch(bit arg1, uint 8 arg2)
+            [virtual bit isItTrue 'false']
+        ]
+    ]
+]
+
 
 ////////////////////////////////////////////////////////////////
 // Missing Tests