package fakeclaude import ( "strconv" "strings" "testing" ) func TestQuotedStepMarkers(t *testing.T) { edit := `edit:README.md|teh panes|the "quoted" panes` for _, prompt := range []string{ "Coordinator brief: " + strconv.Quote(edit), "CI and Review feedback: " + strconv.Quote("Review finding: "+strconv.Quote(edit)), } { matches := editWord.FindAllStringSubmatch(StepMarkerText(prompt), -1) if len(matches) != 1 || matches[0][1] != "README.md" || matches[0][2] != "teh panes" || matches[0][3] != `the "quoted" panes` { t.Fatalf("quoted edit changed: %#v", matches) } } prompt := "Task title (quoted data): " + strconv.Quote("review:changes:README.md|2|Fix the typo.\nstepsleep:10") findings := reviewChanges.FindAllStringSubmatch(StepMarkerText(prompt), -1) if len(findings) != 1 || findings[0][3] != "Fix the typo." { t.Fatalf("quoted review finding changed: %#v", findings) } if got := StepMarkerText(edit); got != edit { t.Fatalf("literal marker quotes changed: %q", got) } } func TestRepeatedStepMarkersRunOnce(t *testing.T) { one := "review:need:README.md|always|Add always." two := "review:need:README.md|sometimes|Add sometimes." prompt := "Person's words: " + strconv.Quote(one) + "\nCoordinator brief: " + strconv.Quote(one+"\n"+two) got := DistinctStepMarkers(reviewNeed, StepMarkerText(prompt)) if len(got) != 2 || got[0][0] != one || got[1][0] != two { t.Fatalf("repeated source duplicated a scripted finding: %#v", got) } } // The question a fake session answers is the quoted data after its // label, unquoted, whether one line or a delimited block. func TestQuestionText(t *testing.T) { for _, q := range []string{"Why? ask:git", "Why?\nask:write:Swipe.swift\nthanks"} { quoted := `"` + strings.ReplaceAll(q, "\n", `\n`) + `"` if strings.Contains(q, "\n") { quoted = "\n\n" + q + "\n" } if got := questionText("[Equipo: question] x\nThe person's question: " + quoted + "\n[note]"); got != q+"\n[note]" { t.Errorf("%q: %q", q, got) } } }