Skip to content

Commit

Permalink
Add more tests, and build tests against java 17, clean up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
OroArmor committed Nov 18, 2021
1 parent 308dbe3 commit be6bff2
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 22 deletions.
10 changes: 10 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ repositories {
mavenCentral()
}

tasks.withType(JavaCompile.class) {
it.targetCompatibility = 17
it.sourceCompatibility = 17
}

tasks.getByName("compileJava") {
it.targetCompatibility = 16
it.sourceCompatibility = 16
}

generateGrammarSource {
maxHeapSize = "64m"
arguments += ["-visitor", "-long-messages"]
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/quiltmc/chasm/asm/ChasmClassVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ChasmClassVisitor extends ClassVisitor {
private final ListNode attributes = new LinkedListNode();

public ChasmClassVisitor() {
super(Opcodes.ASM7);
super(Opcodes.ASM9);
}

public MapNode getClassNode() {
Expand Down
9 changes: 6 additions & 3 deletions src/test/java/org/quiltmc/chasm/UnmodifiedClassesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
public class UnmodifiedClassesTest {
public static String[] classNames() {
return new String[] {
"org.quiltmc.chasm.ExampleClass",
"org.quiltmc.chasm.ExampleClass$ExampleAnnotation",
"org.quiltmc.chasm.ExampleClass$ExampleRecord",
"org.quiltmc.chasm.testclasses.ExampleClass",
"org.quiltmc.chasm.testclasses.ExampleClass$ExampleAnnotation",
"org.quiltmc.chasm.testclasses.ExampleClass$ExampleRecord",
"org.quiltmc.chasm.testclasses.ExampleEnum",
"org.quiltmc.chasm.testclasses.SealedTest",
"org.quiltmc.chasm.testclasses.SealedTest$SealedExtendsTest",
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.quiltmc.chasm;
package org.quiltmc.chasm.testclasses;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public abstract class ExampleClass {
public static void publicStaticMethod() {
Expand Down Expand Up @@ -32,29 +34,28 @@ public static String testSwitch() {
case 10 -> {
String nested = "Test";
yield switch (nested) {
case "NotTest" -> {
yield "NotTest";
}
case "NotTest" -> "NotTest";
default -> throw new IllegalStateException("Unexpected value: " + "Test");
};
}
default -> "Not 10";
};
}

public static String testSwitch() {
return switch ((int) Math.round(Math.random() * 100)) {
case 10 -> {
String nested = "Test";
yield switch (nested) {
case "NotTest" -> {
yield "NotTest";
}
default -> throw new IllegalStateException("Unexpected value: " + "Test");
};
}
default -> "Not 10";
};
public static int testGenerics() throws ExecutionException, InterruptedException {
int output = CompletableFuture.supplyAsync(() -> 5)
.thenApply(i -> Integer.toString(i))
.thenAccept(System.out::println)
.thenApply(v -> 7)
.get();

switch (output) {
case 7: output = 10;
default:
output = 7;
}

return output;
}

public abstract void annotationTest(@ExampleAnnotation("first") String first, @ExampleAnnotation("second") String second);
Expand All @@ -67,4 +68,5 @@ yield switch (nested) {
public static record ExampleRecord(Integer first, String second) {

}

}
15 changes: 15 additions & 0 deletions src/test/java/org/quiltmc/chasm/testclasses/ExampleEnum.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.quiltmc.chasm.testclasses;

public enum ExampleEnum {
A(1), B(2) {
public String toString() {
return "b";
}
};

private final int value;

ExampleEnum(int value) {
this.value = value;
}
}
7 changes: 7 additions & 0 deletions src/test/java/org/quiltmc/chasm/testclasses/SealedTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.quiltmc.chasm.testclasses;

public sealed class SealedTest permits SealedTest.SealedExtendsTest {
public static final class SealedExtendsTest extends SealedTest {

}
}

0 comments on commit be6bff2

Please sign in to comment.