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:
+17
-4
@@ -10,8 +10,8 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// TestDefinesCannotOutgrowLimit checks that variables that hold variables
|
||||
// stop at the byte limit, as a few lines of them would otherwise make gigabytes.
|
||||
// TestDefinesCannotOutgrowLimit checks that variables that hold variables stop
|
||||
// at the byte limit, as a few lines of them would otherwise make gigabytes.
|
||||
func TestDefinesCannotOutgrowLimit(t *testing.T) {
|
||||
var b strings.Builder
|
||||
// The names are as long as each other, so none is the start of another.
|
||||
@@ -53,6 +53,9 @@ func (r *countingReader) Read(p []byte) (int, error) {
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
// TestParseReadsNoMoreThanLimit checks that Parse refuses a reader that is
|
||||
// past the limit without reading all of it, and accepts text that is at the
|
||||
// limit.
|
||||
func TestParseReadsNoMoreThanLimit(t *testing.T) {
|
||||
var r countingReader
|
||||
_, err := Parse(&r, WithLimits(Limits{MaxBytes: 1000}))
|
||||
@@ -67,6 +70,7 @@ func TestParseReadsNoMoreThanLimit(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestLimitsDepth checks that WithLimits sets how deeply includes may nest.
|
||||
func TestLimitsDepth(t *testing.T) {
|
||||
m := map[string]string{"a": "#include \"b\"", "b": "#include \"c\"", "c": "<region>"}
|
||||
_, err := Parse(strings.NewReader("#include \"a\""), WithResolver(files(m)), WithLimits(Limits{MaxDepth: 2}))
|
||||
@@ -75,8 +79,9 @@ func TestLimitsDepth(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestLexScales checks that text a few megabytes long takes a moment to
|
||||
// read in each shape that was once quadratic.
|
||||
// TestLexScales checks that text a few megabytes long is read in a moment, in
|
||||
// each shape of text whose reading time could grow with the square of its
|
||||
// length.
|
||||
func TestLexScales(t *testing.T) {
|
||||
for name, text := range map[string]string{
|
||||
"opcodes on one line": strings.Repeat("a=1 ", 1<<19),
|
||||
@@ -100,6 +105,8 @@ func TestLexScales(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestByteOrderMark checks that a byte order mark is read as space, so that a
|
||||
// directive after it is still one.
|
||||
func TestByteOrderMark(t *testing.T) {
|
||||
text := "\ufeff#define $A 1\n<region> sample=$A.wav\n"
|
||||
doc := mustParse(t, text, nil)
|
||||
@@ -118,6 +125,8 @@ func TestByteOrderMark(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestWriteFilesStaysInFolder checks that WriteFiles refuses an include that
|
||||
// leaves the folder, and writes nothing.
|
||||
func TestWriteFilesStaysInFolder(t *testing.T) {
|
||||
anyFile := func(string) ([]byte, error) { return []byte("<region> sample=a.wav\n"), nil }
|
||||
for _, include := range []string{"../evil.sfz", "a/../../evil.sfz", "/evil.sfz", "..\\evil.sfz"} {
|
||||
@@ -133,6 +142,8 @@ func TestWriteFilesStaysInFolder(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestValidateOutsideFolder checks that Validate reports includes and samples
|
||||
// that leave the folder.
|
||||
func TestValidateOutsideFolder(t *testing.T) {
|
||||
doc := mustParse(t, "#include \"../x.sfz\"\n<region> sample=../a.wav\n<region> sample=/a.wav\n<region> sample=C:\\a.wav\n<region> sample=ok/../b.wav\n", map[string]string{"../x.sfz": ""})
|
||||
var codes []string
|
||||
@@ -145,6 +156,8 @@ func TestValidateOutsideFolder(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestKeyswitchRangeOneEnd checks that a keyswitch range with only one end
|
||||
// set is that one key.
|
||||
func TestKeyswitchRangeOneEnd(t *testing.T) {
|
||||
for text, want := range map[string]KeyswitchRange{
|
||||
"<region> sample=a.wav sw_lokey=36": {Low: 36, High: 36},
|
||||
|
||||
Reference in New Issue
Block a user