summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-07-27 20:14:34 +0100
committerMichael Williamson <mike@zwobble.org>2026-07-27 20:17:54 +0100
commitbece8f933669ed6d83e99ba22a4829480470a3eb (patch)
tree2cd98d46f1fede76df7bee5fb1d6305482fc7d66 /src
parent044089d9370a5b4d492b2d2858980269b3eacdfe (diff)
Reorder tests to match AST definitions
Diffstat (limited to 'src')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java82
1 files changed, 42 insertions, 40 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 8b60341..80c145d 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
@@ -1267,7 +1267,7 @@ public class JavaWriterTests {
// == Expressions ==
- // === Binary operations ===
+ // === Array accesses ===
@Test
public void arrayAccess() throws IOException {
@@ -1281,6 +1281,8 @@ public class JavaWriterTests {
assertThat(string, equalTo("x[42]"));
}
+ // === Binary operations ===
+
@Test
public void binaryOperationAdd() throws IOException {
var java = new JavaBinaryOperation(
@@ -1308,6 +1310,32 @@ public class JavaWriterTests {
}
@Test
+ public void binaryOperationBitwiseAnd() throws IOException {
+ var java = JavaBinaryOperation.arbitrary()
+ .withOperator(JavaBinaryOperator.BITWISE_AND)
+ .withLeft(JavaRef.arbitrary().withName(JavaIdentifier.of("x")))
+ .withRight(JavaRef.arbitrary().withName(JavaIdentifier.of("y")))
+ .build();
+
+ var string = write(writer -> writer.writeTopLevelExpression(java));
+
+ assertThat(string, equalTo("x & y"));
+ }
+
+ @Test
+ public void binaryOperationBitwiseOr() throws IOException {
+ var java = JavaBinaryOperation.arbitrary()
+ .withOperator(JavaBinaryOperator.BITWISE_OR)
+ .withLeft(JavaRef.arbitrary().withName(JavaIdentifier.of("x")))
+ .withRight(JavaRef.arbitrary().withName(JavaIdentifier.of("y")))
+ .build();
+
+ var string = write(writer -> writer.writeTopLevelExpression(java));
+
+ assertThat(string, equalTo("x | y"));
+ }
+
+ @Test
public void binaryOperationEqualTo() throws IOException {
var java = new JavaBinaryOperation(
JavaBinaryOperator.EQUAL_TO,
@@ -1321,6 +1349,19 @@ public class JavaWriterTests {
}
@Test
+ public void binaryOperationLeftShift() throws IOException {
+ var java = JavaBinaryOperation.arbitrary()
+ .withOperator(JavaBinaryOperator.LEFT_SHIFT)
+ .withLeft(JavaRef.arbitrary().withName(JavaIdentifier.of("x")))
+ .withRight(JavaRef.arbitrary().withName(JavaIdentifier.of("y")))
+ .build();
+
+ var string = write(writer -> writer.writeTopLevelExpression(java));
+
+ assertThat(string, equalTo("x << y"));
+ }
+
+ @Test
public void binaryOperationLessThan() throws IOException {
var java = new JavaBinaryOperation(
JavaBinaryOperator.LESS_THAN,
@@ -1360,19 +1401,6 @@ public class JavaWriterTests {
}
@Test
- public void binaryOperationUnsignedLeftShift() throws IOException {
- var java = JavaBinaryOperation.arbitrary()
- .withOperator(JavaBinaryOperator.LEFT_SHIFT)
- .withLeft(JavaRef.arbitrary().withName(JavaIdentifier.of("x")))
- .withRight(JavaRef.arbitrary().withName(JavaIdentifier.of("y")))
- .build();
-
- var string = write(writer -> writer.writeTopLevelExpression(java));
-
- assertThat(string, equalTo("x << y"));
- }
-
- @Test
public void binaryOperationUnsignedRightShift() throws IOException {
var java = JavaBinaryOperation.arbitrary()
.withOperator(JavaBinaryOperator.UNSIGNED_RIGHT_SHIFT)
@@ -1385,32 +1413,6 @@ public class JavaWriterTests {
assertThat(string, equalTo("x >>> y"));
}
- @Test
- public void binaryOperationBitwiseAnd() throws IOException {
- var java = JavaBinaryOperation.arbitrary()
- .withOperator(JavaBinaryOperator.BITWISE_AND)
- .withLeft(JavaRef.arbitrary().withName(JavaIdentifier.of("x")))
- .withRight(JavaRef.arbitrary().withName(JavaIdentifier.of("y")))
- .build();
-
- var string = write(writer -> writer.writeTopLevelExpression(java));
-
- assertThat(string, equalTo("x & y"));
- }
-
- @Test
- public void binaryOperationBitwiseOr() throws IOException {
- var java = JavaBinaryOperation.arbitrary()
- .withOperator(JavaBinaryOperator.BITWISE_OR)
- .withLeft(JavaRef.arbitrary().withName(JavaIdentifier.of("x")))
- .withRight(JavaRef.arbitrary().withName(JavaIdentifier.of("y")))
- .build();
-
- var string = write(writer -> writer.writeTopLevelExpression(java));
-
- assertThat(string, equalTo("x | y"));
- }
-
// === Boolean literals ===
@Test