Skip to content

Commit

Permalink
EmptyFileTest: use explicit expected
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Jul 8, 2024
1 parent 888030c commit 1d5350d
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions scalafmt-tests/src/test/scala/org/scalafmt/EmptyFileTest.scala
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
package org.scalafmt

import scala.meta.internal.prettyprinters.DoubleQuotes

import java.lang.System.lineSeparator

import munit.FunSuite

class EmptyFileTest extends FunSuite {

test("empty tree formats to newline") {
Seq("", lineSeparator, "", s" $lineSeparator ").foreach { original =>
val expected = "\n"
Seq(
("", "\n"),
(" \n \n ", "\n"),
(" \r\n \r\n ", "\n"),
(lineSeparator(), "\n"),
(s" $lineSeparator ", "\n"),
).foreach { case (original, expected) =>
val expectedQuoted = DoubleQuotes(expected)
test(s"empty tree formats to newline: ${DoubleQuotes(original)} -> $expectedQuoted") {
val obtained = Scalafmt.format(original).get
assertNoDiff(obtained, expected)
if (obtained != expected) fail(
s"values are not equal: ${DoubleQuotes(obtained)} != $expectedQuoted",
)
}
}

}

0 comments on commit 1d5350d

Please sign in to comment.