From 09ea62597a3f097fd0aca3894b1f8ef081b81222 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 3 May 2026 12:05:23 +0100 Subject: Extract UntypedNodeMatchers --- .../compiler/ast/untyped/UntypedNodeMatchers.java | 28 ++++++++++++++++++++++ .../parser/ParserConstructedTypeTests.java | 26 +++----------------- 2 files changed, 31 insertions(+), 23 deletions(-) create mode 100644 src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedNodeMatchers.java (limited to 'src/test') diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedNodeMatchers.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedNodeMatchers.java new file mode 100644 index 0000000..9e2c217 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedNodeMatchers.java @@ -0,0 +1,28 @@ +package org.zwobble.hobgoblin.compiler.ast.untyped; + +import org.zwobble.precisely.Matcher; + +import static org.zwobble.precisely.Matchers.*; + +public class UntypedNodeMatchers { + private UntypedNodeMatchers() { + } + + public static Matcher isUntypedConstructedTypeNode( + Matcher receiver, + Matcher> args + ) { + return instanceOf( + UntypedConstructedTypeNode.class, + has("receiver", UntypedConstructedTypeNode::receiver, receiver), + has("args", UntypedConstructedTypeNode::args, args) + ); + } + + public static Matcher isUntypedTypeLevelReferenceNode(String name) { + return instanceOf( + UntypedTypeLevelReferenceNode.class, + has("name", UntypedTypeLevelReferenceNode::name, equalTo(name)) + ); + } +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserConstructedTypeTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserConstructedTypeTests.java index 1444cf0..3b6a614 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserConstructedTypeTests.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserConstructedTypeTests.java @@ -1,14 +1,12 @@ package org.zwobble.hobgoblin.compiler.parser; import org.junit.jupiter.api.Test; -import org.zwobble.hobgoblin.compiler.ast.untyped.UntypedConstructedTypeNode; -import org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTypeLevelExpressionNode; -import org.zwobble.hobgoblin.compiler.ast.untyped.UntypedTypeLevelReferenceNode; -import org.zwobble.precisely.Matcher; +import static org.zwobble.hobgoblin.compiler.ast.untyped.UntypedNodeMatchers.isUntypedConstructedTypeNode; +import static org.zwobble.hobgoblin.compiler.ast.untyped.UntypedNodeMatchers.isUntypedTypeLevelReferenceNode; import static org.zwobble.hobgoblin.compiler.parser.ParserTesting.parseString; import static org.zwobble.precisely.AssertThat.assertThat; -import static org.zwobble.precisely.Matchers.*; +import static org.zwobble.precisely.Matchers.isSequence; public class ParserConstructedTypeTests { @Test @@ -54,23 +52,5 @@ public class ParserConstructedTypeTests { ) )); } - - private static Matcher isUntypedConstructedTypeNode( - Matcher receiver, - Matcher> args - ) { - return instanceOf( - UntypedConstructedTypeNode.class, - has("receiver", UntypedConstructedTypeNode::receiver, receiver), - has("args", UntypedConstructedTypeNode::args, args) - ); - } - - private static Matcher isUntypedTypeLevelReferenceNode(String name) { - return instanceOf( - UntypedTypeLevelReferenceNode.class, - has("name", UntypedTypeLevelReferenceNode::name, equalTo(name)) - ); - } } -- cgit v1.2.3