Tests: END-1 Core drain/regen/lose-edge + persistence v4 (330/330 EditMode)

CoreSystemsTests (new): a breaching Husk drains + is consumed; idles at 0;
regen fires once per interval in Calm only; no regen mid-Siege; caps at Max.
CyclePhaseSystemTests: the soft-loss overrun edge ends the siege, drains the
ledger, despawns husks, withholds the goal charge, and resolves once.
StorageMathTests: DrainFraction floors per row, drops zeroed rows, clamps.
SavePersistenceTests: CoreCurrent round-trips at v4; a pre-END-1 save with no
CoreCurrent defaults to 0 (-> born full); the v3->v4 version pin updated.
TuningConfig golden pin extended with the 3 Core defaults.

See DR-034.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-12 21:51:52 -07:00
parent 60e1e21dd3
commit 037ff66490
6 changed files with 311 additions and 1 deletions
@@ -18,6 +18,51 @@ namespace ProjectM.Tests
return (world, e);
}
[Test]
public void DrainFraction_Removes_Floored_Fraction_Of_Each_Row()
{
var (world, e) = MakeWorld();
try
{
var buf = world.EntityManager.GetBuffer<StorageEntry>(e);
StorageMath.Deposit(buf, 2, 100); // Ore
StorageMath.Deposit(buf, 4, 51); // Charge
StorageMath.DrainFraction(buf, 0.5f);
Assert.AreEqual(50, StorageMath.TotalOf(buf, 2), "100 -> floor(50) drained -> 50 left");
Assert.AreEqual(26, StorageMath.TotalOf(buf, 4), "51 -> floor(25) drained -> 26 left");
}
finally { world.Dispose(); }
}
[Test]
public void DrainFraction_Drops_Rows_That_Hit_Zero_And_Clamps_Above_One()
{
var (world, e) = MakeWorld();
try
{
var buf = world.EntityManager.GetBuffer<StorageEntry>(e);
StorageMath.Deposit(buf, 2, 4);
StorageMath.DrainFraction(buf, 1.5f); // clamps to 1.0 -> removes all -> row dropped
Assert.AreEqual(0, buf.Length, "a fully-drained row is removed");
}
finally { world.Dispose(); }
}
[Test]
public void DrainFraction_Zero_Is_NoOp()
{
var (world, e) = MakeWorld();
try
{
var buf = world.EntityManager.GetBuffer<StorageEntry>(e);
StorageMath.Deposit(buf, 2, 10);
StorageMath.DrainFraction(buf, 0f);
Assert.AreEqual(10, StorageMath.TotalOf(buf, 2), "0 fraction drains nothing");
}
finally { world.Dispose(); }
}
[Test]
public void Deposit_New_Item_Appends_Row()
{