Files
ForgeMultipart/src/test/java/codechicken/multipart/EdgePartCharacterizationTest.java
T
Algent f82b5d2294 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.
2026-08-14 21:28:51 +02:00

59 lines
1.7 KiB
Java

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 org.junit.jupiter.api.Test;
class EdgePartCharacterizationTest {
@Test
void edgePartsDoNotConductRedstoneByDefault() {
assertFalse(new ForwardingPart().conductsRedstone());
}
/** The bridge holds the trait default rather than dispatching, so an override does not change what it returns. */
@Test
void deprecatedBridgeReturnsTheTraitDefaultEvenWhenOverridden() {
assertFalse(TEdgePart$class.conductsRedstone(new ForwardingPart()));
assertTrue(new ConductingPart().conductsRedstone());
assertFalse(TEdgePart$class.conductsRedstone(new ConductingPart()));
}
@Test
void edgePartIsASlottedPart() {
ForwardingPart part = new ForwardingPart();
assertTrue(part instanceof TSlottedPart);
assertEquals(1 << 15, part.getSlotMask());
}
/** Mirrors the forwarder Scala emits for a class mixing in the trait without overriding it. */
private static class ForwardingPart extends TMultiPart implements TEdgePart {
@Override
public String getType() {
return "test:edge";
}
@Override
public int getSlotMask() {
return 1 << 15;
}
@Override
public boolean conductsRedstone() {
return TEdgePart$class.conductsRedstone(this);
}
}
private static final class ConductingPart extends ForwardingPart {
@Override
public boolean conductsRedstone() {
return true;
}
}
}