note: close out the model — correct an inert mutation claim, retag four non-discriminating assertions, assert Tempo's closure, fix three doc/test accuracy gaps

No behavior change; verification-record corrections and one static_assert.
This commit is contained in:
2026-07-30 21:03:02 -04:00
parent a80eb76c1f
commit dddecc5734
5 changed files with 42 additions and 12 deletions
+5
View File
@@ -175,6 +175,9 @@ static void testUnnamedModifierClampsToStraight() {
== divisionIndex(makeDivision(0, DivisionModifier::Straight)));
CHECK(divisionLabel(makeDivision(0, junk)) == "1/4"); // and no junk reaches the readout
CHECK(makeDivision(0, junk) == makeDivision(0, DivisionModifier::Straight));
// Measured (clamp removed from clampModifier): still passes. junk(7) != Dotted's stored
// modifier either way, clamped or raw — this discriminates a degenerate operator== that
// ignores the modifier field, not the clamp itself.
CHECK(makeDivision(0, junk) != makeDivision(0, DivisionModifier::Dotted));
}
@@ -184,6 +187,8 @@ static void testEveryConstructibleDivisionIndexesIntoThePickerSet() {
// modifier clamp.
const int exponents[] = {-9000, -99, kMinQuarterExponent, 0, kMaxQuarterExponent, 120, 9000};
for (int e : exponents) {
// 260, not 256: m=256..259 wrap modulo uint8_t back to 0..3, re-covering the four
// lowest bytes rather than reaching any byte 256 alone couldn't already reach.
for (int m = 0; m < 260; ++m) {
const Division d = makeDivision(e, static_cast<DivisionModifier>(m));
const int index = divisionIndex(d);
+18 -2
View File
@@ -356,14 +356,27 @@ static void testEveryDenominationBranchingFunctionAgreesWithThePin() {
CHECK(corrupt == asMs); // offsetMs / offsetBeats / offsetSeconds covered above
CHECK(!(corrupt != asMs));
CHECK(redenominate(corrupt, Denomination::Milliseconds, t) == corrupt);
// Measured (mutate offsetOf to a pass-through): still passes. offsetFromBeats always
// tags its result Beats, so this holds regardless of whether corrupt was pinned — it
// does not discriminate the pin.
CHECK(redenominate(corrupt, Denomination::Beats, t).denomination() == Denomination::Beats);
// Reported measured (withMsView reverted to its pre-domain-closure form): still passes.
// corrupt already equals asMs by this point, and withMsView is a pure function of its
// argument, so this line cannot discriminate anything withMsView-specific — it is a
// restatement of the equality above.
CHECK(withMsView(corrupt, 40.0, t) == withMsView(asMs, 40.0, t));
CHECK(withMsView(corrupt, 40.0, t).denomination() == Denomination::Milliseconds);
// Measured (mutate offsetOf to a pass-through): still passes. withBeatsView only branches
// on `== Beats`; any non-Beats value — pinned or raw corrupt — takes the same ms-based
// else branch, so this does not discriminate the pin either.
CHECK(withBeatsView(corrupt, 1.0, t) == withBeatsView(asMs, 1.0, t));
CHECK(withBeatsView(corrupt, 1.0, t).denomination() == Denomination::Milliseconds);
CHECK(almostEqual(withBeatsView(corrupt, 1.0, t).magnitude(), 500.0, 1e-6));
// An unnamed TARGET denomination pins the same way an unnamed stored one does.
// Reported measured (offsetOf(0.0, to) replaced with `= to;`): still passes, for the
// same reason as above — `target == Beats` is false whether target is pinned or raw, so
// this always takes the ms branch and cannot discriminate the door (see the comment on
// that line in note_program.cpp).
CHECK(redenominate(offsetFromBeats(1.0), static_cast<Denomination>(7), t)
== offsetFromMs(500.0));
}
@@ -445,7 +458,10 @@ static void testResolveNoteIsFiniteForEveryConstructibleInput() {
const double magnitudes[] = {-inf, -kMaxConvertibleMagnitude, -1e300, 0.0, 1e300,
kMaxConvertibleMagnitude, inf, nan};
int accepted = 0, rejected = 0;
for (double bpm : {1e-320, 1e-306, 1e-200, 1e-6, 0.5, 120.0, 1e6, 1e100, 1e308}) {
// 1e-294/1e-295 bracket the accept/reject edge (measured ~3.34e-295) so the sweep
// actually approaches it rather than jumping past it by ~95 orders of magnitude.
for (double bpm :
{1e-320, 1e-306, 1e-295, 1e-294, 1e-200, 1e-6, 0.5, 120.0, 1e6, 1e100, 1e308}) {
const std::optional<Tempo> tempo = Tempo::fromBpm(bpm);
if (!tempo) { ++rejected; continue; }
++accepted;