11package dotty .tools .repl
22
3+ import java .util .regex .Pattern
4+
35import org .junit .Assert .{assertTrue => assert , _ }
46import org .junit .{Ignore , Test }
57
68class ReplCompilerTests extends ReplTest {
9+ import ReplCompilerTests ._
710
811 private def lines () =
912 storedOutput().trim.linesIterator.toList
@@ -157,7 +160,7 @@ class ReplCompilerTests extends ReplTest {
157160 |}
158161 """ .stripMargin) }
159162 .andThen { implicit state =>
160- assertEquals (
163+ assertMultiLineEquals (
161164 """ // defined trait Ord
162165 |// defined object IntOrd""" .stripMargin,
163166 storedOutput().trim
@@ -173,11 +176,24 @@ class ReplCompilerTests extends ReplTest {
173176
174177 @ Test def testSingletonPrint = fromInitialState { implicit state =>
175178 run(""" val a = "hello"; val x: a.type = a""" )
176- assertEquals (" val a: String = hello\n val x: a.type = hello" , storedOutput().trim)
179+ assertMultiLineEquals (" val a: String = hello\n val x: a.type = hello" , storedOutput().trim)
177180 }
178181
179182 @ Test def i6574 = fromInitialState { implicit state =>
180183 run(" val a: 1 | 0 = 1" )
181184 assertEquals(" val a: 1 | 0 = 1" , storedOutput().trim)
182185 }
183186}
187+
188+ object ReplCompilerTests {
189+
190+ private val pattern = Pattern .compile(" \\ r[\\ n]?|\\ n" );
191+
192+ // Ensure 'expected' and 'actual' contain the same line separator(s).
193+ def assertMultiLineEquals (expected : String , actual : String ): Unit = {
194+ val expected0 = pattern.matcher(expected).replaceAll(System .lineSeparator)
195+ val actual0 = pattern.matcher(actual).replaceAll(System .lineSeparator)
196+ assertEquals(expected0, actual0)
197+ }
198+
199+ }
0 commit comments