diff options
author | Som Snytt <som.snytt@gmail.com> | 2016-10-19 12:26:59 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2016-10-19 12:50:24 -0700 |
commit | 9201f53ba46159cbd3a342a51106e671d0063feb (patch) | |
tree | 881f1d143c62e87508cc2d42a36306512b6e3005 | |
parent | 12fb6fee44177742c68be6b4ef46709d0dd6db06 (diff) | |
download | scala-9201f53ba46159cbd3a342a51106e671d0063feb.tar.gz scala-9201f53ba46159cbd3a342a51106e671d0063feb.tar.bz2 scala-9201f53ba46159cbd3a342a51106e671d0063feb.zip |
SI-9832 Fix line endings in junit test
-rw-r--r-- | test/junit/scala/tools/nsc/settings/SettingsTest.scala | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/test/junit/scala/tools/nsc/settings/SettingsTest.scala b/test/junit/scala/tools/nsc/settings/SettingsTest.scala index 3fdf758619..183cb792cc 100644 --- a/test/junit/scala/tools/nsc/settings/SettingsTest.scala +++ b/test/junit/scala/tools/nsc/settings/SettingsTest.scala @@ -181,6 +181,12 @@ class SettingsTest { assertThrows[IllegalArgumentException](check(expected = "2.11", "-Xsource:2.invalid"), _ contains "There was a problem parsing 2.invalid") } + // equal with stripped margins and normalized line endings + private def marginallyEquals(s1: String, s2: String): Boolean = { + def normally(s: String): String = s.stripMargin.lines.mkString("\n") + normally(s1) == normally(s2) + } + @Test def helpHasDefault(): Unit = { val s = new MutableSettings(msg => throw new IllegalArgumentException(msg)) object mChoices extends s.MultiChoiceEnumeration { @@ -201,15 +207,14 @@ class SettingsTest { assertTrue(check("-m")(_.value == Set(b))) assertTrue(check("-m") { _ => - assertEquals( - """magic sauce - | a help a - | b help b - | c help c - |Default: b - |""".stripMargin, - m.help) - true + val expected = + """|magic sauce + | a help a + | b help b + | c help c + |Default: b + |""" + marginallyEquals(expected, m.help) }) } @Test def helpHasDefaultAll(): Unit = { @@ -232,15 +237,14 @@ class SettingsTest { assertTrue(check("-m")(_.value == Set(a, b, c))) assertTrue(check("-m") { _ => - assertEquals( - """magic sauce - | a help a - | b help b - | c help c - |Default: All choices are enabled by default. - |""".stripMargin, - m.help) - true + val expected = + """|magic sauce + | a help a + | b help b + | c help c + |Default: All choices are enabled by default. + |""" + marginallyEquals(expected, m.help) }) } } |