mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-13 17:04:25 +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,58 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user