aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/shedlang/compiler/parser
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2024-12-11 20:51:26 +0000
committerMichael Williamson <mike@zwobble.org>2024-12-11 20:51:26 +0000
commit85e0fc7a603e832205a7eef34930e8901fefd77d (patch)
tree1326f656d7250890e61eea9559cbf37a993e34a2 /src/test/java/org/shedlang/compiler/parser
parentde320dfc664bc926686938e75ef4a9c6d42c947c (diff)
Parse methods in extend inline node
Diffstat (limited to 'src/test/java/org/shedlang/compiler/parser')
-rw-r--r--src/test/java/org/shedlang/compiler/parser/ParserExtendInlineTests.java26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/test/java/org/shedlang/compiler/parser/ParserExtendInlineTests.java b/src/test/java/org/shedlang/compiler/parser/ParserExtendInlineTests.java
index 75030e4b..6652a46e 100644
--- a/src/test/java/org/shedlang/compiler/parser/ParserExtendInlineTests.java
+++ b/src/test/java/org/shedlang/compiler/parser/ParserExtendInlineTests.java
@@ -2,10 +2,10 @@ package org.shedlang.compiler.parser;
import org.junit.jupiter.api.Test;
-import static org.shedlang.compiler.ast.untyped.UntypedNodeMatchers.isUntypedExtendInlineNode;
-import static org.shedlang.compiler.ast.untyped.UntypedNodeMatchers.isUntypedTypeLevelReferenceNode;
+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;
public class ParserExtendInlineTests {
@Test
@@ -20,6 +20,28 @@ public class ParserExtendInlineTests {
node,
isUntypedExtendInlineNode()
.withExtendedType(isUntypedTypeLevelReferenceNode("Count"))
+ .withMethods(isSequence())
+ );
+ }
+
+ @Test
+ public void canParseExtendInlineWithSingleMethod() {
+ var source = """
+ extend Count {
+ fun message(this) {
+ }
+ }
+ """;
+
+ var node = parseString(source, Parser::parseNamespaceStatement);
+
+ assertThat(
+ node,
+ isUntypedExtendInlineNode()
+ .withExtendedType(isUntypedTypeLevelReferenceNode("Count"))
+ .withMethods(isSequence(
+ isUntypedFunctionDefinitionNode().withName("message")
+ ))
);
}
}