feat(base-formula): add date and coercion functions, wire registry

This commit is contained in:
Philipinho
2026-04-24 00:03:40 +01:00
parent 0174fada5f
commit ea0dc2b56b
5 changed files with 67 additions and 6 deletions
@@ -45,8 +45,7 @@ describe("evaluate", () => {
});
});
// TODO: unskip after Task 15 wires the function registry with round/concat.
describe.skip("evaluate with registered functions", () => {
describe("evaluate with registered functions", () => {
it("invokes registered functions", () => {
expect(run('round(1.6)', {})).toBe(2);
expect(run('concat("a", "b", "c")', {})).toBe("abc");
@@ -1,4 +1,3 @@
// TODO: unskip after Task 15 lands date functions and populates the registry.
import { parseRaw, resolve, typecheck, registry } from "@docmost/base-formula/server";
import type { FormulaAST } from "@docmost/base-formula/server";
@@ -9,7 +8,7 @@ const mk = (src: string, propTypes: Record<string, "number" | "string" | "boolea
return { ast: resolved.ast, typeMap };
};
describe.skip("typecheck", () => {
describe("typecheck", () => {
it("infers number for arithmetic", () => {
const { ast, typeMap } = mk('prop("Price") * 2', { Price: "number" });
expect(typecheck(ast, typeMap, registry).resultType).toBe("number");