feat: implement all runtime errors #32

Merged
jt2622 merged 16 commits from runtime-errors into master 2025-02-28 00:23:13 +00:00
2 changed files with 10 additions and 20 deletions
Showing only changes of commit cb4f899b8c - Show all commits

View File

@@ -41,23 +41,7 @@ class ParallelExamplesSpec extends AnyFlatSpec with BeforeAndAfterAll {
val inputLine = val inputLine =
contents contents
.find(_.matches("^# ?[Ii]nput:.*$")) .find(_.matches("^# ?[Ii]nput:.*$"))
.map(line => .map(_.split(":").last.strip + "\n")
("" :: 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("") .getOrElse("")
val outputLineIdx = contents.indexWhere(_.matches("^# ?[Oo]utput:.*$")) val outputLineIdx = contents.indexWhere(_.matches("^# ?[Oo]utput:.*$"))
val expectedOutput = val expectedOutput =
@@ -95,7 +79,7 @@ class ParallelExamplesSpec extends AnyFlatSpec with BeforeAndAfterAll {
assert( assert(
stdout.toString stdout.toString
.replaceAll("0x[0-9a-f]+", "#addrs#") .replaceAll("0x[0-9a-f]+", "#addrs#")
.replaceAll("fatal error:.*", "#runtime_error#\u0000") .replaceAll("fatal error:.*", "#runtime_error#\n\u0000")
.takeWhile(_ != '\u0000') .takeWhile(_ != '\u0000')
== expectedOutput == expectedOutput
) )