1
1
package dotty .tools .repl
2
2
3
+ import java .util .regex .Pattern
4
+
3
5
import org .junit .Assert .{assertTrue => assert , _ }
4
6
import org .junit .{Ignore , Test }
5
7
6
8
class ReplCompilerTests extends ReplTest {
9
+ import ReplCompilerTests ._
7
10
8
11
private def lines () =
9
12
storedOutput().trim.linesIterator.toList
@@ -157,7 +160,7 @@ class ReplCompilerTests extends ReplTest {
157
160
|}
158
161
""" .stripMargin) }
159
162
.andThen { implicit state =>
160
- assertEquals (
163
+ assertMultiLineEquals (
161
164
""" // defined trait Ord
162
165
|// defined object IntOrd""" .stripMargin,
163
166
storedOutput().trim
@@ -173,11 +176,24 @@ class ReplCompilerTests extends ReplTest {
173
176
174
177
@ Test def testSingletonPrint = fromInitialState { implicit state =>
175
178
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)
177
180
}
178
181
179
182
@ Test def i6574 = fromInitialState { implicit state =>
180
183
run(" val a: 1 | 0 = 1" )
181
184
assertEquals(" val a: 1 | 0 = 1" , storedOutput().trim)
182
185
}
183
186
}
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