Udpated parser's test-common
This commit is contained in:
parent
d6aa28602c
commit
86a45d5e8a
|
@ -3,12 +3,18 @@ package parser
|
||||||
import "io"
|
import "io"
|
||||||
import "testing"
|
import "testing"
|
||||||
import "strings"
|
import "strings"
|
||||||
|
import "git.tebibyte.media/sashakoshka/fspl/lexer"
|
||||||
import "git.tebibyte.media/sashakoshka/fspl/errors"
|
import "git.tebibyte.media/sashakoshka/fspl/errors"
|
||||||
import "git.tebibyte.media/sashakoshka/fspl/testcommon"
|
import "git.tebibyte.media/sashakoshka/fspl/testcommon"
|
||||||
|
|
||||||
func testString (test *testing.T, correct string, input string) {
|
func testString (test *testing.T, correct string, input string) {
|
||||||
ast := Tree { }
|
ast := Tree { }
|
||||||
err := ast.Parse("input.fspl", strings.NewReader(input))
|
lx, err := lexer.LexReader("input.fspl", strings.NewReader(input))
|
||||||
|
if err != nil && err != io.EOF{
|
||||||
|
test.Error("lexer returned error:\n" + errors.Format(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = ast.Parse(lx)
|
||||||
if err != nil && err != io.EOF{
|
if err != nil && err != io.EOF{
|
||||||
test.Error("parser returned error:\n" + errors.Format(err))
|
test.Error("parser returned error:\n" + errors.Format(err))
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue