testFunctionNamesAreHashedValueNamesAreNot

tcmts.core.test.hash.testFunctionNamesAreHashedValueNamesAreNot · #e63an7gl · term

A value's own name is not part of its hash, a function's is (it's observable as .name).

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

export const testFunctionNamesAreHashedValueNamesAreNot = () => {
  assert.equal(hashes(`const xs = [1, 2]`).xs, hashes(`const ys = [1, 2]`).ys);
  assert.notEqual(hashes(`const inc = (x: number) => x + 1`).inc, hashes(`const plusOne = (x: number) => x + 1`).plusOne);
  assert.notEqual(hashes(`class A extends Error {}`).A, hashes(`class B extends Error {}`).B);
}

uses