diff --git a/os/src/Path.scala b/os/src/Path.scala index b34a3da6..ecc8a1ed 100644 --- a/os/src/Path.scala +++ b/os/src/Path.scala @@ -408,15 +408,21 @@ object Path { else{ var xSeg = "" var ySeg = "" - var i = -1 + var i = 0 + var result: Integer = null while ({ - i += 1 xSeg = x.getSegment(i) ySeg = y.getSegment(i) - i < xSegCount && xSeg == ySeg + i += 1 + val compared = Ordering.String.compare(xSeg, ySeg) + if (i < xSegCount && compared == 0) true // continue + else { + result = compared + false + } }) () - if (i == xSegCount) 0 - else Ordering.String.compare(xSeg, ySeg) + + result } } } diff --git a/os/test/src/PathTests.scala b/os/test/src/PathTests.scala index d96a664d..88ed6010 100644 --- a/os/test/src/PathTests.scala +++ b/os/test/src/PathTests.scala @@ -327,10 +327,21 @@ object PathTests extends TestSuite{ } } test("sorting"){ - assert( - Seq(root/"c", root, root/"b", root/"a").sorted == Seq(root, root/"a", root/"b", root/"c"), + test - { + assert( + Seq(root/"c", root, root/"b", root/"a").sorted == + Seq(root, root/"a", root/"b", root/"c") + ) + } + + test - assert( Seq(up/"c", up/up/"c", rel/"b"/"c", rel/"a"/"c", rel/"a"/"d").sorted == - Seq(rel/"a"/"c", rel/"a"/"d", rel/"b"/"c", up/"c", up/up/"c") + Seq(rel/"a"/"c", rel/"a"/"d", rel/"b"/"c", up/"c", up/up/"c") + ) + + test - assert( + Seq(os.root / "yo", os.root / "yo").sorted == + Seq(os.root / "yo", os.root / "yo") ) } test("construction"){