testWatchExpressionsAreKeptApart

tcmts.core.test.hash.testWatchExpressionsAreKeptApart · #v22ymr3k · term

Watch expressions are analyzed but kept apart from definitions.

import { analyze } from "#codebase/tcmts/core/test/hash";
import assert from "node:assert/strict";

export const testWatchExpressionsAreKeptApart = () => {
  const a = analyze(`const sq = (x: number) => x * x\nsq(4)`);
  assert.equal(a.defs.length, 1);
  assert.equal(a.watches.length, 1);
  assert.equal(a.watches[0]!.expression, "sq(4)");
  assert.deepEqual(a.watches[0]!.deps.map((d) => d.ref), [`#${a.defs[0]!.hash}`]);
}

uses