Files
rea/src/native/parsers/demangle.test.ts
T
Iwakurakaoru0822andClaude Opus 5.5 6c88094da4 fix(native): pass Swift symbols to swift-demangle as operands
`swift-demangle` parsed a symbol beginning with `-` as an option, so
`-help` replaced the results with usage text and the call failed as
unreadable output. A symbol containing a line feed split into extra
output records, and the CRLF-tolerant parser stripped a carriage return
that belonged to the final symbol.

Pass the symbols after `--`, split records on the LF the demangler
emits, and reject multi-line symbols in the shared CLI/MCP input schema.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 22:40:19 -07:00

37 lines
993 B
TypeScript

import { expect, it } from "vitest";
import { parseDemangledSymbols } from "./demangle.js";
it.each(["ordinary name ", "ordinary\t", " "])(
"preserves unchanged final symbol text: %j",
(input) => {
expect(parseDemangledSymbols([input], `${input}\n`)).toEqual([
{ input, output: input, status: "unchanged" },
]);
},
);
it.each(["carriage\r", "\r", "mid\rdle"])(
"keeps carriage returns that belong to the symbol: %j",
(input) => {
expect(parseDemangledSymbols([input], `${input}\n`)).toEqual([
{ input, output: input, status: "unchanged" },
]);
},
);
it("removes only the line terminator and preserves mixed output ordering", () => {
expect(
parseDemangledSymbols(
["$s4main5helloyyF", "plain "],
"main.hello() -> ()\nplain \n",
),
).toEqual([
{
input: "$s4main5helloyyF",
output: "main.hello() -> ()",
status: "demangled",
},
{ input: "plain ", output: "plain ", status: "unchanged" },
]);
});