Skip to content

Commit dbbe845

Browse files
authored
Merge pull request #178 from andrewdroz/main
Use java lang lineSeparator to support newline across different os
2 parents ed3c1c1 + 6dd1f1f commit dbbe845

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/test/scala/progscala3/forcomps/RemoveBlanksSuite.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ package progscala3.forcomps
33

44
import munit.*
55

6+
import java.lang.System.lineSeparator
7+
68
class RemoveBlanksSuite extends FunSuite:
79
var path = "src/test/scala/progscala3/forcomps/small-test-file.txt"
810

911
test("RemoveBlanks removes blank lines in text") {
1012
val lines = RemoveBlanks(path, compress = false, numbers = false)
11-
val actual = lines.mkString("\n")
13+
val actual = lines.mkString(lineSeparator)
1214
val expected =
1315
""" This is a small
1416
|test file""".stripMargin
@@ -17,7 +19,7 @@ class RemoveBlanksSuite extends FunSuite:
1719

1820
test("RemoveBlanks optionally compresses whitespace in text") {
1921
val lines = RemoveBlanks(path, compress = true, numbers = false)
20-
val actual = lines.mkString("\n")
22+
val actual = lines.mkString(lineSeparator)
2123
val expected =
2224
"""This is a small
2325
|test file""".stripMargin
@@ -26,7 +28,7 @@ class RemoveBlanksSuite extends FunSuite:
2628

2729
test("RemoveBlanks optionally prints line numbers from the original text") {
2830
val lines = RemoveBlanks(path, compress = true, numbers = true)
29-
val actual = lines.mkString("\n")
31+
val actual = lines.mkString(lineSeparator)
3032
val expected =
3133
""" 1: This is a small
3234
| 3: test file""".stripMargin

src/test/scala/progscala3/fp/datastructs/FoldRegexPatternsSuite.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package progscala3.fp.datastructs
33

44
import munit.*
55

6+
import java.lang.System.lineSeparator
7+
68
class FoldRegexPatternsSuite extends FunSuite:
79
test("Regex pattern matching used in a foldLeft") {
810
val ignoreRegex = """^\s*(#.*|\s*)$""".r // <1>
@@ -24,7 +26,7 @@ class FoldRegexPatternsSuite extends FunSuite:
2426

2527
// Parse each line, skipping expected
2628
val actual =
27-
properties.split("\n").
29+
properties.split(lineSeparator).
2830
zipWithIndex.
2931
foldLeft(Vector.empty[Either[Error,KV]]) { case (vect, (line, n)) =>
3032
if ignoreRegex.matches(line) then vect

0 commit comments

Comments
 (0)