TestEditFileWhitespaceNearMissHint: a miss whose only difference is indentation gets the diagnostic hint, and the file is left untouched (the hint is detection only, never a fuzzy apply).
(t *testing.T)
| 63 | // indentation, matching whole lines exactly once, is APPLIED (the retyped- |
| 64 | // indentation failure is the canonical weak-model edit_file miss; a unique |
| 65 | // whole-line match preserves the exactly-once guarantee). new_string goes in |
| 66 | // as given; every surrounding byte survives exactly. |
| 67 | func TestEditFileWhitespaceFuzzyApply(t *testing.T) { |
| 68 | dir := t.TempDir() |
| 69 | path := filepath.Join(dir, "f.go") |
| 70 | const orig = "func main() {\n\treturn 1\n}\n" // file indents with a tab |
| 71 | if err := os.WriteFile(path, []byte(orig), 0o644); err != nil { |
| 72 | t.Fatal(err) |
| 73 | } |
| 74 | s := EditFile(path, " return 1", " return 2") // model supplied spaces |
| 75 | if !strings.Contains(s, "edited") || !strings.Contains(s, "whitespace") { |
| 76 | t.Fatalf("want fuzzy apply, got %q", s) |
| 77 | } |
| 78 | if !strings.Contains(s, "lines 2-2") { |
| 79 | t.Fatalf("result must name the matched lines, got %q", s) |
| 80 | } |
| 81 | if got, _ := os.ReadFile(path); string(got) != "func main() {\n return 2\n}\n" { |
| 82 | t.Fatalf("bad fuzzy apply result: %q", got) |
nothing calls this directly
no test coverage detected