Skip to content

Commit 9cfdc2a

Browse files
committed
fmt
1 parent d34ceaf commit 9cfdc2a

File tree

2 files changed

+45
-16
lines changed

2 files changed

+45
-16
lines changed

os/src/Path.scala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ object PathChunk extends PathChunkMacros {
2626
val splitted = strNoTrailingSeps.split('/')
2727
splitted ++ Array.fill(trailingSeparatorsCount)("")
2828
}
29-
private def reduceUps(in:Array[String]): List[String] = in.foldLeft(List.empty[String]){case (acc,x) =>
30-
acc match{
31-
case h :: t if h == ".." => x :: acc
32-
case h :: t if x == ".." => t
33-
case _ => x :: acc}
34-
}.reverse
29+
private def reduceUps(in: Array[String]): List[String] =
30+
in.foldLeft(List.empty[String]) { case (acc, x) =>
31+
acc match {
32+
case h :: t if h == ".." => x :: acc
33+
case h :: t if x == ".." => t
34+
case _ => x :: acc
35+
}
36+
}.reverse
3537
private[os] def segmentsFromStringLiteralValidation(literal: String): Array[String] = {
3638
val stringSegments = segmentsFromString(literal)
3739
val validSegmnts = reduceUps(validLiteralSegments(stringSegments))

os/test/src/PathTests.scala

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,44 @@ object PathTests extends TestSuite {
3030

3131
test("Compile errors") {
3232

33-
compileError("""root / "src/../foo"""").check("", nonCanonicalLiteral("src/../foo","foo"))
34-
compileError("""root / "hello/../world"""").check("", nonCanonicalLiteral("hello/../world","world"))
35-
compileError("""root / "src/../foo/bar"""").check("", nonCanonicalLiteral("src/../foo/bar","foo/bar"))
36-
compileError("""root / "src/../foo/bar/.."""").check("", nonCanonicalLiteral("src/../foo/bar/..","foo"))
37-
compileError("""root / "src/../foo/../bar/."""").check("", nonCanonicalLiteral("src/../foo/../bar/.","bar"))
38-
compileError("""root / "src/foo/./.."""").check("", nonCanonicalLiteral("src/foo/./..","src"))
39-
compileError("""root / "src/foo//./.."""").check("", nonCanonicalLiteral("src/foo//./..","src"))
33+
compileError("""root / "src/../foo"""").check("", nonCanonicalLiteral("src/../foo", "foo"))
34+
compileError("""root / "hello/../world"""").check(
35+
"",
36+
nonCanonicalLiteral("hello/../world", "world")
37+
)
38+
compileError("""root / "src/../foo/bar"""").check(
39+
"",
40+
nonCanonicalLiteral("src/../foo/bar", "foo/bar")
41+
)
42+
compileError("""root / "src/../foo/bar/.."""").check(
43+
"",
44+
nonCanonicalLiteral("src/../foo/bar/..", "foo")
45+
)
46+
compileError("""root / "src/../foo/../bar/."""").check(
47+
"",
48+
nonCanonicalLiteral("src/../foo/../bar/.", "bar")
49+
)
50+
compileError("""root / "src/foo/./.."""").check(
51+
"",
52+
nonCanonicalLiteral("src/foo/./..", "src")
53+
)
54+
compileError("""root / "src/foo//./.."""").check(
55+
"",
56+
nonCanonicalLiteral("src/foo//./..", "src")
57+
)
4058

4159
compileError("""root / "src/.."""").check("", removeLiteralErr("src/.."))
4260
compileError("""root / "src/../foo/.."""").check("", removeLiteralErr("src/../foo/.."))
4361
compileError("""root / "src/foo/../.."""").check("", removeLiteralErr("src/foo/../.."))
4462
compileError("""root / "src/foo/./../.."""").check("", removeLiteralErr("src/foo/./../.."))
45-
compileError("""root / "src/./foo/./../.."""").check("", removeLiteralErr("src/./foo/./../.."))
46-
compileError("""root / "src///foo/./../.."""").check("", removeLiteralErr("src///foo/./../.."))
63+
compileError("""root / "src/./foo/./../.."""").check(
64+
"",
65+
removeLiteralErr("src/./foo/./../..")
66+
)
67+
compileError("""root / "src///foo/./../.."""").check(
68+
"",
69+
removeLiteralErr("src///foo/./../..")
70+
)
4771

4872
compileError("""root / "/" """).check("", removeLiteralErr("/"))
4973
compileError("""root / "/ " """).check("", nonCanonicalLiteral("/ ", " "))
@@ -54,7 +78,10 @@ object PathTests extends TestSuite {
5478
compileError("""root / "foo//" """).check("", nonCanonicalLiteral("foo//", "foo"))
5579

5680
compileError("""root / "foo/bar/" """).check("", nonCanonicalLiteral("foo/bar/", "foo/bar"))
57-
compileError("""root / "foo/bar//" """).check("", nonCanonicalLiteral("foo/bar//", "foo/bar"))
81+
compileError("""root / "foo/bar//" """).check(
82+
"",
83+
nonCanonicalLiteral("foo/bar//", "foo/bar")
84+
)
5885

5986
compileError("""root / "/foo" """).check("", nonCanonicalLiteral("/foo", "foo"))
6087
compileError("""root / "//foo" """).check("", nonCanonicalLiteral("//foo", "foo"))

0 commit comments

Comments
 (0)