Skip to content

Commit 44e4ee3

Browse files
committed
test(flavor): name the flavorScanSlack magic number in TestFlavorCount_CoversEveryValidFlavor
Round-2 code review nitpicked the bare "+10" in the flavor-scan bound as an undocumented magic number. Name it flavorScanSlack with a comment explaining why any small headroom (not a specific count) suffices. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LJTrn4DizYTMdYj4tbswVJ
1 parent fef5e5b commit 44e4ee3

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

pkg/markdown/flavor/feature_test.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,21 @@ func TestFeatureCount_MatchesAllFeatures(t *testing.T) {
117117
assert.Equal(t, len(AllFeatures()), int(featureCount))
118118
}
119119

120+
// flavorScanSlack is how far past the last declared Flavor constant
121+
// TestFlavorCount_CoversEveryValidFlavor scans. New Flavor constants
122+
// are added one (or a small handful) at a time, so a slack of 10
123+
// comfortably catches the next one added without a matching
124+
// flavorCount bump; it is not tied to any specific count.
125+
const flavorScanSlack = 10
126+
120127
// TestFlavorCount_CoversEveryValidFlavor pins flavorCount against
121128
// every Flavor value Flavor.String (and so IsValid) recognises — the
122-
// Flavor equivalent of TestFeatureCount_MatchesAllFeatures. Scans a
123-
// generous range past the last declared constant so a newly added
124-
// Flavor with no matching flavorCount bump fails this test instead of
125-
// silently losing its row in the support table.
129+
// Flavor equivalent of TestFeatureCount_MatchesAllFeatures. Scans past
130+
// the last declared constant so a newly added Flavor with no matching
131+
// flavorCount bump fails this test instead of silently losing its row
132+
// in the support table.
126133
func TestFlavorCount_CoversEveryValidFlavor(t *testing.T) {
127-
for f := Flavor(0); f <= FlavorMyST+10; f++ {
134+
for f := Flavor(0); f <= FlavorMyST+flavorScanSlack; f++ {
128135
if f.IsValid() {
129136
assert.Lessf(t, int(f), flavorCount,
130137
"flavor %s (%d) is valid but falls outside the support table bounds", f, int(f))

0 commit comments

Comments
 (0)