MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestEditFileWhitespaceNearMissHint

Function TestEditFileWhitespaceNearMissHint

internal/tools/edit_test.go:65–79  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
67func 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)

Callers

nothing calls this directly

Calls 1

EditFileFunction · 0.85

Tested by

no test coverage detected