fspl/parser/test-common.go

31 lines
644 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
}
}
2023-09-18 05:55:38 +00:00
got := tree.String()
if got != correct {
test.Log("strings do not match")
2023-09-18 06:12:27 +00:00
test.Log("tree.String():\n" + got)
test.Log("correct:\n" + correct)
2023-09-18 05:55:38 +00:00
test.Fail()
return
}
}