diff options
Diffstat (limited to 'src/test')
3 files changed, 53 insertions, 12 deletions
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java index 178ca0a..4ce2ea1 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java @@ -1219,19 +1219,19 @@ public class JavaWriterTests { new JavaRef(JavaIdentifier.of("x")), List.of( new JavaSwitchRule( - new JavaCasePattern( + new JavaCasePattern(new JavaPattern( JavaTypeRef.topLevel(JavaPackageName.of("org", "example"), JavaIdentifier.of("A")), JavaIdentifier.of("a") - ), + )), new JavaBlock(List.of( new JavaReturn(new JavaIntegerLiteral(0)) )) ), new JavaSwitchRule( - new JavaCasePattern( + new JavaCasePattern(new JavaPattern( JavaTypeRef.topLevel(JavaPackageName.of("org", "example"), JavaIdentifier.of("B")), JavaIdentifier.of("b") - ), + )), new JavaBlock(List.of( new JavaReturn(new JavaIntegerLiteral(1)) )) diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCasePatternMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCasePatternMatcher.java index ebf029c..d4bf59a 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCasePatternMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaCasePatternMatcher.java @@ -30,15 +30,9 @@ public class JavaCasePatternMatcher implements org.zwobble.precisely.Matcher<jav return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern.class, this.submatchers); } - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePatternMatcher withType(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef> type) { + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePatternMatcher withPattern(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaPattern> pattern) { var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern>>(this.submatchers); - submatchers.add(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern::type, type)); - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePatternMatcher(submatchers); - } - - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePatternMatcher withVariableName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> variableName) { - var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern>>(this.submatchers); - submatchers.add(org.zwobble.precisely.Matchers.has("variableName", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern::variableName, variableName)); + submatchers.add(org.zwobble.precisely.Matchers.has("pattern", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePattern::pattern, pattern)); return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaCasePatternMatcher(submatchers); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaPatternMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaPatternMatcher.java new file mode 100644 index 0000000..789da61 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaPatternMatcher.java @@ -0,0 +1,47 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.java.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaPatternMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaPatternMatcher imports + +public class JavaPatternMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaPatternMatcher isJavaPattern() { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaPatternMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaPattern>> submatchers; + + private JavaPatternMatcher( + java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaPattern>> submatchers + ) { + this.submatchers = submatchers; + } + + public org.zwobble.precisely.MatchResult match(java.lang.Object actual) { + return this.toMatcher().match(actual); + } + + public org.zwobble.precisely.TextTree describe() { + return this.toMatcher().describe(); + } + + private org.zwobble.precisely.Matcher<java.lang.Object> toMatcher() { + return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaPattern.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaPatternMatcher withType(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaTypeRef> type) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaPattern>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("type", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaPattern::type, type)); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaPatternMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaPatternMatcher withVariableName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaIdentifier> variableName) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaPattern>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("variableName", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaPattern::variableName, variableName)); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaPatternMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaPatternMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaPatternMatcher body +} |
