package tools import ( "strings" "testing" "mm/internal/fileedit" ) // TestClip: a display line is scanned, not read. A hundred columns, one line — // the same rule as the command recap, and the same reason: a multi-line old // text printed whole would be longer than the diff it announces. func TestClip(t *testing.T) { if got := clip("📝 edit_file: a.go\n (2 edits)"); got != "📝 edit_file: a.go (2 edits)" { t.Errorf("clip folded to %q", got) } long := clip("📄 read_file: " + strings.Repeat("x", 200)) if r := []rune(long); len(r) != maxDisplayWidth || r[len(r)-1] != '…' { t.Errorf("clip = %d runes ending %q, want %d ending …", len(r), string(r[len(r)-1]), maxDisplayWidth) } } // TestEditKeyTellsRetriesApart: the loop detector must see a corrected edit as // a NEW action. Keying on the path alone made "same path, different old text" // look like a repeat, and the detector fired on a model that was fixing itself. func TestEditKeyTellsRetriesApart(t *testing.T) { a := editKey(editFileInput{Path: "f.go", Edits: []fileedit.Edit{{Old: "x", New: "y"}}}) b := editKey(editFileInput{Path: "f.go", Edits: []fileedit.Edit{{Old: "x2", New: "y"}}}) same := editKey(editFileInput{Path: "f.go", Edits: []fileedit.Edit{{Old: "x", New: "y"}}}) if a == b || a != same { t.Errorf("editKey: a=%q b=%q same=%q", a, b, same) } }