From 6ea86b1b56aebbae7edeb37b01d7bf5cd145bf60 Mon Sep 17 00:00:00 2001 From: Josh Kingsley Date: Thu, 6 Nov 2025 22:31:12 +0200 Subject: feat(web): change subvisions --- web/src/math/Ratio.test.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 web/src/math/Ratio.test.ts (limited to 'web/src/math/Ratio.test.ts') diff --git a/web/src/math/Ratio.test.ts b/web/src/math/Ratio.test.ts new file mode 100644 index 0000000..da6fef2 --- /dev/null +++ b/web/src/math/Ratio.test.ts @@ -0,0 +1,27 @@ +import { describe, expect, test } from "vitest"; +import Ratio from "./Ratio"; + +describe(Ratio, () => { + describe(Ratio.prototype.add, () => { + test("returns fractions in simplest form", () => { + const a = Ratio.fromInteger(0); + const b = new Ratio(1, 4); + + const c = a.add(b); + expect(c.numerator).toBe(1); + expect(c.denominator).toBe(4); + + const d = c.add(b); + expect(d.numerator).toBe(1); + expect(d.denominator).toBe(2); + + const e = d.add(b); + expect(e.numerator).toBe(3); + expect(e.denominator).toBe(4); + + const f = e.add(b); + expect(f.numerator).toBe(1); + expect(f.denominator).toBe(1); + }); + }); +}); -- cgit v1.2.3