This repository has been archived on 2022-08-29. You can view files and clone it, but cannot push or open issues or pull requests.
arf/parser/parser_test.go

55 lines
989 B
Go
Raw Normal View History

2022-08-12 10:55:17 -06:00
package parser
import "io"
2022-08-12 10:55:17 -06:00
import "testing"
// import "git.tebibyte.media/sashakoshka/arf/types"
2022-08-12 10:55:17 -06:00
func checkTree (modulePath string, correct string, test *testing.T) {
2022-08-12 10:55:17 -06:00
tree, err := Parse(modulePath)
if err != io.EOF {
2022-08-12 10:55:17 -06:00
test.Log("returned error:")
test.Log(err.Error())
test.Fail()
return
}
treeString := tree.ToString(0)
if treeString != correct {
test.Log("trees not equal!")
test.Log("CORRECT TREE:")
test.Log(correct)
test.Log("WHAT WAS PARSED:")
test.Log(treeString)
2022-08-12 10:55:17 -06:00
test.Fail()
return
}
}
// quickIdentifier returns a simple identifier of names
func quickIdentifier (trail ...string) (identifier Identifier) {
for _, item := range trail {
identifier.trail = append (
identifier.trail,
Argument {
what: ArgumentKindString,
value: item,
},
)
}
return
}
2022-08-12 10:55:17 -06:00
func TestMeta (test *testing.T) {
checkTree ("../tests/parser/meta",
`:arf
author "Sasha Koshka"
license "GPLv3"
require "someModule"
require "otherModule"
---
`, test)
}