Skip to content

Commit 6db1423

Browse files
dwijnandodersky
authored andcommitted
Test case for REPL bad symbolic reference
1 parent 6daae21 commit 6db1423

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

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

+14
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,20 @@ class ReplCompilerTests extends ReplTest:
409409
@Test def `i13097 expect template after colon` = contextually:
410410
assert(ParseResult.isIncomplete("class C:"))
411411

412+
@Test def i15562: Unit = initially {
413+
val s1 = run("List(1, 2).filter(_ % 2 == 0).foreach(println)")
414+
assertEquals("2", storedOutput().trim)
415+
s1
416+
} andThen { s1 ?=>
417+
val comp = tabComplete("List(1, 2).filter(_ % 2 == 0).fore")
418+
assertEquals(List("foreach"), comp.distinct)
419+
s1
420+
} andThen {
421+
val s2 = run("List(1, 2).filter(_ % 2 == 0).foreach(println)")
422+
assertEquals("2", storedOutput().trim)
423+
s2
424+
}
425+
412426
object ReplCompilerTests:
413427

414428
private val pattern = Pattern.compile("\\r[\\n]?|\\n");

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

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ extends ReplDriver(options, new PrintStream(out, true, StandardCharsets.UTF_8.na
4040

4141
def contextually[A](op: Context ?=> A): A = op(using initialState.context)
4242

43+
/** Returns the `(<instance completions>, <companion completions>)`*/
44+
def tabComplete(src: String)(implicit state: State): List[String] =
45+
completions(src.length, src, state).map(_.value).sorted
46+
4347
extension [A](state: State)
4448
infix def andThen(op: State ?=> A): A = op(using state)
4549

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

-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ import org.junit.Test
88
/** These tests test input that has proved problematic */
99
class TabcompleteTests extends ReplTest {
1010

11-
/** Returns the `(<instance completions>, <companion completions>)`*/
12-
private def tabComplete(src: String)(implicit state: State): List[String] =
13-
completions(src.length, src, state).map(_.value).sorted
14-
1511
@Test def tabCompleteList = initially {
1612
val comp = tabComplete("List.r")
1713
assertEquals(List("range"), comp.distinct)

0 commit comments

Comments
 (0)