rewrite prop_relPathDirToFileAbs_basics

This was not a good test, it broke the requirement that
relPathDirToFileAbs take absolute paths. And it failed when the two
input paths were eg, the same but differently normalized.

Replaced with some tests of the real basics of that function.
This commit is contained in:
Joey Hess 2021-01-13 13:21:15 -04:00
parent 6c8205a113
commit 99ba471209
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 21 additions and 11 deletions

View file

@ -35,16 +35,14 @@ prop_upFrom_basics tdir
p = fromRawFilePath <$> upFrom (toRawFilePath dir)
dir = fromTestableFilePath tdir
prop_relPathDirToFileAbs_basics :: TestableFilePath -> TestableFilePath -> Bool
prop_relPathDirToFileAbs_basics fromt tot
| from == to = null r
| otherwise = not (null r)
prop_relPathDirToFileAbs_basics :: TestableFilePath -> Bool
prop_relPathDirToFileAbs_basics pt = and
[ relPathDirToFileAbs p (p </> "bar") == "bar"
, relPathDirToFileAbs (p </> "bar") p == ".."
, relPathDirToFileAbs p p == ""
]
where
from = fromTestableFilePath fromt
to = fromTestableFilePath tot
r = fromRawFilePath $ relPathDirToFileAbs
(toRawFilePath from)
(toRawFilePath to)
p = pathSeparator `B.cons` toRawFilePath (fromTestableFilePath pt)
prop_relPathDirToFileAbs_regressionTest :: Bool
prop_relPathDirToFileAbs_regressionTest = same_dir_shortcurcuits_at_difference