diff options
author | Seth Tisue <seth@tisue.net> | 2016-10-19 19:51:04 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-19 19:51:04 -0700 |
commit | 54cf7313e6bd16bddcba2052d0b4277ead308abd (patch) | |
tree | 2c44e516d14f69675b85621945dbb290ed6d0c60 | |
parent | af41493ea423fa49e26c3e57ad5b4adc5f20237d (diff) | |
parent | 9201f53ba46159cbd3a342a51106e671d0063feb (diff) | |
download | scala-54cf7313e6bd16bddcba2052d0b4277ead308abd.tar.gz scala-54cf7313e6bd16bddcba2052d0b4277ead308abd.tar.bz2 scala-54cf7313e6bd16bddcba2052d0b4277ead308abd.zip |
Merge pull request #5467 from som-snytt/issue/9832-2.11-cleanup
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) }) } } |