Files
STSheets/tests/core/rng.test.ts
T
2026-10-30 02:38:02 +01:00

11 lines
452 B
TypeScript

import { test, expect } from "bun:test";
import { createRng } from "../../src/core/rng.ts";
test("rng deterministic", () => {
const a = createRng(42), b = createRng(42), c = createRng(43);
const sa = [a.next(), a.next(), a.next()];
expect([b.next(), b.next(), b.next()]).toEqual(sa);
expect(c.next()).not.toBe(sa[0]);
const r = createRng(1); for (let i = 0; i < 1000; i++) { const v = r.int(3, 5); expect(v >= 3 && v <= 5).toBe(true); }
});