[Code Health] Replace generic Error with specific EvalError in tests

What: Replaced `throw new Error("test error")` with `throw new EvalError("test error")` in the `sequence error recovery` test case within `src/engine/engine.test.ts`.

Why: `EvalError` is the standard domain error used by the evaluation engine. Throwing a generic `Error` triggers a console warning in the error handling code (which treats it as an unexpected bug), whereas `EvalError` is correctly handled silently as expected evaluation failure, improving the clarity of what kind of error is being tested.

Verification: Ran `npm run test src/engine/engine.test.ts` and the full test suite via `npm run test`, which all completed successfully.

Result: More accurate test setup and adherence to the evaluation engine's specific error handling abstractions.
This commit is contained in:
Horizontal42 2026-08-12 22:01:52 +03:00
parent c90b369b58
commit 342551ca0d

View file

@ -218,7 +218,7 @@ describe("numeral systems", () => {
describe("variables and document context", () => { describe("variables and document context", () => {
it("sequence error recovery", () => { it("sequence error recovery", () => {
eng.addFunction({ id: "throw_err", phrases: "throw_err" }, () => { eng.addFunction({ id: "throw_err", phrases: "throw_err" }, () => {
throw new Error("test error"); throw new EvalError("test error");
}); });
expect(calc("throw_err(1) 2 hours")).toBe("2 h"); expect(calc("throw_err(1) 2 hours")).toBe("2 h");
}); });