Skip to content

Commit da375e2

Browse files
Steve Ramageclaude
andcommitted
test: cover the flag-off gating and non-enumerable completion cases
The completion bundle tested the flag-on behaviours but not two things worth guaranteeing: that grammar completion stays suppressed when the experimental engine is off (the gating contract), and that a non-enumerable next token (number/regex) offers nothing rather than crashing or suggesting junk. - GrammarValueCompletionTest.testFlagOffOffersNoGrammarCompletions: flag off, the AF_IN partial yields no AF_* names (the flag-on path's suggestions are absent). - NextTokenChoicesTest.testNonEnumerableNextTokenOffersNothing: an IntegerTerminal port grammar returns an empty choice set. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent e40c8ed commit da375e2

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/completion/GrammarValueCompletionTest.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,14 @@ class GrammarValueCompletionTest : AbstractUnitFileTest() {
3939
val results = basicCompletionResultStrings
4040
assertContainsElements(results, "AF_INET", "AF_INET6")
4141
}
42+
43+
@Test
44+
fun testFlagOffOffersNoGrammarCompletions() {
45+
// Gating guarantee: with the experimental engine OFF (the default), grammar completion must not
46+
// fire. A GrammarOptionValue has no legacy autocomplete options, so the same partial token that
47+
// the flag-on path completes to AF_INET/AF_INET6 yields nothing grammar-derived here.
48+
setupFileInEditor("file.service", "[Service]\nRestrictAddressFamilies=AF_IN${COMPLETION_POSITION}")
49+
50+
assertDoesntContain(basicCompletionResultStrings, "AF_INET", "AF_INET6")
51+
}
4252
}

src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/optionvalues/grammar/NextTokenChoicesTest.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,11 @@ class NextTokenChoicesTest {
3232
// Context awareness: after a family and a separator, another family is expected.
3333
assertTrue(addressFamilies.nextTokenChoices("AF_INET ").contains("AF_INET6"))
3434
}
35+
36+
@Test
37+
fun testNonEnumerableNextTokenOffersNothing() {
38+
// Numbers/regexes/whitespace/EOF aren't enumerable, so there is nothing concrete to suggest.
39+
val portGrammar = SequenceCombinator(IntegerTerminal(0, 65536), EOF())
40+
assertTrue(portGrammar.nextTokenChoices("").isEmpty())
41+
}
3542
}

0 commit comments

Comments
 (0)