aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/shedlang/compiler/parser
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org/shedlang/compiler/parser')
-rw-r--r--src/test/java/org/shedlang/compiler/parser/ParserStructDefinitionTests.java29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/test/java/org/shedlang/compiler/parser/ParserStructDefinitionTests.java b/src/test/java/org/shedlang/compiler/parser/ParserStructDefinitionTests.java
index 903c4c52..4f0698ad 100644
--- a/src/test/java/org/shedlang/compiler/parser/ParserStructDefinitionTests.java
+++ b/src/test/java/org/shedlang/compiler/parser/ParserStructDefinitionTests.java
@@ -40,10 +40,37 @@ public class ParserStructDefinitionTests {
.withFields(isSequence(
isUntypedStructFieldDefinitionNode()
.withName("name")
- .withType(isUntypedTypeLevelReferenceNode("String")),
+ .withType(isUntypedTypeLevelReferenceNode("String"))
+ .withIsPositional(false),
isUntypedStructFieldDefinitionNode()
.withName("accessLevel")
.withType(isUntypedTypeLevelReferenceNode("AccessLevel"))
+ .withIsPositional(false)
+ ))
+ );
+ }
+
+ @Test
+ public void canParseStructWithPositionalFields() {
+ var source = """
+ struct X(name: String, accessLevel: AccessLevel) {}
+ """;
+
+ var node = parseString(source, Parser::parseNamespaceStatement);
+
+ assertThat(
+ node,
+ isUntypedStructDefinitionNode()
+ .withName("X")
+ .withFields(isSequence(
+ isUntypedStructFieldDefinitionNode()
+ .withName("name")
+ .withType(isUntypedTypeLevelReferenceNode("String"))
+ .withIsPositional(true),
+ isUntypedStructFieldDefinitionNode()
+ .withName("accessLevel")
+ .withType(isUntypedTypeLevelReferenceNode("AccessLevel"))
+ .withIsPositional(true)
))
);
}