@@ -4,6 +4,8 @@ import com.sun.jdi.Location
44import dotty .tools .io .JPath
55import dotty .tools .readLines
66
7+ import scala .annotation .tailrec
8+
79/**
810 * A debug step and an associated assertion to validate the step.
911 * A sequence of DebugStepAssert is parsed from the check file in tests/debug
@@ -41,8 +43,9 @@ private[debug] object DebugStepAssert:
4143 val multiLineError = s " error $trailing" .r
4244 val allLines = readLines(checkFile.toFile)
4345
46+ @ tailrec
4447 def loop (lines : List [String ], acc : List [DebugStepAssert [? ]]): List [DebugStepAssert [? ]] =
45- given CheckFileLocation = CheckFileLocation (checkFile, allLines.size - lines.size + 1 )
48+ given location : CheckFileLocation = CheckFileLocation (checkFile, allLines.size - lines.size + 1 )
4649 lines match
4750 case Nil => acc.reverse
4851 case break(className , lineStr) :: tail =>
@@ -66,18 +69,21 @@ private[debug] object DebugStepAssert:
6669 val step = DebugStepAssert (Eval (expr), assertion)
6770 loop(tail2, step :: acc)
6871 case trailing() :: tail => loop(tail, acc)
69- case invalid :: tail => throw new Exception (s " Cannot parse debug step: $invalid" )
72+ case invalid :: tail =>
73+ throw new Exception (s " Cannot parse debug step: $invalid ( $location) " )
7074
7175 def parseEvalAssertion (lines : List [String ]): (Either [String , String ] => Unit , List [String ]) =
72- given CheckFileLocation = CheckFileLocation (checkFile, allLines.size - lines.size + 1 )
76+ given location : CheckFileLocation = CheckFileLocation (checkFile, allLines.size - lines.size + 1 )
7377 lines match
7478 case Nil => throw new Exception (s " Missing result or error " )
79+ case trailing() :: tail => parseEvalAssertion(tail)
7580 case result(expected) :: tail => (checkResult(expected), tail)
7681 case error(expected) :: tail => (checkError(Seq (expected)), tail)
7782 case multiLineError() :: tail0 =>
7883 val (expected, tail1) = tail0.span(_.startsWith(" " ))
7984 (checkError(expected.map(_.stripPrefix(" " ))), tail1)
80- case invalid :: _ => throw new Exception (s " Cannot parse as result or error: $invalid" )
85+ case invalid :: _ =>
86+ throw new Exception (s " Cannot parse as result or error: $invalid ( $location) " )
8187
8288 loop(allLines, Nil )
8389 end parseCheckFile
0 commit comments