test: characterize supported tile hooks

This commit is contained in:
Algent committed 2026-09-05 15:03:48 +02:00
1 parent 37d5ea98f6
commit 8b12dfe507
2 files changed
+64 -1

No files matched your search

@@ -20,6 +20,33 @@ import scala.collection.immutable.Nil$;
/** Consumer-visible state and behavior of the generated slotted-tile trait. */
class TSlottedTileFunctionalTest {
@Test
void cacheBindingDoesNotPlaceOrRebindThePartAndLeavesOldSlotsUntilExplicitlyCleared() throws Exception {
TileMultipart tile = newSlottedTile();
TileMultipart owner = new TileMultipart();
SlotPart part = new SlotPart(1 << 1);
part.bind(owner);
tile.bindPart(part);
assertTrue(tile.jPartList().isEmpty());
assertSame(owner, part.tile());
assertSame(part, tile.partMap(1));
part.slotMask = 1 << 5;
tile.bindPart(part);
assertSame(part, tile.partMap(1), "bindPart adds current slots; it does not remove the old mask");
assertSame(part, tile.partMap(5));
TMultiPart[] slots = partMap(tile);
for (int i = 0; i < slots.length; i++) {
if (slots[i] == part) slots[i] = null;
}
tile.bindPart(part);
assertNull(tile.partMap(1));
assertSame(part, tile.partMap(5));
assertSame(owner, part.tile());
assertTrue(tile.jPartList().isEmpty());
}
@Test
void copyFromSharesACompatibleSlotArrayAndKeepsItForAPlainSource() throws Exception {
TileMultipart source = newSlottedTile();
@@ -140,7 +167,7 @@ class TSlottedTileFunctionalTest {
private static final class SlotPart extends PlainPart implements TSlottedPart {
private final int slotMask;
private int slotMask;
private SlotPart(int slotMask) {
this.slotMask = slotMask;
@@ -16,6 +16,42 @@ import scala.collection.Seq;
/** Equality and callback semantics of the pre-port TileMultipart implementation. */
class TileMultipartEqualityRegressionTest {
@Test
void localChangeUsesCapturedOrderSkipsDetachedPartsAndPropagatesCallbackFailures() {
List<String> events = new ArrayList<>();
TileMultipart tile = new TileMultipart();
EqualPart detached = new EqualPart("detached", "detached", events);
EqualPart rebound = new EqualPart("rebound", "rebound", events);
EqualPart added = new EqualPart("added", "added", events);
EqualPart first = new EqualPart("first", "first", events) {
@Override
public void onPartChanged(TMultiPart part) {
super.onPartChanged(part);
detached.bind(null);
rebound.bind(new TileMultipart());
tile.setPartList(Arrays.asList(added));
}
};
RuntimeException failure = new IllegalStateException("local change failure");
EqualPart failing = new EqualPart("failing", "failing", events) {
@Override
public void onPartChanged(TMultiPart part) {
super.onPartChanged(part);
throw failure;
}
};
EqualPart later = new EqualPart("later", "later", events);
add(tile, first, detached, rebound, failing, later);
added.bind(tile);
assertSame(failure, assertThrows(RuntimeException.class, () -> tile.internalPartChange(null)));
assertEquals(Arrays.asList("first.changed:null", "rebound.changed:null", "failing.changed:null"), events);
assertEquals(Arrays.asList(added), tile.jPartList());
assertNull(tile.getWorldObj(), "Local notification requires no world and performs no world notification");
}
@Test
void internalPartChangeExcludesDistinctEqualPartsAndStillBroadcastsNull() {
List<String> events = new ArrayList<>();