Merge pull request #9 from magthe/ClarifyRelative

Clarify what limitations the RelX parsers have.
This commit is contained in:
Chris Done 2016-03-04 14:29:52 +01:00
commit 04fa5d3ea8
2 changed files with 9 additions and 0 deletions

View File

@ -104,6 +104,8 @@ parseAbsDir filepath =
-- | Get a location for a relative directory. Produces a normalized
-- path which always ends in a path separator.
--
-- Note that @filepath@ may contain any number of @./@ but may not consist solely of @./@. It also may not contain a single @..@ anywhere.
--
-- Throws: 'PathParseException'
--
parseRelDir :: MonadThrow m
@ -136,6 +138,8 @@ parseAbsFile filepath =
-- | Get a location for a relative file.
--
-- Note that @filepath@ may contain any number of @./@ but may not contain a single @..@ anywhere.
--
-- Throws: 'PathParseException'
--
parseRelFile :: MonadThrow m

View File

@ -150,12 +150,15 @@ parseRelDirSpec =
failing "~/"
failing "/"
failing "./"
failing "././"
failing "//"
failing "///foo//bar//mu/"
failing "///foo//bar////mu"
failing "///foo//bar/.//mu"
succeeding "foo.bak" (Path "foo.bak/")
succeeding "./foo" (Path "foo/")
succeeding "././foo" (Path "foo/")
succeeding "./foo/./bar" (Path "foo/bar/")
succeeding "foo//bar//mu//" (Path "foo/bar/mu/")
succeeding "foo//bar////mu" (Path "foo/bar/mu/")
succeeding "foo//bar/.//mu" (Path "foo/bar/mu/")
@ -193,6 +196,8 @@ parseRelFileSpec =
failing "///foo//bar/.//mu"
succeeding "foo.txt" (Path "foo.txt")
succeeding "./foo.txt" (Path "foo.txt")
succeeding "././foo.txt" (Path "foo.txt")
succeeding "./foo/./bar.txt" (Path "foo/bar.txt")
succeeding "foo//bar//mu.txt" (Path "foo/bar/mu.txt")
succeeding "foo//bar////mu.txt" (Path "foo/bar/mu.txt")
succeeding "foo//bar/.//mu.txt" (Path "foo/bar/mu.txt")