| id | 2606231013 |
|---|---|
| title | Add dedicated unit tests for inline_scan.go helpers |
| status | ✅ |
| model | sonnet |
| summary | internal/lint/inline_scan.go has 13 unexported helper functions exercised only via the higher-level TestScanInlineRun_* suite. Add a named unit test for each so the audit policy (every function has a TestFoo / TestReceiver_Foo by name) is satisfied. |
internal/lint/inline_scan.go (plan 2606141904 /
PR #632) has 13 unexported helper functions. They
are tested only through the 55 higher-level
TestScanInlineRun_* behavioral tests. The audit
policy requires a named test for every function.
This plan adds those tests.
The audit policy (tests.md) requires a named
test for every production function. Use TestFoo
for a package function Foo. Use
TestReceiver_Foo for a method on Receiver.
Functions in inline_scan.go with no dedicated
test as of commit 1599c9f:
scanRunEligiblemergeAppendTextfinalAppendTextscanParagraphInlinesapplyCodeSpanapplyAutolinkapplyBangapplyLinkscanCodeSpan(covered byTestScanInlineRun_*but not byTestScanCodeSpan)scanLinkOrImagescanLinkParensskipSpacesAtisSpaceOrNewlineByte
- For each function above, add at least one
test function named
TestFunctionName(orTestFunctionName_Variantfor multiple cases) tointernal/lint/inline_scan_test.go. - Each test must be a standalone unit test:
drive the helper directly, not via
scanInlineRun. - Keep each test function short (≤ 15 lines). Use table-driven style only when three or more cases differ in one dimension.
isSpaceOrNewlineBytehas two boolean branches (c == ' 'andc == '\n'), so the trivial- accessor exemption does not apply. AddTestIsSpaceOrNewlineByteinstead.- Run
go test ./internal/lint/... -run TestScanto confirm all pass. - Run
go vet ./internal/lint/...andgo tool -modfile=tools/go.mod golangci-lint run ./internal/lint/...— both must pass.
-
internal/lint/inline_scan_test.gocontainsTestScanRunEligible,TestMergeAppendText,TestFinalAppendText,TestScanParagraphInlines,TestApplyCodeSpan,TestApplyAutolink,TestApplyBang,TestApplyLink,TestScanCodeSpan,TestScanLinkOrImage,TestScanLinkParens,TestSkipSpacesAt,TestIsSpaceOrNewlineByte(13 new test functions). -
isSpaceOrNewlineBytehas a dedicated test (TestIsSpaceOrNewlineByte); the predicate has two branches so the trivial-accessor exemption does not apply. -
go test ./internal/lint/...is green. - No new golangci-lint warnings.