Skip to content

Commit a2ce353

Browse files
noti0na1tgodzik
authored andcommitted
Add REPL test
1 parent 483e455 commit a2ce353

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,43 @@ class ReplCompilerTests extends ReplTest:
372372
assertTrue(last, last.startsWith("val res0: tpolecat.type = null"))
373373
assertTrue(last, last.endsWith("""// result of "res0.toString" is null"""))
374374

375+
@Test def `i21431 filter out best effort options`: Unit =
376+
initially:
377+
run(":settings -Ybest-effort -Ywith-best-effort-tasty")
378+
.andThen:
379+
run("0") // check for crash
380+
val last = lines()
381+
assertTrue(last(0), last(0) == ("Options incompatible with repl will be ignored: -Ybest-effort, -Ywith-best-effort-tasty"))
382+
assertTrue(last(1), last(1) == ("val res0: Int = 0"))
383+
384+
@Test def `i9879`: Unit = initially:
385+
run {
386+
"""|opaque type A = Int; def getA: A = 0
387+
|object Wrapper { opaque type A = Int; def getA: A = 1 }
388+
|val x = getA
389+
|val y = Wrapper.getA""".stripMargin
390+
}
391+
val expected = List(
392+
"def getA: A",
393+
"// defined object Wrapper",
394+
"val x: A = 0",
395+
"val y: Wrapper.A = 1"
396+
)
397+
assertEquals(expected, lines())
398+
399+
@Test def `i9879b`: Unit = initially:
400+
run {
401+
"""|def test =
402+
| type A = Int
403+
| opaque type B = String
404+
| object Wrapper { opaque type C = Int }
405+
| ()""".stripMargin
406+
}
407+
val all = lines()
408+
assertEquals(6, all.length)
409+
assertTrue(all.head.startsWith("-- [E103] Syntax Error"))
410+
assertTrue(all.exists(_.trim().startsWith("| Illegal start of statement: this modifier is not allowed here")))
411+
375412
object ReplCompilerTests:
376413

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

0 commit comments

Comments
 (0)