From 744e8de7941192d730dbd10e578f23a5ffe9b0db Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sat, 17 Sep 2022 23:29:11 -0400 Subject: [PATCH] Added ToString for SectionTable --- analyzer/table.go | 9 +++++++++ analyzer/test-common.go | 13 +++++++++++++ tests/analyzer/type/main.arf | 4 ++++ 3 files changed, 26 insertions(+) create mode 100644 analyzer/test-common.go create mode 100644 tests/analyzer/type/main.arf diff --git a/analyzer/table.go b/analyzer/table.go index 94e1142..cfe313d 100644 --- a/analyzer/table.go +++ b/analyzer/table.go @@ -15,6 +15,15 @@ func (where locator) ToString () (output string) { // and all sections that it requires from other modules. type SectionTable map[locator] Section +// ToString returns the data stored in the table as a string. +func (table SectionTable) ToString (indent int) (output string) { + for _, section := range table { + output += section.ToString(indent) + } + + return +} + // SectionKind differentiates Section interfaces. type SectionKind int diff --git a/analyzer/test-common.go b/analyzer/test-common.go new file mode 100644 index 0000000..ae186df --- /dev/null +++ b/analyzer/test-common.go @@ -0,0 +1,13 @@ +package analyzer + +import "os" +import "testing" +import "path/filepath" +import "git.tebibyte.media/arf/arf/testCommon" + +func checkTree (modulePath string, skim bool, correct string, test *testing.T) { + cwd, _ := os.Getwd() + modulePath = filepath.Join(cwd, modulePath) + table, err := Analyze(modulePath, skim) + testCommon.CheckStrings(test, table, err, correct) +} diff --git a/tests/analyzer/type/main.arf b/tests/analyzer/type/main.arf new file mode 100644 index 0000000..9858c4d --- /dev/null +++ b/tests/analyzer/type/main.arf @@ -0,0 +1,4 @@ +:arf +--- + +type basicInt:Int:<5>