diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-09-27 20:28:09 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-09-27 20:28:09 +0100 |
| commit | 059d6276a4d2ef23672adb009e633a06f3603a8c (patch) | |
| tree | 162ba95c15b2ed66c323be4c2225c4b096313dfc /src/test/java/org/shedlang/compiler/parser | |
| parent | a0074f328bfabc0c28d7e5b1202761daaa265fc8 (diff) | |
Parse struct definition fields
Diffstat (limited to 'src/test/java/org/shedlang/compiler/parser')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/parser/ParserStructDefinitionTests.java | 25 |
1 files changed, 24 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 8a0fe6b6..3fd640b1 100644 --- a/src/test/java/org/shedlang/compiler/parser/ParserStructDefinitionTests.java +++ b/src/test/java/org/shedlang/compiler/parser/ParserStructDefinitionTests.java @@ -2,7 +2,7 @@ package org.shedlang.compiler.parser; import org.junit.jupiter.api.Test; -import static org.shedlang.compiler.ast.untyped.UntypedNodeMatchers.isUntypedStructDefinitionNode; +import static org.shedlang.compiler.ast.untyped.UntypedNodeMatchers.*; import static org.shedlang.compiler.parser.ParserTesting.parseString; import static org.zwobble.precisely.AssertThat.assertThat; import static org.zwobble.precisely.Matchers.isSequence; @@ -23,4 +23,27 @@ public class ParserStructDefinitionTests { .withFields(isSequence()) ); } + + @Test + public void canParseStructWithFields() { + 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")), + isUntypedStructFieldDefinitionNode() + .withName("accessLevel") + .withType(isUntypedTypeLevelReferenceNode("AccessLevel")) + )) + ); + } } |
