test: fix input handling for IOLoop example

This commit is contained in:
2025-02-27 18:25:12 +00:00
parent c472c7a62c
commit c0f2473db1

View File

@@ -39,7 +39,26 @@ class ParallelExamplesSpec extends AnyFlatSpec with BeforeAndAfterAll {
// Retrieve contents to get input and expected output + exit code
val contents = scala.io.Source.fromFile(File(filename)).getLines.toList
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 expectedOutput =
if (outputLineIdx == -1) ""
@@ -95,7 +114,7 @@ class ParallelExamplesSpec extends AnyFlatSpec with BeforeAndAfterAll {
// "^.*wacc-examples/valid/if.*$",
// "^.*wacc-examples/valid/IO/print.*$",
// "^.*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/pairs.*$",
"^.*wacc-examples/valid/runtimeErr.*$",