@@ -336,7 +336,40 @@ class SmokeFileTest {
336336 }
337337 assertEquals(" second third" ,
338338 SystemFileSystem .source(path).buffered().use { it.readString() })
339+ }
340+
341+ @Test
342+ fun resolve () {
343+ assertFailsWith<FileNotFoundException >(" Non-existing path resolution should fail" ) {
344+ SystemFileSystem .resolve(createTempPath())
345+ }
346+
347+ val cwd = SystemFileSystem .resolve(Path (" ." ))
348+ val parentRel = Path (" .." )
349+ assertEquals(cwd.parent, SystemFileSystem .resolve(parentRel))
339350
351+ assertEquals(cwd, SystemFileSystem .resolve(cwd),
352+ " Absolute path resolution should not alter the path" )
353+
354+ // root
355+ // |-> a -> b
356+ // |-> c -> d
357+ val root = createTempPath()
358+ SystemFileSystem .createDirectories(Path (root, " a" , " b" ))
359+ val tgt = Path (root, " c" , " d" )
360+ SystemFileSystem .createDirectories(tgt)
361+
362+ val src = Path (root, " a" , " .." , " a" , " ." , " b" , " .." , " .." , " c" , " ." , " d" )
363+ try {
364+ // root/a/../a/./b/../../c/./d -> root/c/d
365+ assertEquals(SystemFileSystem .resolve(tgt), SystemFileSystem .resolve(src))
366+ } finally {
367+ // TODO: remove as soon as recursive file removal is implemented
368+ SystemFileSystem .delete(Path (root, " a" , " b" ))
369+ SystemFileSystem .delete(Path (root, " a" ))
370+ SystemFileSystem .delete(Path (root, " c" , " d" ))
371+ SystemFileSystem .delete(Path (root, " c" ))
372+ }
340373 }
341374
342375 private fun constructAbsolutePath (vararg parts : String ): String {
0 commit comments