2023-09-18 05:55:38 +00:00
|
|
|
package parser
|
|
|
|
|
|
|
|
import "io"
|
|
|
|
import "testing"
|
|
|
|
import "strings"
|
2024-02-06 23:58:09 +00:00
|
|
|
import "git.tebibyte.media/sashakoshka/fspl/errors"
|
2024-02-06 05:49:28 +00:00
|
|
|
import "git.tebibyte.media/sashakoshka/fspl/testcommon"
|
2023-09-18 05:55:38 +00:00
|
|
|
|
2024-02-06 05:49:28 +00: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{
|
2024-02-08 21:51:48 +00:00
|
|
|
test.Error("parser returned error:\n" + errors.Format(err))
|
2024-02-06 05:49:28 +00:00
|
|
|
return
|
2023-09-18 05:55:38 +00:00
|
|
|
}
|
2023-09-21 21:04:53 +00:00
|
|
|
|
2024-02-06 05:49:28 +00:00
|
|
|
got := ast.String()
|
2023-09-18 05:55:38 +00:00
|
|
|
if got != correct {
|
2024-02-06 05:49:28 +00:00
|
|
|
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-18 05:55:38 +00:00
|
|
|
test.Fail()
|
|
|
|
}
|
|
|
|
}
|