mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-18 03:25:35 +00:00
test: characterize TEdgePart
Freezes the single trait default before the port: conductsRedstone returns
false, TEdgePart extends TSlottedPart, and the $class static holds the
default rather than dispatching, so an overriding part gets its own value
from a direct call but false from the bridge.
The member is abstract on the reference interface, so a Java class cannot
inherit it today; the test part mirrors the forwarder Scala emits instead,
which keeps the file compiling before and after the port.
Adds a frozen Scala 2.11.5 consumer compiled against the reference dev jar
at f2f1870. OpenComputers is the only consumer, and it links against
$init$ rather than conductsRedstone.
61 plain-JVM tests, all passing against the untouched Scala.
This commit is contained in:
1 parent
f2f1870931
commit
f82b5d2294
5 files changed
+156
No files matched your search
@@ -0,0 +1,53 @@
|
||||
package codechicken.multipart;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.Objects;
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Loads a Scala class compiled against the reference dev jar, whose forwarder calls TEdgePart$class.conductsRedstone
|
||||
* and whose constructor calls TEdgePart$class.$init$. OpenComputers links against the latter.
|
||||
*/
|
||||
class TEdgePartBinaryCompatibilityTest {
|
||||
|
||||
@Test
|
||||
void referenceScalaImplementorStillLinksThroughTheBridge() throws Exception {
|
||||
Class<?> fixtureClass = new FixtureClassLoader(TEdgePart.class.getClassLoader()).define(loadFixture());
|
||||
Object fixture = fixtureClass.getDeclaredConstructor().newInstance();
|
||||
|
||||
assertTrue(fixture instanceof TEdgePart);
|
||||
assertTrue(fixture instanceof TSlottedPart);
|
||||
assertTrue(fixture instanceof TMultiPart);
|
||||
TEdgePart part = (TEdgePart) fixture;
|
||||
|
||||
assertFalse(part.conductsRedstone());
|
||||
assertEquals(1 << 15, part.getSlotMask());
|
||||
}
|
||||
|
||||
private static byte[] loadFixture() {
|
||||
InputStream input = Objects.requireNonNull(
|
||||
TEdgePartBinaryCompatibilityTest.class.getResourceAsStream("/compat/ReferenceScalaEdgePart.class.b64"));
|
||||
try (Scanner scanner = new Scanner(input, StandardCharsets.US_ASCII.name()).useDelimiter("\\A")) {
|
||||
return Base64.getMimeDecoder().decode(scanner.next());
|
||||
}
|
||||
}
|
||||
|
||||
private static final class FixtureClassLoader extends ClassLoader {
|
||||
|
||||
private FixtureClassLoader(ClassLoader parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
private Class<?> define(byte[] bytecode) {
|
||||
return defineClass(null, bytecode, 0, bytecode.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user