feat(rng-seam): ScriptedRandomSource (throw-on-overrun deterministic source)
This commit is contained in:
@@ -35,5 +35,21 @@ namespace SVSim.BattleEngine.Tests
|
||||
for (int i = 0; i < 8; i++)
|
||||
Assert.That(src.NextSelf(100), Is.EqualTo(refSelf.Next(100)), $"NextSelf drift at {i}");
|
||||
}
|
||||
|
||||
// ScriptedRandomSource feeds a known sequence (the oracle's control + the Phase-3 replay seam).
|
||||
// It MUST throw on overrun, not wrap: an unexpected extra roll should fail loudly so a test
|
||||
// surfaces a miscount of engine RNG calls rather than silently reusing a value.
|
||||
[Test]
|
||||
public void ScriptedSource_returns_sequence_then_throws_on_overrun()
|
||||
{
|
||||
var src = new ScriptedRandomSource(new[] { 0.1, 0.5 }, new[] { 3 });
|
||||
|
||||
Assert.That(src.NextUnit(), Is.EqualTo(0.1));
|
||||
Assert.That(src.NextUnit(), Is.EqualTo(0.5));
|
||||
Assert.That(() => src.NextUnit(), Throws.InvalidOperationException, "should throw on unit overrun");
|
||||
|
||||
Assert.That(src.NextSelf(99), Is.EqualTo(3));
|
||||
Assert.That(() => src.NextSelf(99), Throws.InvalidOperationException, "should throw on self overrun");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user