(base, ext) = splitExtension f
len = B.length ext
-{- This requires the first path to be absolute, and the
- - second path cannot contain ../ or ./
+{- This requires both paths to be absolute and normalized.
-
- On Windows, if the paths are on different drives,
- a relative path is not possible and the path is simply
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
--- /dev/null
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 1"""
+ date="2021-01-13T17:01:07Z"
+ content="""
+This is a pure test, and the filesystem does not affect it in any way.
+
+The test is slightly broken, in that when two paths
+are the same except slightly differently normalized (eg, "A" vs "A/"),
+it fails. Really not a great test overall, rewriting.
+"""]]