From d6afd5049c97159fbcb6e13aa033a07e4f56d181 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 2 Mar 2024 13:50:16 +0000 Subject: Parse effect params --- .../compiler/ast/untyped/UntypedNodeMatchers.java | 7 +++++++ .../compiler/parser/ParserEffectParamTests.java | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/test/java/org/shedlang/compiler/parser/ParserEffectParamTests.java (limited to 'src/test/java/org') diff --git a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java index cf28b0ad..e0597387 100644 --- a/src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java +++ b/src/test/java/org/shedlang/compiler/ast/untyped/UntypedNodeMatchers.java @@ -118,6 +118,13 @@ public class UntypedNodeMatchers { ); } + public static Matcher isUntypedEffectParamNode(String name) { + return instanceOf( + UntypedEffectParamNode.class, + has("name", x -> x.name(), equalTo(name)) + ); + } + public static Matcher isUntypedEqualsNode( Matcher left, Matcher right diff --git a/src/test/java/org/shedlang/compiler/parser/ParserEffectParamTests.java b/src/test/java/org/shedlang/compiler/parser/ParserEffectParamTests.java new file mode 100644 index 00000000..dfd970bf --- /dev/null +++ b/src/test/java/org/shedlang/compiler/parser/ParserEffectParamTests.java @@ -0,0 +1,18 @@ +package org.shedlang.compiler.parser; + +import org.junit.jupiter.api.Test; + +import static org.shedlang.compiler.ast.untyped.UntypedNodeMatchers.isUntypedEffectParamNode; +import static org.shedlang.compiler.parser.ParserTesting.parseString; +import static org.zwobble.precisely.AssertThat.assertThat; + +public class ParserEffectParamTests { + @Test + public void canParseEffectParam() { + var source = "!E"; + + var node = parseString(source, Parser::parseTypeLevelParam); + + assertThat(node, isUntypedEffectParamNode("E")); + } +} -- cgit v1.2.3