testLocalRenamesAndFormattingKeepTheHash

tcmts.core.test.hash.testLocalRenamesAndFormattingKeepTheHash · #eyu2oaqi · term

Local renames, formatting, comments and export do not change the hash.

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

export const testLocalRenamesAndFormattingKeepTheHash = () => {
  const a = hashes(`export function sum(xs: number[]): number { let total = 0; for (const x of xs) total += x; return total }`);
  const b = hashes(`
    /** docs are metadata */
    function sum(values: number[]): number {
      let acc = 0 // running total
      for (const v of values) acc += v
      return acc
    }`);
  assert.equal(a.sum, b.sum);
}

uses