fspl/parser/test-common.go

33 lines
661 B
Go
Raw Normal View History

2023-09-18 05:55:38 +00:00
package parser
import "io"
import "fmt"
import "testing"
import "strings"
func testString (test *testing.T, correct, input string) {
testReader(test, correct, strings.NewReader(input))
}
func testReader (test *testing.T, correct string, inputs ...io.Reader) {
tree := Tree { }
for index, stream := range inputs {
err := tree.Parse(fmt.Sprintf("stream%d.fspl", index), stream)
if err != nil {
test.Error("parser returned error: ", err)
return
}
}
got := tree.String()
if got != correct {
test.Log("strings do not match")
test.Log("tree.String():")
test.Log(got)
test.Log("correct:")
test.Log(correct)
test.Fail()
return
}
}