26 lines
633 B
Go
26 lines
633 B
Go
package parser
|
|
|
|
import "io"
|
|
import "testing"
|
|
import "strings"
|
|
import "git.tebibyte.media/sashakoshka/fspl/errors"
|
|
import "git.tebibyte.media/sashakoshka/fspl/testcommon"
|
|
|
|
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:\n" + errors.Format(err))
|
|
return
|
|
}
|
|
|
|
got := ast.String()
|
|
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")
|
|
test.Fail()
|
|
}
|
|
}
|