From f58e79e8e1883b2246da7c36b0871c1e31728f86 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 29 Oct 2023 16:50:41 +0000 Subject: Make return type optional in typed function signature node --- .../compiler/ast/typed/TypedFunctionDefinitionNodeMatcher.java | 5 ++--- .../compiler/ast/typed/TypedFunctionExpressionNodeMatcher.java | 5 ++--- .../compiler/ast/typed/TypedFunctionSignatureNodeMatcher.java | 3 ++- 3 files changed, 6 insertions(+), 7 deletions(-) (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/ast/typed/TypedFunctionDefinitionNodeMatcher.java b/src/test/java/org/shedlang/compiler/ast/typed/TypedFunctionDefinitionNodeMatcher.java index e12a187d..58527e4f 100644 --- a/src/test/java/org/shedlang/compiler/ast/typed/TypedFunctionDefinitionNodeMatcher.java +++ b/src/test/java/org/shedlang/compiler/ast/typed/TypedFunctionDefinitionNodeMatcher.java @@ -8,8 +8,7 @@ import org.zwobble.precisely.Matcher; import java.util.Optional; -import static org.zwobble.precisely.Matchers.equalTo; -import static org.zwobble.precisely.Matchers.has; +import static org.zwobble.precisely.Matchers.*; public class TypedFunctionDefinitionNodeMatcher extends MatcherBuilder { public static TypedFunctionDefinitionNodeMatcher empty() { @@ -51,7 +50,7 @@ public class TypedFunctionDefinitionNodeMatcher extends MatcherBuilder> returnType) { - return with(has("returnType", x -> x.signature().returnType(), returnType)); + return with(has("returnType", x -> x.signature().returnType(), isOptionalOf(returnType))); } public TypedFunctionDefinitionNodeMatcher withType(FunctionType type) { diff --git a/src/test/java/org/shedlang/compiler/ast/typed/TypedFunctionExpressionNodeMatcher.java b/src/test/java/org/shedlang/compiler/ast/typed/TypedFunctionExpressionNodeMatcher.java index b47fb39c..50319754 100644 --- a/src/test/java/org/shedlang/compiler/ast/typed/TypedFunctionExpressionNodeMatcher.java +++ b/src/test/java/org/shedlang/compiler/ast/typed/TypedFunctionExpressionNodeMatcher.java @@ -8,8 +8,7 @@ import org.zwobble.precisely.Matcher; import java.util.Optional; -import static org.zwobble.precisely.Matchers.equalTo; -import static org.zwobble.precisely.Matchers.has; +import static org.zwobble.precisely.Matchers.*; public class TypedFunctionExpressionNodeMatcher extends MatcherBuilder< TypedExpressionNode, @@ -55,7 +54,7 @@ public class TypedFunctionExpressionNodeMatcher extends MatcherBuilder< } public TypedFunctionExpressionNodeMatcher withReturnType(Matcher> returnType) { - return with(has("returnType", x -> x.signature().returnType(), returnType)); + return with(has("returnType", x -> x.signature().returnType(), isOptionalOf(returnType))); } public TypedFunctionExpressionNodeMatcher withType(FunctionType type) { diff --git a/src/test/java/org/shedlang/compiler/ast/typed/TypedFunctionSignatureNodeMatcher.java b/src/test/java/org/shedlang/compiler/ast/typed/TypedFunctionSignatureNodeMatcher.java index 2661d4fb..ca2e64ae 100644 --- a/src/test/java/org/shedlang/compiler/ast/typed/TypedFunctionSignatureNodeMatcher.java +++ b/src/test/java/org/shedlang/compiler/ast/typed/TypedFunctionSignatureNodeMatcher.java @@ -8,6 +8,7 @@ import org.zwobble.precisely.Matcher; import java.util.Optional; import static org.zwobble.precisely.Matchers.has; +import static org.zwobble.precisely.Matchers.isOptionalOf; public class TypedFunctionSignatureNodeMatcher extends MatcherBuilder< TypedFunctionSignatureNode, @@ -45,6 +46,6 @@ public class TypedFunctionSignatureNodeMatcher extends MatcherBuilder< } public TypedFunctionSignatureNodeMatcher withReturnType(Matcher> returnType) { - return with(has("returnType", x -> x.returnType(), returnType)); + return with(has("returnType", x -> x.returnType(), isOptionalOf(returnType))); } } -- cgit v1.2.3