diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-09-27 20:22:34 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-09-27 20:22:34 +0100 |
| commit | a0074f328bfabc0c28d7e5b1202761daaa265fc8 (patch) | |
| tree | 28336e56dbf2341e6630d5ea27f7a9348b46ccde /src/test/java/org/shedlang/compiler/parser | |
| parent | 71e8f7645a022dbe913cb0e5ea3a1ab5e9b33a0f (diff) | |
Parse struct without fields
Diffstat (limited to 'src/test/java/org/shedlang/compiler/parser')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/parser/ParserStructDefinitionTests.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/parser/ParserStructDefinitionTests.java b/src/test/java/org/shedlang/compiler/parser/ParserStructDefinitionTests.java new file mode 100644 index 00000000..8a0fe6b6 --- /dev/null +++ b/src/test/java/org/shedlang/compiler/parser/ParserStructDefinitionTests.java @@ -0,0 +1,26 @@ +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.parser.ParserTesting.parseString; +import static org.zwobble.precisely.AssertThat.assertThat; +import static org.zwobble.precisely.Matchers.isSequence; + +public class ParserStructDefinitionTests { + @Test + public void canParseStructWithNoFields() { + var source = """ + struct X() {} + """; + + var node = parseString(source, Parser::parseNamespaceStatement); + + assertThat( + node, + isUntypedStructDefinitionNode() + .withName("X") + .withFields(isSequence()) + ); + } +} |
