feat: core types, time, rng, model fetch

Co-Authored-By: Claude Haiku 5.5 <[email protected]>
This commit is contained in:
Lucas Winther
2026-10-30 02:38:02 +01:00
co-authored by Claude Haiku 5.5
parent 0a6ec1dc40
commit bac4fbeb1d
8 changed files with 140 additions and 2 deletions
+10
View File
@@ -0,0 +1,10 @@
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); }
});
+8
View File
@@ -0,0 +1,8 @@
import { test, expect } from "bun:test";
import { ticksToSeconds, secondsToTicks } from "../../src/core/time.ts";
test("ticks/seconds", () => {
expect(ticksToSeconds(960, 60)).toBeCloseTo(1);
expect(ticksToSeconds(3840, 120)).toBeCloseTo(2);
expect(secondsToTicks(0.5, 120)).toBeCloseTo(960);
});