From 3900bbe7bf0faf265b9d37b54e9dad46c161be2a Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sat, 20 Aug 2022 15:45:01 -0400 Subject: [PATCH] Parser test cases now print out line numbers --- parser/parser_test.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/parser/parser_test.go b/parser/parser_test.go index 5d38cc9..051e771 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -1,6 +1,7 @@ package parser import "io" +import "strings" import "testing" // import "git.tebibyte.media/sashakoshka/arf/types" @@ -10,9 +11,9 @@ func checkTree (modulePath string, correct string, test *testing.T) { treeRunes := []rune(treeString) test.Log("CORRECT TREE:") - test.Log(correct) + logWithLineNumbers(correct, test) test.Log("WHAT WAS PARSED:") - test.Log(treeString) + logWithLineNumbers(treeString, test) if err != io.EOF && err != nil { test.Log("returned error:") @@ -63,6 +64,15 @@ func checkTree (modulePath string, correct string, test *testing.T) { } } +func logWithLineNumbers (bigString string, test *testing.T) { + lines := strings.Split ( + strings.Replace(bigString, "\t", " ", -1), "\n") + + for index, line := range lines { + test.Logf("%3d | %s", index + 1, line) + } +} + func TestMeta (test *testing.T) { checkTree ("../tests/parser/meta", `:arf