|
|
|
@ -1,21 +1,26 @@
|
|
|
|
package parser
|
|
|
|
package parser
|
|
|
|
|
|
|
|
|
|
|
|
import "reflect"
|
|
|
|
import "io"
|
|
|
|
import "testing"
|
|
|
|
import "testing"
|
|
|
|
import "git.tebibyte.media/sashakoshka/arf/types"
|
|
|
|
// import "git.tebibyte.media/sashakoshka/arf/types"
|
|
|
|
|
|
|
|
|
|
|
|
func checkTree (modulePath string, correct *SyntaxTree, test *testing.T) {
|
|
|
|
func checkTree (modulePath string, correct string, test *testing.T) {
|
|
|
|
tree, err := Parse(modulePath)
|
|
|
|
tree, err := Parse(modulePath)
|
|
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err != io.EOF {
|
|
|
|
test.Log("returned error:")
|
|
|
|
test.Log("returned error:")
|
|
|
|
test.Log(err.Error())
|
|
|
|
test.Log(err.Error())
|
|
|
|
test.Fail()
|
|
|
|
test.Fail()
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(tree, correct) {
|
|
|
|
treeString := tree.ToString(0)
|
|
|
|
test.Log("trees not equal")
|
|
|
|
if treeString != correct {
|
|
|
|
|
|
|
|
test.Log("trees not equal!")
|
|
|
|
|
|
|
|
test.Log("CORRECT TREE:")
|
|
|
|
|
|
|
|
test.Log(correct)
|
|
|
|
|
|
|
|
test.Log("WHAT WAS PARSED:")
|
|
|
|
|
|
|
|
test.Log(treeString)
|
|
|
|
test.Fail()
|
|
|
|
test.Fail()
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|