Skip to content

Commit fa1cbb0

Browse files
authored
Fix windows test (#16321)
[test_windows_full]
2 parents cc4c279 + 990a6fa commit fa1cbb0

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

compiler/test/dotty/tools/dotc/TupleShowTests.scala

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package dotc
44
import core.*, Decorators.*, Symbols.*
55
import printing.Texts.*
66

7+
import java.lang.System.{ lineSeparator => EOL }
78
import org.junit.Test
89

910
class TupleShowTests extends DottyTest:
@@ -51,22 +52,27 @@ class TupleShowTests extends DottyTest:
5152
))
5253
chkEq(exp, obt)
5354

54-
@Test def tup3_show10 = chkEq("(Int,\n Long,\n Short)", tup3.toText(ctx.printer).mkString(10, false))
55+
@Test def tup3_show10 = chkEq("(Int,\n Long,\n Short)".normEOL, tup3.toText(ctx.printer).mkString(10, false))
5556

5657
val res21 = """|(Int, Int, Int, Int, Int, Long, Long, Long, Long, Long, Int, Int, Int, Int,
57-
| Int, Long, Long, Long, Long, Long, Int)""".stripMargin
58+
| Int, Long, Long, Long, Long, Long, Int)""".stripMargin.normEOL
5859

5960
val res22 = """|(Int, Int, Int, Int, Int, Long, Long, Long, Long, Long, Int, Int, Int, Int,
60-
| Int, Long, Long, Long, Long, Long, Int, Long)""".stripMargin
61+
| Int, Long, Long, Long, Long, Long, Int, Long)""".stripMargin.normEOL
6162

6263
val res23 = """|(Int, Int, Int, Int, Int, Long, Long, Long, Long, Long, Int, Int, Int, Int,
63-
| Int, Long, Long, Long, Long, Long, Int, Long, Short)""".stripMargin
64+
| Int, Long, Long, Long, Long, Long, Int, Long, Short)""".stripMargin.normEOL
6465

6566
val res24 = """|(Int, Int, Int, Int, Int, Long, Long, Long, Long, Long, Int, Int, Int, Int,
66-
| Int, Long, Long, Long, Long, Long, Int, Long, Short, Short)""".stripMargin
67+
| Int, Long, Long, Long, Long, Long, Int, Long, Short, Short)""".stripMargin.normEOL
6768

6869
def chkEq[A](expected: A, obtained: A) = assert(expected == obtained, diff(s"$expected", s"$obtained"))
6970

71+
/** On Windows the string literal in this test source file will be read with `\n` (b/c of "-encoding UTF8")
72+
* but the compiler will correctly emit \r\n as the line separator.
73+
* So we align the expected result to faithfully compare test results. */
74+
extension (str: String) def normEOL = if EOL == "\n" then str else str.replace("\n", EOL).nn
75+
7076
def diff(exp: String, obt: String) =
7177
val min = math.min(exp.length, obt.length)
7278
val pre =

0 commit comments

Comments
 (0)