(t *testing.T)
| 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) |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | // TestEditFileWhitespaceFuzzyApplyMultiline: an indent-shifted multi-line |
| 87 | // block applies, preserving the lines around it byte-exactly. |
| 88 | func TestEditFileWhitespaceFuzzyApplyMultiline(t *testing.T) { |
| 89 | dir := t.TempDir() |
| 90 | path := filepath.Join(dir, "f.py") |
| 91 | const orig = "def f():\n if x:\n do(1)\n do(2)\n return\n" |
| 92 | if err := os.WriteFile(path, []byte(orig), 0o644); err != nil { |
| 93 | t.Fatal(err) |
| 94 | } |
| 95 | // Model retyped the block one indent level off. |
| 96 | s := EditFile(path, "if x:\n do(1)\n do(2)", " if y:\n do(1)\n do(2)") |
| 97 | if !strings.Contains(s, "edited") { |
| 98 | t.Fatalf("want fuzzy apply, got %q", s) |
nothing calls this directly
no test coverage detected