From 77acfd1cf26def0d7963274a6c4e22c733b746bf Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sat, 17 Sep 2022 12:22:17 -0400 Subject: [PATCH] Fixed func ToString and test case --- parser/func_test.go | 9 ++++----- parser/tree-tostring.go | 7 +++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/parser/func_test.go b/parser/func_test.go index ed10863..e44e528 100644 --- a/parser/func_test.go +++ b/parser/func_test.go @@ -101,10 +101,9 @@ func ro gControlFlow [otherThing] func ro hSetPhrase --- - let x:Int:<3> - let y:{Int}:<[loc x]> - let z:Int:8:<398 9 2309 983 -2387 478 555 123> - let bird:Bird:(.that:(.whenYou:<99999>) .this:<324>) - + [let x:Int:<3>] + [let y:{Int}:<[loc x]>] + [let z:Int:8:<398 9 2309 983 -2387 478 555 123>] + [let bird:Bird:(.that:(.whenYou:<99999>) .this:<324>)] `, test) } diff --git a/parser/tree-tostring.go b/parser/tree-tostring.go index 332f5e5..e38f6cf 100644 --- a/parser/tree-tostring.go +++ b/parser/tree-tostring.go @@ -76,7 +76,9 @@ func (values ObjectDefaultValues) ToString ( output += doIndent(indent, "(") if breakLine { output += "\n" } - for _, name := range sortMapKeysAlphabetically(values) { + for index, name := range sortMapKeysAlphabetically(values) { + if index > 0 && !breakLine { output += " " } + value := values[name] output += doIndent(indent, "." + name + ":") @@ -109,7 +111,8 @@ func (values ArrayDefaultValues) ToString ( output += doIndent(indent, "<") if breakLine { output += "\n" } - for _, value := range values { + for index, value := range values { + if index > 0 && !breakLine { output += " " } output += value.ToString(indent, breakLine) }