All files / binary101/tests/unit/analyzers/symbol-demangle name-decoder.test.ts

100% Statements 27/27
100% Branches 2/2
100% Functions 0/0
100% Lines 27/27

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 281x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import assert from "node:assert/strict";
import { test } from "node:test";
import { createSymbolNameDecoder } from "../../../../analyzers/symbol-demangle/name-decoder.js";
 
void test("shared symbol routing keeps grammar identities and data evidence separate", async () => {
  const decode = createSymbolNameDecoder(assert.fail);
 
  assert.deepEqual(await decode("_Z1fi"),
    { text: "f(int)", language: "Itanium C++", symbolKind: undefined });
  assert.deepEqual(await decode("_Z5value"),
    { text: "value", language: "Itanium C++", symbolKind: "ItaniumData" });
  assert.deepEqual(await decode("_RC1a"),
    { text: "a", language: "Rust v0", symbolKind: undefined });
  assert.deepEqual(await decode("_D3foo3barf"),
    { text: "float foo.bar", language: "D", symbolKind: "DlangData" });
  assert.equal(await decode("_Zbroken"), null);
  assert.equal(await decode("_Rbroken"), null);
  assert.equal(await decode("_Dbroken"), null);
});
 
void test("ordinary names do not initialize any WASM", async () => {
  const decode = createSymbolNameDecoder(assert.fail, assert.fail, assert.fail, assert.fail);
 
  assert.equal(await decode(undefined), null);
  assert.equal(await decode(""), null);
  assert.equal(await decode("main"), null);
});