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")
|
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
|
|
|
|
}
|
|
|
|
}
|