Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6580046

Browse files
committedSep 16, 2024·
Add more tests for mspec parser and code generator.
Signed-off-by: Łukasz Dywicki <luke@code-house.org>
1 parent c1a7135 commit 6580046

File tree

1 file changed

+35
-27
lines changed
  • code-generation/protocol-test/src/main/resources/protocols/test

1 file changed

+35
-27
lines changed
 

‎code-generation/protocol-test/src/main/resources/protocols/test/test.mspec

+35-27
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
//[manualArray uint 8 manualArrayField count '1' ] // TODO: Implement ...
4949
//[manualArray uint 8 manualArrayField length '1' ] // TODO: Implement ...
5050
//[manualArray uint 8 manualArrayField terminated '1' ] // TODO: Implement ...
51-
[manual uint 8 manualField 'STATIC_CALL("readAManualField", readBuffer, simpleField)'
52-
'STATIC_CALL("writeAManualField", writeBuffer, simpleField)'
51+
[manual uint 8 manualField 'STATIC_CALL("readManualField", readBuffer, simpleField)'
52+
'STATIC_CALL("writeManualField", writeBuffer, simpleField)'
5353
'simpleField*8' ]
5454
[optional uint 8 optionalField 'simpleField == 5' ]
5555
[padding uint 8 paddingField '0x00' 'simpleField']
@@ -121,7 +121,6 @@
121121
[simple string 8 abstractStringField]
122122
]
123123
]
124-
//[abstract bit oneMoreBit] // TODO: apparently this breaks java
125124
]
126125
127126
[type ArrayTypeTest
@@ -213,6 +212,23 @@
213212
]
214213
]
215214

215+
// Check field with arguments
216+
[type Struct(bit signed, bit unsigned)
217+
[typeSwitch signed
218+
['true' SignedType
219+
[simple int 8 data]
220+
]
221+
['false' UnsignedType
222+
[simple uint 8 data]
223+
]
224+
]
225+
]
226+
227+
[type StructContainer
228+
[simple bit signed]
229+
[simple Struct('signed', '!signed') struct]
230+
]
231+
216232
// TODO: So far only trouble in GO, C seems OK.
217233
[type VirtualFieldTest
218234
[simple uint 8 simpleField]
@@ -477,28 +493,6 @@
477493
////////////////////////////////////////////////////////////////
478494

479495
/* Needs to be ported to C and GO
480-
[discriminatedType TTGranddad
481-
[discriminator uint 8 dadNumber]
482-
[simple uint 8 warStories]
483-
[typeSwitch dadNumber
484-
['0x00' TTDad
485-
[discriminator uint 8 sonNumber]
486-
[simple uint 8 beerBottles]
487-
[typeSwitch sonNumber
488-
['0x01' TTSon
489-
[simple uint 8 gameConsoles]
490-
[discriminator uint 8 babyNumber]
491-
[typeSwitch babyNumber
492-
['0x02' TTBaby
493-
[simple uint 8 lalalala]
494-
]
495-
]
496-
]
497-
]
498-
]
499-
]
500-
]
501-
502496
[discriminatedType TypeSwitchInTypeSwitchParentType
503497
[discriminator uint 8 typeNumber]
504498
[simple uint 8 parentFieldHurz]
@@ -558,10 +552,24 @@
558552
]
559553
]
560554
]
561-
]*/
555+
]
556+
557+
[discriminatedType TypeSwitchWithArg(bit arg1, uint 8 arg2)
558+
[abstract bit isItTrue]
559+
[simple uint 8 value]
560+
[typeSwitch arg1
561+
['true' TrustfulTypeSwitch(uint 8 value)
562+
[virtual bit isItTrue 'true']
563+
]
564+
['false' UnTrustfulTypeSwitch(uint 8 value)
565+
[virtual bit isItTrue 'false']
566+
]
567+
]
568+
]
569+
562570

563571
////////////////////////////////////////////////////////////////
564572
// Missing Tests
565573
////////////////////////////////////////////////////////////////
566574

567-
// TODO: Test case where a dataIo type is used as type of a simple field (Linking normal model and dataIo)
575+
// TODO: Test case where a dataIo type is used as type of a simple field (Linking normal model and dataIo)

0 commit comments

Comments
 (0)
Please sign in to comment.