Skip to content

Commit

Permalink
Add REPL test
Browse files Browse the repository at this point in the history
  • Loading branch information
noti0na1 committed Oct 11, 2024
1 parent 9a19ca0 commit e564d00
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion compiler/test/dotty/tools/repl/ReplCompilerTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,36 @@ class ReplCompilerTests extends ReplTest:
.andThen:
run("0") // check for crash
val last = lines()
println(last)
assertTrue(last(0), last(0) == ("Options incompatible with repl will be ignored: -Ybest-effort, -Ywith-best-effort-tasty"))
assertTrue(last(1), last(1) == ("val res0: Int = 0"))

@Test def `i9879`: Unit = initially:
run {
"""|opaque type A = Int; def getA: A = 0
|object Wrapper { opaque type A = Int; def getA: A = 1 }
|val x = getA
|val y = Wrapper.getA""".stripMargin
}
val expected = List(
"def getA: A",
"// defined object Wrapper",
"val x: A = 0",
"val y: Wrapper.A = 1"
)
assertEquals(expected, lines())

@Test def `i9879b`: Unit = initially:
run {
"""|def test =
| type A = Int
| opaque type B = String
| object Wrapper { opaque type C = Int }
| ()""".stripMargin
}
val all = lines()
assertEquals(6, all.length)
assertTrue(all.head.startsWith("-- [E103] Syntax Error"))
assertTrue(all.exists(_.trim().startsWith("| Illegal start of statement: this modifier is not allowed here")))

object ReplCompilerTests:

Expand Down

0 comments on commit e564d00

Please sign in to comment.