From a2ce35301ddd1777d7be85c32d96e6d2fb3e92d4 Mon Sep 17 00:00:00 2001 From: noti0na1 Date: Fri, 11 Oct 2024 05:50:21 +0200 Subject: [PATCH] Add REPL test --- .../dotty/tools/repl/ReplCompilerTests.scala | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/compiler/test/dotty/tools/repl/ReplCompilerTests.scala b/compiler/test/dotty/tools/repl/ReplCompilerTests.scala index f09bdcd513be..c61e50a97852 100644 --- a/compiler/test/dotty/tools/repl/ReplCompilerTests.scala +++ b/compiler/test/dotty/tools/repl/ReplCompilerTests.scala @@ -372,6 +372,43 @@ class ReplCompilerTests extends ReplTest: assertTrue(last, last.startsWith("val res0: tpolecat.type = null")) assertTrue(last, last.endsWith("""// result of "res0.toString" is null""")) + @Test def `i21431 filter out best effort options`: Unit = + initially: + run(":settings -Ybest-effort -Ywith-best-effort-tasty") + .andThen: + run("0") // check for crash + val last = lines() + 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: private val pattern = Pattern.compile("\\r[\\n]?|\\n");