diff options
Diffstat (limited to 'src/test/java/org/zwobble')
4 files changed, 67 insertions, 104 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 ff374fb..8c3531f 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 @@ -836,8 +836,9 @@ public class JavaWriterTests { } @Test - public void assignment() throws IOException { - var java = new JavaAssignment( + public void binaryOperationAssignment() throws IOException { + var java = new JavaBinaryOperation( + JavaBinaryOperator.ASSIGN, new JavaRef(JavaIdentifier.of("x")), new JavaIntegerLiteral(42) ); @@ -848,6 +849,19 @@ public class JavaWriterTests { } @Test + public void binaryOperationUnsignedRightShift() throws IOException { + var java = JavaBinaryOperation.arbitrary() + .withOperator(JavaBinaryOperator.UNSIGNED_RIGHT_SHIFT) + .withLeft(JavaRef.arbitrary().withName(JavaIdentifier.of("x"))) + .withRight(JavaRef.arbitrary().withName(JavaIdentifier.of("y"))) + .build(); + + var string = write(writer -> writer.writeExpression(java)); + + assertThat(string, equalTo("x >>> y")); + } + + @Test public void fieldAccess() throws IOException { var java = new JavaFieldAccess( new JavaRef(JavaIdentifier.of("one")), @@ -905,18 +919,6 @@ public class JavaWriterTests { } @Test - public void unsignedRightShift() throws IOException { - var java = JavaUnsignedRightShift.arbitrary() - .withLeft(JavaRef.arbitrary().withName(JavaIdentifier.of("x"))) - .withRight(JavaRef.arbitrary().withName(JavaIdentifier.of("y"))) - .build(); - - var string = write(writer -> writer.writeExpression(java)); - - assertThat(string, equalTo("x >>> y")); - } - - @Test public void typeRefWithoutArgsHasNoAngleBrackets() throws IOException { var java = JavaTypeRef.topLevel( JavaPackageName.of("abc", "def"), diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaAssignmentMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaAssignmentMatcher.java deleted file mode 100644 index dd3ce7d..0000000 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaAssignmentMatcher.java +++ /dev/null @@ -1,45 +0,0 @@ -// Generated by hobgoblin. - -package org.zwobble.hobgoblin.compiler.output.lang.java.ast; - -// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignmentMatcher imports -// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignmentMatcher imports - -public class JavaAssignmentMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { - public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignmentMatcher isJavaAssignment() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignmentMatcher(java.util.List.of()); - } - - private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment>> submatchers; - - private JavaAssignmentMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment>> 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.JavaAssignment.class, this.submatchers); - } - - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignmentMatcher withLeft(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> left) { - var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment>>(this.submatchers); - submatchers.add(org.zwobble.precisely.Matchers.has("left", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment::left, left)); - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignmentMatcher(submatchers); - } - - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignmentMatcher withRight(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> right) { - var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment>>(this.submatchers); - submatchers.add(org.zwobble.precisely.Matchers.has("right", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignment::right, right)); - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignmentMatcher(submatchers); - } - - // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignmentMatcher body - // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaAssignmentMatcher body -} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaBinaryOperationMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaBinaryOperationMatcher.java new file mode 100644 index 0000000..4157a44 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaBinaryOperationMatcher.java @@ -0,0 +1,51 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.java.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher imports + +public class JavaBinaryOperationMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { + public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher isJavaBinaryOperation() { + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher(java.util.List.of()); + } + + private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation>> submatchers; + + private JavaBinaryOperationMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation>> 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.JavaBinaryOperation.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher withOperator(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperator> operator) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("operator", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation::operator, operator)); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher withLeft(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> left) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("left", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation::left, left)); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher(submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher withRight(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> right) { + var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation>>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("right", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperation::right, right)); + return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaBinaryOperationMatcher body +} diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaUnsignedRightShiftMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaUnsignedRightShiftMatcher.java deleted file mode 100644 index 7da71c1..0000000 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/ast/JavaUnsignedRightShiftMatcher.java +++ /dev/null @@ -1,45 +0,0 @@ -// Generated by hobgoblin. - -package org.zwobble.hobgoblin.compiler.output.lang.java.ast; - -// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShiftMatcher imports -// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShiftMatcher imports - -public class JavaUnsignedRightShiftMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> { - public static org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShiftMatcher isJavaUnsignedRightShift() { - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShiftMatcher(java.util.List.of()); - } - - private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift>> submatchers; - - private JavaUnsignedRightShiftMatcher(java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift>> 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.JavaUnsignedRightShift.class, this.submatchers); - } - - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShiftMatcher withLeft(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> left) { - var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift>>(this.submatchers); - submatchers.add(org.zwobble.precisely.Matchers.has("left", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift::left, left)); - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShiftMatcher(submatchers); - } - - public org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShiftMatcher withRight(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaExpression> right) { - var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift>>(this.submatchers); - submatchers.add(org.zwobble.precisely.Matchers.has("right", org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShift::right, right)); - return new org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShiftMatcher(submatchers); - } - - // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShiftMatcher body - // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.java.ast.JavaUnsignedRightShiftMatcher body -} |
