Files
rea/src/domain/symbolAnalysis.test.ts
T
morluto 392f1f3107 refactor: consolidate boundary semantics and prune redundant tests
Share parser modes and collision-free composite keys, enforce architecture guards, and consolidate redundant unit assertions into filesystem, CLI, MCP, and producer-backed workflows. Preserve concurrent upstream boundary fixes and exclude legacy Objective-C class-name bookkeeping labels.

Validation: source/composition suites (3358 passing), focused canonical digest and MCP checks, typecheck/lint, Knip, formatting, architecture guards, and real Foundation archive and Apple legacy simulator CLI/MCP verification. No real Hopper, Ghidra, or IDA verification claim.
2026-10-10 05:56:01 +08:00

98 lines
2.8 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { categorizeSwiftTypes } from "./symbolAnalysis.js";
describe("modern Swift category evidence", () => {
it.each([
["$s4main7ServiceCMa", "classes"],
["$s4main5StateOMa", "enums"],
["$s4main7ScoringPMp", "protocols"],
["$s4main5OuterV5InnerCMa", "classes"],
["$s4main4PairV5otherE7doubledSiyF", "extensions"],
["$S4main4PairVMa", "structs"],
["_T04main4PairVMa", "structs"],
["$s4_TtX4PairVMa", "structs"],
] as const)("decodes nominal contexts for %s", (name, category) => {
expect(
categorizeSwiftTypes([{ address: "0x1", name }], { category }),
).toMatchObject({
total: 1,
categories: { [category]: { count: 1 } },
unclassified: [],
});
});
it("retains unresolved Swift observations under category filters", () => {
const names = [
"$s4main13swiftIndirectySiAA7Scoring_p_SitF",
"$sSi4mainE7doubledSiyF",
"$s9999999999999999999999BadVMa",
"$s4main04PairVMa",
];
const result = categorizeSwiftTypes(
names.map((name, index) => ({ address: String(index), name })),
{ category: "structs" },
);
expect(result).toMatchObject({
total: 0,
unclassified: names.map((name) => ({
name,
mangled_names: [name],
reason: "category_not_decoded",
})),
limitations: expect.arrayContaining([
expect.stringContaining("could not be established"),
]),
});
expect(
categorizeSwiftTypes([{ address: "0x1", name: names[0] ?? "" }], {
category: "structs",
pattern: "missing",
}),
).toMatchObject({ total: 0, unclassified: [] });
});
it("deduplicates display names after selecting a category", () => {
expect(
categorizeSwiftTypes(
[
{ address: "0x1", name: "shared" },
{ address: "0x2", name: "shared" },
],
{ category: "structs" },
[
{ address: "0x1", name: "$s4main7ServiceCMa" },
{ address: "0x2", name: "$s4main4PairVMa" },
],
),
).toMatchObject({
total: 1,
categories: { structs: { items: [{ address: "0x2", name: "shared" }] } },
});
});
});
describe("Swift alias ambiguity", () => {
it("reports conflicting aliases rather than choosing a category", () => {
expect(
categorizeSwiftTypes(
[{ address: "0x1", name: "shared" }],
{ category: "structs" },
[
{ address: "0x1", name: "$s4main4PairVMa" },
{ address: "0x1", name: "$s4main7ServiceCMa" },
],
),
).toMatchObject({
total: 0,
unclassified: [
{
name: "shared",
reason: "conflicting_categories",
mangled_names: ["$s4main4PairVMa", "$s4main7ServiceCMa"],
},
],
});
});
});