fspl/parser/test-common.go

25 lines
563 B
Go
Raw Normal View History

2023-09-17 23:55:38 -06:00
package parser
import "io"
import "testing"
import "strings"
import "git.tebibyte.media/sashakoshka/fspl/testcommon"
2023-09-17 23:55:38 -06:00
func testString (test *testing.T, correct string, input string) {
ast := Tree { }
err := ast.Parse("input.fspl", strings.NewReader(input))
if err != nil && err != io.EOF{
test.Error("parser returned error:", err)
return
2023-09-17 23:55:38 -06:00
}
got := ast.String()
2023-09-17 23:55:38 -06:00
if got != correct {
test.Logf("results do not match")
testcommon.Compare(test, correct, got)
test.Log("SOURCE FSPL CODE:")
test.Log("\033[32m" + input + "\033[0m")
2023-09-17 23:55:38 -06:00
test.Fail()
}
}