Sort ToString of requires

This commit is contained in:
Sasha Koshka 2022-09-29 11:06:45 -04:00
parent a31c975c9d
commit 8b88e1d440
2 changed files with 3 additions and 5 deletions

View File

@ -11,8 +11,8 @@ func TestMeta (test *testing.T) {
author "Sasha Koshka"
license "GPLv3"
require "` + filepath.Join(cwd, "./some/local/module") + `"
require "/some/absolute/path/to/someModule"
require "/usr/local/include/arf/someLibraryInstalledInStandardLocation"
require "/some/absolute/path/to/someModule"
---
`, test)
}

View File

@ -41,7 +41,8 @@ func (tree SyntaxTree) ToString (indent int) (output string) {
output += doIndent(indent, "license \"", tree.license, "\"\n")
}
for _, require := range tree.requires {
for _, name := range sortMapKeysAlphabetically(tree.requires) {
require := tree.requires[name]
output += doIndent(indent, "require \"", require, "\"\n")
}
@ -379,13 +380,10 @@ func (phrase Phrase) ToString (indent int, ownLine bool) (output string) {
func (funcOutput FuncOutput) ToString (indent int) (output string) {
output += doIndent(indent + 1)
output += "< " + funcOutput.Declaration.ToString()
// why is it always nil??? WHY???
if funcOutput.argument.kind != ArgumentKindNil {
output += " " + funcOutput.argument.ToString(indent, false)
}
output += "\n"
print(funcOutput.argument.ToString(0, true))
return
}