From 23d6b1a39c366c36ae7c9a1d8950916eed9723da Mon Sep 17 00:00:00 2001 From: thejesh Date: Sat, 13 Jun 2026 05:36:23 -0700 Subject: [PATCH] =?UTF-8?q?test(core):=20DartExtractor=20=E2=80=94=20visib?= =?UTF-8?q?ility=20rule=20(underscore=20prefix)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- .../__tests__/dart-extractor.test.ts | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/understand-anything-plugin/packages/core/src/plugins/extractors/__tests__/dart-extractor.test.ts b/understand-anything-plugin/packages/core/src/plugins/extractors/__tests__/dart-extractor.test.ts index 9954743..b6c5401 100644 --- a/understand-anything-plugin/packages/core/src/plugins/extractors/__tests__/dart-extractor.test.ts +++ b/understand-anything-plugin/packages/core/src/plugins/extractors/__tests__/dart-extractor.test.ts @@ -327,4 +327,46 @@ describe("DartExtractor", () => { parser.delete(); }); }); + + describe("extractStructure - visibility", () => { + it("does NOT export a top-level declaration whose name starts with _", () => { + const { tree, parser, root } = parse(`int _helper() => 1; +class _PrivateImpl {} +`); + const result = extractor.extractStructure(root); + + const names = result.exports.map((e) => e.name); + expect(names).not.toContain("_helper"); + expect(names).not.toContain("_PrivateImpl"); + tree.delete(); + parser.delete(); + }); + + it("DOES export a top-level declaration without an underscore prefix", () => { + const { tree, parser, root } = parse(`int helper() => 1; +class Public {} +`); + const result = extractor.extractStructure(root); + + const names = result.exports.map((e) => e.name); + expect(names).toEqual(expect.arrayContaining(["helper", "Public"])); + tree.delete(); + parser.delete(); + }); + + it("does NOT export class members whose names start with _", () => { + const { tree, parser, root } = parse(`class Counter { + void _helper() {} + void publicMethod() {} +} +`); + const result = extractor.extractStructure(root); + + const names = result.exports.map((e) => e.name); + expect(names).toContain("publicMethod"); + expect(names).not.toContain("_helper"); + tree.delete(); + parser.delete(); + }); + }); });