summaryrefslogtreecommitdiff
path: root/hadrian/src/Rules/Selftest.hs
diff options
context:
space:
mode:
Diffstat (limited to 'hadrian/src/Rules/Selftest.hs')
-rw-r--r--hadrian/src/Rules/Selftest.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/hadrian/src/Rules/Selftest.hs b/hadrian/src/Rules/Selftest.hs
index 68aa6e3889..b931f85ef6 100644
--- a/hadrian/src/Rules/Selftest.hs
+++ b/hadrian/src/Rules/Selftest.hs
@@ -13,6 +13,8 @@ import Settings
import Target
import Utilities
+import qualified System.FilePath.Posix as Posix ((</>))
+
instance Arbitrary Way where
arbitrary = wayFromUnits <$> arbitrary
@@ -31,6 +33,7 @@ selftestRules =
testLookupAll
testModuleName
testPackages
+ testPaths
testWay
testBuilder :: Action ()
@@ -111,3 +114,14 @@ testWay :: Action ()
testWay = do
putBuild "==== Read Way, Show Way"
test $ \(x :: Way) -> read (show x) == x
+
+testPaths :: Action ()
+testPaths = do
+ putBuild "==== Absolute, Relative Path Concatenation"
+ test $ forAll paths $ \(path1, path2) ->
+ path1 -/- path2 == path1 Posix.</> path2
+ where
+ paths = (,) <$> path <*> path
+ path = frequency [(1, relativePath), (1, absolutePath)]
+ relativePath = intercalate "/" <$> listOf1 (elements ["a"])
+ absolutePath = ('/':) <$> relativePath