diff --git a/src/game/formulas/formulas.ts b/src/game/formulas/formulas.ts index bf989b1..79adfce 100644 --- a/src/game/formulas/formulas.ts +++ b/src/game/formulas/formulas.ts @@ -124,11 +124,14 @@ export abstract class InternalFormula { expect(formula.invert(100)).compare_tolerance(0); }); - test("Inverting with non-invertible sections", () => { - const formula = Formula.add(variable, constant.ceil()); - expect(formula.isInvertible()).toBe(true); - expect(formula.invert(10)).compare_tolerance(0); + describe("Inverting with non-invertible sections", () => { + test("Non-invertible constant", () => { + const formula = Formula.add(variable, constant.ceil()); + expect(formula.isInvertible()).toBe(true); + expect(() => formula.invert(10)).not.toThrow(); + }); + test("Non-invertible variable", () => { + const formula = Formula.add(variable.ceil(), constant); + expect(formula.isInvertible()).toBe(false); + expect(() => formula.invert(10)).toThrow(); + }); }); }); @@ -619,6 +626,19 @@ describe("Integrating", () => { const formula = Formula.pow(1.05, variable).times(100).pow(0.5); expect(() => formula.evaluateIntegral()).toThrow(); }); + + describe("Integrating with non-integrable sections", () => { + test("Non-integrable constant", () => { + const formula = Formula.add(variable, constant.ceil()); + expect(formula.isIntegrable()).toBe(true); + expect(() => formula.evaluateIntegral()).not.toThrow(); + }); + test("Non-integrable variable", () => { + const formula = Formula.add(variable.ceil(), constant); + expect(formula.isIntegrable()).toBe(false); + expect(() => formula.evaluateIntegral()).toThrow(); + }); + }); }); describe("Inverting integrals", () => {