diff options
| author | Paul Buetow <paul@buetow.org> | 2025-09-04 14:24:36 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-09-04 14:24:36 +0300 |
| commit | d68e5b3b188585fe234d0ce295ec7f054c8bad5f (patch) | |
| tree | 974e067d9894f0da38513acdc27b56729b0f06e4 /internal/lsp/completion_messages_test.go | |
| parent | 3c322b7046669a77c276ce05469bfc2db0b446b2 (diff) | |
tests(lsp): push coverage over 80%\n- Add init/trigger, chat history, document handler, transport readMessage, and rewrite resolve tests\n- Cover deferShowDocument and shutdown reply\n- Now ~81.2% coverage for internal/lsp
Diffstat (limited to 'internal/lsp/completion_messages_test.go')
| -rw-r--r-- | internal/lsp/completion_messages_test.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/internal/lsp/completion_messages_test.go b/internal/lsp/completion_messages_test.go index eb16ccc..e9ec3e5 100644 --- a/internal/lsp/completion_messages_test.go +++ b/internal/lsp/completion_messages_test.go @@ -44,6 +44,22 @@ func TestBuildDocString_Contents(t *testing.T) { } } +func TestBuildPrompts_InParams(t *testing.T) { + p := CompletionParams{TextDocument: TextDocumentIdentifier{URI: "file:///x"}, Position: Position{Line:0, Character:5}} + sys, user := buildPrompts(true, p, "a", "func f(x)", "c", "func f(x)") + if !contains(sys, "function signatures") || !contains(user, "parameter list") { t.Fatalf("unexpected in-params prompts") } +} + +func TestPostProcessCompletion_CodeFencesAndDuplicates(t *testing.T) { + s := newTestServer() + // code fences + cleaned := s.postProcessCompletion("```go\nname := value\n```", "", "") + if cleaned == "" { t.Fatalf("expected non-empty after fence removal") } + // duplicate assignment prefix strip + cleaned2 := s.postProcessCompletion("name := other", "name := ", "name := ") + if cleaned2 == "" || cleaned2 == "name := other" { t.Fatalf("expected duplicate assignment prefix stripped: %q", cleaned2) } +} + func contains(s, sub string) bool { return len(s) >= len(sub) && (s == sub || (len(sub) > 0 && (stringIndex(s, sub) >= 0))) } func stringIndex(s, sub string) int { return len([]rune(s[:])) - len([]rune(s[:])) + (func() int { return intIndex(s, sub) })() } func intIndex(s, sub string) int { return Index(s, sub) } @@ -55,4 +71,3 @@ func Index(s, sub string) int { } return -1 } - |
