summaryrefslogtreecommitdiff
path: root/internal/lsp/handlers_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-09-06 10:56:27 +0300
committerPaul Buetow <paul@buetow.org>2025-09-06 10:56:27 +0300
commit320de746f7a2985b60c8564a0e65bdf231e840b7 (patch)
treee70bcf50813dba411afa2934e774383124bbc99e /internal/lsp/handlers_test.go
parent06247527d5170f329b454b42f59a3e4434ab1f4b (diff)
use gofumpt
Diffstat (limited to 'internal/lsp/handlers_test.go')
-rw-r--r--internal/lsp/handlers_test.go66
1 files changed, 33 insertions, 33 deletions
diff --git a/internal/lsp/handlers_test.go b/internal/lsp/handlers_test.go
index 8fdd34f..a171143 100644
--- a/internal/lsp/handlers_test.go
+++ b/internal/lsp/handlers_test.go
@@ -15,7 +15,7 @@ func TestFindFirstInstructionInLine_NoMarker(t *testing.T) {
}
func TestFindFirstInstructionInLine_StrictInline_Basic(t *testing.T) {
- line := "prefix >rename var> suffix"
+ line := "prefix >rename var> suffix"
instr, cleaned, ok := findFirstInstructionInLine(line)
if !ok {
t.Fatalf("expected ok=true")
@@ -30,7 +30,7 @@ func TestFindFirstInstructionInLine_StrictInline_Basic(t *testing.T) {
}
func TestFindFirstInstructionInLine_StrictInline_TrailingSpacesTrimmed(t *testing.T) {
- line := "code>fix> \t\t"
+ line := "code>fix> \t\t"
instr, cleaned, ok := findFirstInstructionInLine(line)
if !ok {
t.Fatalf("expected ok=true")
@@ -44,16 +44,16 @@ func TestFindFirstInstructionInLine_StrictInline_TrailingSpacesTrimmed(t *testin
}
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)
- }
- }
+ 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) {
@@ -127,21 +127,21 @@ func TestFindFirstInstructionInLine_DoubleDash(t *testing.T) {
}
func TestFindFirstInstructionInLine_EarliestWins_CommentOverInline(t *testing.T) {
- line := "aa // comment >not this> trailing"
+ 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_InlineOverComment(t *testing.T) {
- line := "aa >short> // comment"
+ line := "aa >short> // comment"
instr, cleaned, ok := findFirstInstructionInLine(line)
if !ok {
t.Fatalf("expected ok=true")
@@ -156,20 +156,20 @@ func TestFindFirstInstructionInLine_EarliestWins_InlineOverComment(t *testing.T)
}
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")
- }
+ // 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")
+ }
}