From 990a6fa60ef10d2ca2240eb86b573a7ffab2a755 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Fri, 11 Nov 2022 20:06:52 +0000 Subject: [PATCH] Fix windows test, normalise EOLs --- .../test/dotty/tools/dotc/TupleShowTests.scala | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/compiler/test/dotty/tools/dotc/TupleShowTests.scala b/compiler/test/dotty/tools/dotc/TupleShowTests.scala index 32b47b52658d..2d76c480b001 100644 --- a/compiler/test/dotty/tools/dotc/TupleShowTests.scala +++ b/compiler/test/dotty/tools/dotc/TupleShowTests.scala @@ -4,6 +4,7 @@ package dotc import core.*, Decorators.*, Symbols.* import printing.Texts.* +import java.lang.System.{ lineSeparator => EOL } import org.junit.Test class TupleShowTests extends DottyTest: @@ -51,22 +52,27 @@ class TupleShowTests extends DottyTest: )) chkEq(exp, obt) - @Test def tup3_show10 = chkEq("(Int,\n Long,\n Short)", tup3.toText(ctx.printer).mkString(10, false)) + @Test def tup3_show10 = chkEq("(Int,\n Long,\n Short)".normEOL, tup3.toText(ctx.printer).mkString(10, false)) val res21 = """|(Int, Int, Int, Int, Int, Long, Long, Long, Long, Long, Int, Int, Int, Int, - | Int, Long, Long, Long, Long, Long, Int)""".stripMargin + | Int, Long, Long, Long, Long, Long, Int)""".stripMargin.normEOL val res22 = """|(Int, Int, Int, Int, Int, Long, Long, Long, Long, Long, Int, Int, Int, Int, - | Int, Long, Long, Long, Long, Long, Int, Long)""".stripMargin + | Int, Long, Long, Long, Long, Long, Int, Long)""".stripMargin.normEOL val res23 = """|(Int, Int, Int, Int, Int, Long, Long, Long, Long, Long, Int, Int, Int, Int, - | Int, Long, Long, Long, Long, Long, Int, Long, Short)""".stripMargin + | Int, Long, Long, Long, Long, Long, Int, Long, Short)""".stripMargin.normEOL val res24 = """|(Int, Int, Int, Int, Int, Long, Long, Long, Long, Long, Int, Int, Int, Int, - | Int, Long, Long, Long, Long, Long, Int, Long, Short, Short)""".stripMargin + | Int, Long, Long, Long, Long, Long, Int, Long, Short, Short)""".stripMargin.normEOL def chkEq[A](expected: A, obtained: A) = assert(expected == obtained, diff(s"$expected", s"$obtained")) + /** On Windows the string literal in this test source file will be read with `\n` (b/c of "-encoding UTF8") + * but the compiler will correctly emit \r\n as the line separator. + * So we align the expected result to faithfully compare test results. */ + extension (str: String) def normEOL = if EOL == "\n" then str else str.replace("\n", EOL).nn + def diff(exp: String, obt: String) = val min = math.min(exp.length, obt.length) val pre =