Rewrite the code comments for consistent tone and accuracy

Comments only: the tokens of every Go file are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-01 19:08:00 +00:00
co-authored by Claude Sonnet 5.5
parent 41f752e1c1
commit 158661eefe
27 changed files with 716 additions and 437 deletions
+14
View File
@@ -8,6 +8,8 @@ import (
"testing"
)
// mustParse parses text, reading its includes from the map m of paths to
// contents, and fails the test if it can't.
func mustParse(t *testing.T, text string, m map[string]string) *Document {
t.Helper()
if m == nil {
@@ -28,6 +30,8 @@ func set(t *testing.T, h *Header, name, value string) {
}
}
// TestSetKeepsLayout checks that Set changes an opcode in place, adds a new
// one laid out like the last, and that what is written reads back.
func TestSetKeepsLayout(t *testing.T) {
doc := mustParse(t, "// piano\n<group>\n\tvolume=-1 // quiet\n\tpan=5\n<region> sample=a.wav\n", nil)
hs := doc.Headers()
@@ -54,6 +58,8 @@ func TestSetKeepsLayout(t *testing.T) {
}
}
// TestDelete checks that Delete removes every copy of an opcode, and does
// nothing for one that isn't there.
func TestDelete(t *testing.T) {
doc := mustParse(t, "<region>\n sample=a.wav\n lokey=1\n hikey=2\n lokey=3\n", nil)
h := doc.Headers()[0]
@@ -64,6 +70,8 @@ func TestDelete(t *testing.T) {
}
}
// TestAddHeader checks that AddHeader puts a header after another header's
// opcodes or at the end of the file, and that Set fills it.
func TestAddHeader(t *testing.T) {
doc := mustParse(t, "<group> volume=1\n<region> sample=a.wav", nil)
hs := doc.Headers()
@@ -127,6 +135,8 @@ func TestEditIncluded(t *testing.T) {
}
}
// TestSetKeepsComments checks where Set puts a new opcode among the comments,
// directives and text that follow the last one.
func TestSetKeepsComments(t *testing.T) {
for _, tc := range []struct{ text, want string }{
{"<region>\n sample=a.wav // the sample\n", "<region>\n sample=a.wav // the sample\n lokey=1\n"},
@@ -144,6 +154,8 @@ func TestSetKeepsComments(t *testing.T) {
}
}
// TestSetRefusesBadValues checks that Set, SetDefine and AddHeader refuse
// what can't be written, and change nothing.
func TestSetRefusesBadValues(t *testing.T) {
text := "<region> sample=a.wav\n"
for _, value := range []string{"1\n<region>", "1 // c", "1 /* c", "1 hikey=2", "<group>", "1\r\n2"} {
@@ -177,6 +189,8 @@ func TestSetRefusesBadValues(t *testing.T) {
}
}
// TestDeleteKeepsLines checks that Delete keeps the line breaks and comments
// that aren't the opcode's.
func TestDeleteKeepsLines(t *testing.T) {
for _, tc := range []struct{ text, want string }{
{"<region>\n a=1\n b=2\n a=3 // x\n", "<region>\n b=2\n // x\n"},