Initial Commit

This commit is contained in:
2026-05-27 23:47:53 +01:00
parent fbc70f96e6
commit 9b28db724f
18103 changed files with 1600554 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
import { describe, expect, it } from "@suaveplan/testing/runner";
import { Xoshiro256PlusPlusRng } from "./xoshiro256.js";
class ZeroXoshiro extends Xoshiro256PlusPlusRng {
public constructor() {
super(1);
this.s0 = 0n;
this.s1 = 0n;
this.s2 = 0n;
this.s3 = 0n;
}
public callEnsureNonZero(): void {
this.ensureNonZeroState();
}
public readState(): [bigint, bigint, bigint, bigint] {
return [this.s0, this.s1, this.s2, this.s3];
}
}
describe("Xoshiro256 ensureNonZeroState guard", () => {
it("repairs an all-zero state by setting s0=1", { timeout: 5000 }, () => {
const rng = new ZeroXoshiro();
rng.callEnsureNonZero();
expect(rng.readState()).toEqual([1n, 0n, 0n, 0n]);
});
});