From 3a3c588023dc239245d8327e39bcae07e84afcdd Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Mon, 15 Aug 2022 14:23:53 -0400 Subject: [PATCH] Added data test --- parser/parser_test.go | 35 ++++++++++++++++++++++++++++++++++- parser/tree-tostring.go | 4 ++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/parser/parser_test.go b/parser/parser_test.go index ea6c19d..4e4a21b 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -42,7 +42,6 @@ func quickIdentifier (trail ...string) (identifier Identifier) { } func TestMeta (test *testing.T) { - checkTree ("../tests/parser/meta", `:arf author "Sasha Koshka" @@ -52,3 +51,37 @@ require "otherModule" --- `, test) } + +func TestData (test *testing.T) { + checkTree ("../tests/parser/data", +`:arf +--- +data wr integer:Int 3202 +data wr integerPointer:{Int} +data wr integerArray16:{Int 16} +data wr integerArrayVariable:{Int ...} +data wr integerArrayInitialized:{Int 16} + 3948 + 293 + 293049 + 948 + 912 + 340 + 0 + 2304 + 0 + 4785 + 92 +data wr object:Obj + , this 324 + , that 2139 +data wr nestedObject:Obj + , this + , bird0 324 + , bird1 "hello world" + , that + , bird2 123.8439 + , bird3 9328.21348239 +`, test) +} + diff --git a/parser/tree-tostring.go b/parser/tree-tostring.go index acfeaa9..8689f6c 100644 --- a/parser/tree-tostring.go +++ b/parser/tree-tostring.go @@ -175,5 +175,9 @@ func (section *DataSection) ToString (indent int) (output string) { section.permission.ToString(), " ", section.name, ":", section.what.ToString()) + + // TODO: print out initialization values. if there is only one of them, + // keep it on the same line. if there are more than one, give each its + // own line. return }