Seed each Day-Care cartridge comparison from its own title [no-card]

The six tests drew their cases from one generator shared by the file, so
a test's inputs depended on which tests the worker had run before it:
Chromium and WebKit, or a full run and a single test, compared different
cases, and a failure could not be replayed by running that test alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kawaandClaude Opus 5.5 committed 2026-10-17 10:53:27 +02:00
1 parent 7a32e689c3
commit 87b05b45f4
1 file changed
+9 -2
+9 -2
View File
@@ -190,8 +190,15 @@ test.describe("Day-Care routines against the cartridge", () => {
...extra, ...extra,
}); });
// A small deterministic generator for the cases. // A small deterministic generator for the cases, seeded by each test from
let seed = 0x5eed; // its own title (FNV-1a): a test's cases are the same whichever tests ran
// before it in the worker, and in every browser.
let seed = 0;
test.beforeEach(({}, testInfo) => {
seed = 0x811c9dc5;
for (const character of testInfo.title)
seed = Math.imul(seed ^ character.charCodeAt(0), 0x01000193) >>> 0;
});
const next = (limit = 256) => { const next = (limit = 256) => {
seed = (Math.imul(seed, 1664525) + 1013904223) >>> 0; seed = (Math.imul(seed, 1664525) + 1013904223) >>> 0;
return (seed >>> 8) % limit; return (seed >>> 8) % limit;