fix: variable-sized values, heap-allocated arrays (and printCharArray) #28

Merged
gk1623 merged 6 commits from asm-gen-arrays into asm-gen 2025-02-27 18:50:12 +00:00
10 changed files with 402 additions and 247 deletions
Showing only changes of commit c0f2473db1 - Show all commits

View File

@@ -39,7 +39,26 @@ class ParallelExamplesSpec extends AnyFlatSpec with BeforeAndAfterAll {
// Retrieve contents to get input and expected output + exit code // Retrieve contents to get input and expected output + exit code
val contents = scala.io.Source.fromFile(File(filename)).getLines.toList val contents = scala.io.Source.fromFile(File(filename)).getLines.toList
val inputLine = val inputLine =
contents.find(_.matches("^# ?[Ii]nput:.*$")).map(_.split(":").last.strip).getOrElse("") contents
.find(_.matches("^# ?[Ii]nput:.*$"))
.map(line =>
("" :: line.split(":").last.strip.split(" ").toList)
.sliding(2)
.flatMap { arr =>
if (
// First entry has no space in front
arr(0) == "" ||
// int followed by non-digit, space can be removed
arr(0).toIntOption.nonEmpty && !arr(1)(0).isDigit ||
// non-int followed by int, space can be removed
!arr(0).last.isDigit && arr(1).toIntOption.nonEmpty
)
then List(arr(1))
else List(" ", arr(1))
}
.mkString
)
.getOrElse("")
val outputLineIdx = contents.indexWhere(_.matches("^# ?[Oo]utput:.*$")) val outputLineIdx = contents.indexWhere(_.matches("^# ?[Oo]utput:.*$"))
val expectedOutput = val expectedOutput =
if (outputLineIdx == -1) "" if (outputLineIdx == -1) ""
@@ -95,7 +114,7 @@ class ParallelExamplesSpec extends AnyFlatSpec with BeforeAndAfterAll {
// "^.*wacc-examples/valid/if.*$", // "^.*wacc-examples/valid/if.*$",
// "^.*wacc-examples/valid/IO/print.*$", // "^.*wacc-examples/valid/IO/print.*$",
// "^.*wacc-examples/valid/IO/read.*$", // "^.*wacc-examples/valid/IO/read.*$",
"^.*wacc-examples/valid/IO/IOLoop.wacc.*$", // "^.*wacc-examples/valid/IO/IOLoop.wacc.*$",
// "^.*wacc-examples/valid/IO/IOSequence.wacc.*$", // "^.*wacc-examples/valid/IO/IOSequence.wacc.*$",
// "^.*wacc-examples/valid/pairs.*$", // "^.*wacc-examples/valid/pairs.*$",
"^.*wacc-examples/valid/runtimeErr.*$", "^.*wacc-examples/valid/runtimeErr.*$",