Skip to content

Commit d34ceaf

Browse files
committed
fix and add tests
1 parent f470844 commit d34ceaf

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

os/test/src/PathTests.scala

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,28 @@ object PathTests extends TestSuite {
2323
test("literals with [..]") {
2424

2525
assert(rel / "src" / ".." == rel / "src" / os.up)
26-
assert(root / "src/.." == root / "src" / os.up)
2726
assert(root / "src" / ".." == root / "src" / os.up)
2827
assert(root / "hello" / ".." / "world" == root / "hello" / os.up / "world")
2928
assert(root / "hello" / "../world" == root / "hello" / os.up / "world")
30-
assert(root / "hello/../world" == root / "hello" / os.up / "world")
3129
}
3230

3331
test("Compile errors") {
32+
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"))
40+
41+
compileError("""root / "src/.."""").check("", removeLiteralErr("src/.."))
42+
compileError("""root / "src/../foo/.."""").check("", removeLiteralErr("src/../foo/.."))
43+
compileError("""root / "src/foo/../.."""").check("", removeLiteralErr("src/foo/../.."))
44+
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/./../.."))
47+
3448
compileError("""root / "/" """).check("", removeLiteralErr("/"))
3549
compileError("""root / "/ " """).check("", nonCanonicalLiteral("/ ", " "))
3650
compileError("""root / " /" """).check("", nonCanonicalLiteral(" /", " "))
@@ -40,10 +54,7 @@ object PathTests extends TestSuite {
4054
compileError("""root / "foo//" """).check("", nonCanonicalLiteral("foo//", "foo"))
4155

4256
compileError("""root / "foo/bar/" """).check("", nonCanonicalLiteral("foo/bar/", "foo/bar"))
43-
compileError("""root / "foo/bar//" """).check(
44-
"",
45-
nonCanonicalLiteral("foo/bar//", "foo/bar")
46-
)
57+
compileError("""root / "foo/bar//" """).check("", nonCanonicalLiteral("foo/bar//", "foo/bar"))
4758

4859
compileError("""root / "/foo" """).check("", nonCanonicalLiteral("/foo", "foo"))
4960
compileError("""root / "//foo" """).check("", nonCanonicalLiteral("//foo", "foo"))

0 commit comments

Comments
 (0)