time for a snapshot

This commit is contained in:
Schluffe
2026-07-11 17:48:28 +02:00
parent 135b7c3042
commit 7262752e16
47 changed files with 1712 additions and 61 deletions
+25
View File
@@ -0,0 +1,25 @@
import { expect, test } from "bun:test";
import { add, scale, sub, vec } from "./vector.ts";
test("vec builds a vector", () => {
expect(vec(2, 3)).toEqual({ x: 2, y: 3 });
});
test("add is component-wise", () => {
expect(add(vec(1, 2), vec(3, 4))).toEqual({ x: 4, y: 6 });
});
test("sub is component-wise", () => {
expect(sub(vec(5, 5), vec(1, 2))).toEqual({ x: 4, y: 3 });
});
test("scale multiplies both components", () => {
expect(scale(vec(2, 3), 2)).toEqual({ x: 4, y: 6 });
expect(scale(vec(2, 3), 0)).toEqual({ x: 0, y: 0 });
});
test("inputs are not mutated (pure functions)", () => {
const a = vec(1, 2);
add(a, vec(3, 4));
expect(a).toEqual({ x: 1, y: 2 });
});