diff options
| author | Paul Buetow <paul@buetow.org> | 2025-09-06 10:25:36 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-09-06 10:25:36 +0300 |
| commit | 5be9532cfa630f4aacd8d879c3e4f5cc316da0fa (patch) | |
| tree | 0a901680fccd1e2703ffdbd9284ccff932be1d67 /internal/lsp/handlers_test.go | |
| parent | 70f1d0e78c57dfa5beae779b3d392b6e6fa44c14 (diff) | |
feat(lsp): configurable inline/chat triggers; switch inline markers to >text>/>>text>; update docs and example config; tests updated to new triggers and raise LSP coverage to >=85%; chore: remove semicolon legacy; chore(mage): auto-refresh coverage daily if docs/coverage.out is older than 24h
Diffstat (limited to 'internal/lsp/handlers_test.go')
| -rw-r--r-- | internal/lsp/handlers_test.go | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/internal/lsp/handlers_test.go b/internal/lsp/handlers_test.go index 5b84254..8fdd34f 100644 --- a/internal/lsp/handlers_test.go +++ b/internal/lsp/handlers_test.go @@ -14,8 +14,8 @@ func TestFindFirstInstructionInLine_NoMarker(t *testing.T) { } } -func TestFindFirstInstructionInLine_StrictSemicolon_Basic(t *testing.T) { - line := "prefix ;rename var; suffix" +func TestFindFirstInstructionInLine_StrictInline_Basic(t *testing.T) { + line := "prefix >rename var> suffix" instr, cleaned, ok := findFirstInstructionInLine(line) if !ok { t.Fatalf("expected ok=true") @@ -29,8 +29,8 @@ func TestFindFirstInstructionInLine_StrictSemicolon_Basic(t *testing.T) { } } -func TestFindFirstInstructionInLine_StrictSemicolon_TrailingSpacesTrimmed(t *testing.T) { - line := "code;fix; \t\t" +func TestFindFirstInstructionInLine_StrictInline_TrailingSpacesTrimmed(t *testing.T) { + line := "code>fix> \t\t" instr, cleaned, ok := findFirstInstructionInLine(line) if !ok { t.Fatalf("expected ok=true") @@ -43,17 +43,17 @@ func TestFindFirstInstructionInLine_StrictSemicolon_TrailingSpacesTrimmed(t *tes } } -func TestFindFirstInstructionInLine_Semicolon_InvalidPatterns(t *testing.T) { - cases := []string{ - "prefix ; bad; suffix", // space after first ';' ⇒ invalid - "prefix ;bad ; suffix", // space before closing ';' ⇒ invalid - "prefix ; ; suffix", // empty inner ⇒ invalid - } - for _, line := range cases { - if instr, _, ok := findFirstInstructionInLine(line); ok && instr != "" { - t.Fatalf("%q: expected no semicolon instruction; got instr=%q", line, instr) - } - } +func TestFindFirstInstructionInLine_Inline_InvalidPatterns(t *testing.T) { + cases := []string{ + "prefix > bad> suffix", // space after first '>' ⇒ invalid + "prefix >bad > suffix", // space before closing '>' ⇒ invalid + "prefix > > suffix", // empty inner ⇒ invalid + } + for _, line := range cases { + if instr, _, ok := findFirstInstructionInLine(line); ok && instr != "" { + t.Fatalf("%q: expected no inline instruction; got instr=%q", line, instr) + } + } } func TestFindFirstInstructionInLine_CBlockComment(t *testing.T) { @@ -126,22 +126,22 @@ func TestFindFirstInstructionInLine_DoubleDash(t *testing.T) { } } -func TestFindFirstInstructionInLine_EarliestWins_CommentOverSemicolon(t *testing.T) { - line := "aa // comment ;not this; trailing" +func TestFindFirstInstructionInLine_EarliestWins_CommentOverInline(t *testing.T) { + line := "aa // comment >not this> trailing" instr, cleaned, ok := findFirstInstructionInLine(line) if !ok { t.Fatalf("expected ok=true") } - if instr != "comment ;not this; trailing" { - t.Fatalf("instr got %q want %q", instr, "comment ;not this; trailing") - } + if instr != "comment >not this> trailing" { + t.Fatalf("instr got %q want %q", instr, "comment >not this> trailing") + } if cleaned != "aa" { t.Fatalf("cleaned got %q want %q", cleaned, "aa") } } -func TestFindFirstInstructionInLine_EarliestWins_SemicolonOverComment(t *testing.T) { - line := "aa ;short; // comment" +func TestFindFirstInstructionInLine_EarliestWins_InlineOverComment(t *testing.T) { + line := "aa >short> // comment" instr, cleaned, ok := findFirstInstructionInLine(line) if !ok { t.Fatalf("expected ok=true") @@ -155,21 +155,21 @@ func TestFindFirstInstructionInLine_EarliestWins_SemicolonOverComment(t *testing } } -func TestFindStrictSemicolonTag_Various(t *testing.T) { - // basic - if text, l, r, ok := findStrictSemicolonTag("pre;do it;post"); !ok || text != "do it" || l != 3 || r != 10 { - t.Fatalf("unexpected: ok=%v text=%q l=%d r=%d", ok, text, l, r) - } - // at start - if text, l, r, ok := findStrictSemicolonTag(";x;"); !ok || text != "x" || l != 0 || r != 3 { - t.Fatalf("unexpected at start: ok=%v text=%q l=%d r=%d", ok, text, l, r) - } - // double opening ';' should still allow a tag starting at the second ';' - if text, _, _, ok := findStrictSemicolonTag("prefix ;;bad; suffix"); !ok || text != "bad" { - t.Fatalf("unexpected double-open handling: ok=%v text=%q", ok, text) - } - // inner spaces directly after first ';' or before last ';' invalidate the tag - if _, _, _, ok := findStrictSemicolonTag("a; inner ;b"); ok { - t.Fatalf("expected invalid strict tag due to spaces at boundaries") - } +func TestFindStrictInlineTag_Various(t *testing.T) { + // basic + if text, l, r, ok := findStrictInlineTag("pre>do it>post"); !ok || text != "do it" || l != 3 || r != 10 { + t.Fatalf("unexpected: ok=%v text=%q l=%d r=%d", ok, text, l, r) + } + // at start + if text, l, r, ok := findStrictInlineTag(">x>"); !ok || text != "x" || l != 0 || r != 3 { + t.Fatalf("unexpected at start: ok=%v text=%q l=%d r=%d", ok, text, l, r) + } + // double opening '>>' should still allow a tag starting at the second '>' + if text, _, _, ok := findStrictInlineTag("prefix >>bad> suffix"); !ok || text != "bad" { + t.Fatalf("unexpected double-open handling: ok=%v text=%q", ok, text) + } + // inner spaces directly after first '>' or before last '>' invalidate the tag + if _, _, _, ok := findStrictInlineTag("a> inner >b"); ok { + t.Fatalf("expected invalid strict tag due to spaces at boundaries") + } } |
