Skip to content

Commit 89f0e7f

Browse files
committed
tests: Bring tool args reading to REPL tests
And, by doing so, reinstate the repl/i13208 script.
1 parent 5fc8313 commit 89f0e7f

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// scalac: -source:future -deprecation
22
scala> type M[X] = X match { case Int => String case _ => Int }
3-
-- Deprecation Warning:
3+
1 warning found
4+
-- Deprecation Warning: --------------------------------------------------------
45
1 | type M[X] = X match { case Int => String case _ => Int }
56
| ^
67
| `_` is deprecated for wildcard arguments of types: use `?` instead
78
scala> type N[X] = X match { case List[_] => Int }
8-
-- Deprecation Warning:
9+
1 warning found
10+
-- Deprecation Warning: --------------------------------------------------------
911
1 | type N[X] = X match { case List[_] => Int }
1012
| ^
1113
| `_` is deprecated for wildcard arguments of types: use `?` instead

compiler/test/dotty/tools/repl/ReplTest.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,21 @@ extends ReplDriver(options, new PrintStream(out, true, StandardCharsets.UTF_8.na
6464

6565
val expectedOutput = lines.flatMap(filterEmpties)
6666
val actualOutput = {
67-
resetToInitial()
67+
val opts = toolArgsParse(lines.take(1))
68+
val (optsLine, inputLines) = if opts.isEmpty then ("", lines) else (lines.head, lines.drop(1))
69+
resetToInitial(opts)
6870

69-
assert(lines.head.startsWith(prompt),
71+
assert(inputLines.head.startsWith(prompt),
7072
s"""Each script must start with the prompt: "$prompt"""")
71-
val inputRes = lines.filter(_.startsWith(prompt))
73+
val inputRes = inputLines.filter(_.startsWith(prompt))
7274

7375
val buf = new ArrayBuffer[String]
7476
inputRes.foldLeft(initialState) { (state, input) =>
7577
val (out, nstate) = evaluate(state, input)
7678
out.linesIterator.foreach(buf.append)
7779
nstate
7880
}
79-
buf.toList.flatMap(filterEmpties)
81+
(optsLine :: buf.toList).flatMap(filterEmpties)
8082
}
8183

8284
if !FileDiff.matches(actualOutput, expectedOutput) then

0 commit comments

Comments
 (0)