From 5da96f8bd884fb15694b9a8c849a88723301ea7d Mon Sep 17 00:00:00 2001 From: dhgoal <153369624+dhgoal@users.noreply.github.com> Date: Sun, 5 Jul 2026 15:26:02 +0900 Subject: [PATCH] test(enrichment): cover extractFunctionParams multi-line and TS param shapes The two existing tests only fed single-line signatures. Adds the uncovered branches: a multi-line signature (extractParamSource's line walk), a rest parameter (`...` stripped), TS type annotations and default values stripped to names, and a `this` pseudo-parameter skipped. Test-only. --- .../test/doc-comment-drift.test.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/review-enrichment/test/doc-comment-drift.test.ts b/review-enrichment/test/doc-comment-drift.test.ts index 8c2c3893a9..8e7d091eea 100644 --- a/review-enrichment/test/doc-comment-drift.test.ts +++ b/review-enrichment/test/doc-comment-drift.test.ts @@ -45,6 +45,26 @@ test("extractFunctionParams: excludes a name declared more than once (overload/d assert.deepEqual([...map.get("other")], ["z"]); }); +test("extractFunctionParams: extracts params from a multi-line signature", () => { + const map = extractFunctionParams("function foo(\n a,\n b\n) {}\n"); + assert.deepEqual([...map.get("foo")], ["a", "b"]); +}); + +test("extractFunctionParams: a rest parameter keeps its name without the `...` marker", () => { + const map = extractFunctionParams("function bar(...rest) {}\n"); + assert.deepEqual([...map.get("bar")], ["rest"]); +}); + +test("extractFunctionParams: strips a TS type annotation and a default value from each name", () => { + const map = extractFunctionParams("function baz(a: string, b = 5): void {}\n"); + assert.deepEqual([...map.get("baz")], ["a", "b"]); +}); + +test("extractFunctionParams: skips a TS `this` pseudo-parameter, keeping the real args", () => { + const map = extractFunctionParams("function qux(this: T, a) {}\n"); + assert.deepEqual([...map.get("qux")], ["a"]); +}); + test("reconstructOldContent: bails (null) when the patch context does not match the head content", () => { // The context line ` other` doesn't exist in newContent → misaligned patch → fail closed. assert.equal(reconstructOldContent(`a\nb\n`, `@@ -1,2 +1,2 @@\n-x\n+a\n other`), null);