Skip to content

Fix windows test #16321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions compiler/test/dotty/tools/dotc/TupleShowTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 =
Expand Down