-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EmptyFileTest: use explicit
expected
- Loading branch information
Showing
1 changed file
with
15 additions
and
4 deletions.
There are no files selected for viewing
19 changes: 15 additions & 4 deletions
19
scalafmt-tests/src/test/scala/org/scalafmt/EmptyFileTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
) | ||
} | ||
} | ||
|
||
} |