Archived
tests/js: break the tautology the delta review caught, and three surviving mutants
The delta review refuted guard 3 of 4dce97b, and it was right. Replacing the re-typed formatters with a slice of the shipped ones removed one unfalsifiable shape and installed another: tpsF/cnt3F/ durF are called on BOTH sides of every comparison, so any formatter bug cancels out. Verified with my own instrument before fixing -- shipped `tps = (v) => "X"` passed all 37 checks. The brief warned about exactly this and I walked into it anyway. Three sections added, each mutation-tested with rc captured on its own line: Formatter literals (14 checks). The only place the formatters are pinned to something other than themselves. tps -> "X" now fails 5 checks; the dur ms branch -> *100 + " s" fails 2. Band boundaries are pinned at both edges (9.995 inclusive, 99.95 exclusive) because that is the rule F1 of the docs fix depends on. Values were derived from the shipped source rather than copied from the review's draft, which caught a real error in it: DASH is U+2013, not a hyphen, so the drafted `tpsF(NaN) === "-"` would have failed on correct code. Median at an ODD row count (2 checks). M17 survived the previous fixture change because the median was only ever asserted at n=24, where floor(12) and ceil(12) are the same row -- a non-uniform fixture could never have caught it, so the earlier diagnosis named the right cause and the wrong cure. n=25 makes the two candidates differ, and floor->ceil now fails with "1.80 s" want "1.70 s". Threshold counts adjacent to the boundaries (8 cases, up from 3). M15 survived because no case sat at 19, and a >=5 -> >=7 mutation survived because no case sat below 7. Counts now straddle both thresholds: 4/5/6 pin the 5 boundary, 19/20 pin the 20. history.test.js 37 -> 63 checks. Full suite: 27/35/63/34 JS, 241/8 and 62646/184 C++. GAP D (the revoke delay argument) deliberately not pinned: the 1000 ms is a safety margin, not a contract, and a guard that fails a reasonable 500 ms encodes an arbitrary constant. Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (xhigh) via Open WebUI
This commit is contained in:
1 parent
8be040f599
commit
d564e6e5b1
1 file changed
+40
-2
@@ -146,8 +146,12 @@ const wantTtft = "ttft median " + durF(tfsSorted[Math.floor(tfsSorted.length / 2
|
||||
ok(textNodes[0].txt === wantTtft,
|
||||
"value and unit are one string, rendered by the shipped dur(): " + JSON.stringify(textNodes[0].txt) + " want " + JSON.stringify(wantTtft));
|
||||
console.log("== the window thresholds: last 20 needs 20 rows, last 5 needs 5 ==");
|
||||
/* 12 is the discriminating count: it kills a threshold lowered to <=12 as well as one raised. */
|
||||
for (const [n, want20, want5] of [[7, false, true], [12, false, true], [24, true, true]]) {
|
||||
/* Every count sits ADJACENT to a threshold, because that is the only place a threshold can move
|
||||
unnoticed: 19/20 pins the 20 boundary (>=19 fails at 19), 4/5 pins the 5 boundary (>=6 or >=7
|
||||
fails at 5). Counts spaced further apart leave the off-by-one free to move. */
|
||||
for (const [n, want20, want5] of [[4, false, false], [5, false, true], [6, false, true],
|
||||
[7, false, true], [12, false, true], [19, false, true],
|
||||
[20, true, true], [24, true, true]]) {
|
||||
const box = mk("span", "hsum");
|
||||
new Function("el", "document", "$", "hRows", "tps", "cnt3", "dur", BLOCK)(
|
||||
el, doc, () => box, mkRows(n), tpsF, cnt3F, durF);
|
||||
@@ -155,5 +159,39 @@ for (const [n, want20, want5] of [[7, false, true], [12, false, true], [24, true
|
||||
eq(t.includes("last 20:"), want20, n + " rows: last 20 " + (want20 ? "shows" : "stays hidden (it would repeat the overall mean)"));
|
||||
eq(t.includes("last 5:"), want5, n + " rows: last 5 " + (want5 ? "shows" : "stays hidden"));
|
||||
}
|
||||
console.log("== the shipped formatters render these exact strings ==");
|
||||
/* The window guards above call tpsF/cnt3F/durF on BOTH sides, so a formatter bug cancels out --
|
||||
replacing tps with a constant passed the whole suite. These literals are the only place the
|
||||
formatters are pinned to something that is not themselves. Values derived from the shipped
|
||||
source; DASH is U+2013, not a hyphen. */
|
||||
eq(tpsF(58), "58.0", "tps keeps one decimal through the middle band");
|
||||
eq(tpsF(54), "54.0", "tps: the GUIDE's F1 example figure");
|
||||
eq(tpsF(9.995), "10.0", "tps lower band boundary is inclusive");
|
||||
eq(tpsF(99.949), "99.9", "tps just under the upper boundary keeps a decimal");
|
||||
eq(tpsF(99.95), "100", "tps upper band boundary is exclusive");
|
||||
eq(tpsF(120), "120", "tps above the band is an integer");
|
||||
eq(tpsF(0), "0", "tps of zero is 0, not 0.00");
|
||||
eq(tpsF(NaN), "\u2013", "tps of a non-finite is the en-dash");
|
||||
eq(cnt3F(691), "691", "cnt3 below the kilo step is a plain integer");
|
||||
eq(cnt3F(1234567), "1.23M", "cnt3 steps to M with three significant figures");
|
||||
eq(durF(0.813), "813 ms", "dur under a second is whole milliseconds");
|
||||
eq(durF(0), "0 ms", "dur of zero is 0 ms");
|
||||
eq(durF(1.7), "1.70 s", "dur just over a second carries two decimals");
|
||||
eq(durF(59.97), "1m 00s", "dur rounds to the shown resolution BEFORE splitting (not 60.0 s)");
|
||||
|
||||
console.log("== the median is falsifiable: an ODD row count ==");
|
||||
/* At n=24 floor(12) and ceil(12) are the same row, so floor->ceil in the shipped median passed
|
||||
every earlier fixture. Only an odd count makes the two candidates differ. */
|
||||
const box25 = mk("span", "hsum");
|
||||
const r25 = mkRows(25);
|
||||
const s25 = r25.map((r) => r.ttft).sort((a, b) => a - b);
|
||||
ok(s25[Math.floor(25 / 2)] !== s25[Math.ceil(25 / 2)],
|
||||
"n=25 makes floor and ceil pick different rows, so the guard can tell them apart");
|
||||
new Function("el", "document", "$", "hRows", "tps", "cnt3", "dur", BLOCK)(
|
||||
el, doc, () => box25, r25, tpsF, cnt3F, durF);
|
||||
const ttft25 = box25.kids.filter((k) => k.cls === "hgrp")[3].kids
|
||||
.filter((k) => k.cls !== "hsep").map((k) => k.txt || "").join("");
|
||||
eq(ttft25, "ttft median 1.70 s", "the shipped median takes the floor row at n=25");
|
||||
|
||||
console.log(fails ? "\n" + fails + " FAILURE(S) of " + checks : "\nALL " + checks + " CHECKS PASS on the shipped history line");
|
||||
process.exit(fails ? 1 : 0);
|
||||
Reference in new issue
Block a user