[commit: ghc] wip/nfs-locking: Add tests for matchVersionedFilePath. (0b68ae8)
git at git.haskell.org
git at git.haskell.org
Fri Oct 27 00:03:51 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/nfs-locking
Link : http://ghc.haskell.org/trac/ghc/changeset/0b68ae8b754a400577dbd05e646764742251ec27/ghc
>---------------------------------------------------------------
commit 0b68ae8b754a400577dbd05e646764742251ec27
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date: Tue Feb 16 19:26:37 2016 +0000
Add tests for matchVersionedFilePath.
>---------------------------------------------------------------
0b68ae8b754a400577dbd05e646764742251ec27
src/Base.hs | 1 +
src/Rules/Selftest.hs | 13 ++++++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/Base.hs b/src/Base.hs
index a794ea8..372ec78 100644
--- a/src/Base.hs
+++ b/src/Base.hs
@@ -183,6 +183,7 @@ removeDirectoryIfExists d =
-- comprising digits (@0-9@), dashes (@-@), and dots (@.@). Examples:
--
--- * @'matchVersionedFilePath' "foo/bar" ".a" "foo/bar.a" '==' 'True'@
+--- * @'matchVersionedFilePath' "foo/bar" ".a" "foo\bar.a" '==' 'True'@
--- * @'matchVersionedFilePath' "foo/bar" "a" "foo/bar.a" '==' 'True'@
--- * @'matchVersionedFilePath' "foo/bar" "" "foo/bar.a" '==' 'False'@
--- * @'matchVersionedFilePath' "foo/bar" "a" "foo/bar-0.1.a" '==' 'True'@
diff --git a/src/Rules/Selftest.hs b/src/Rules/Selftest.hs
index a3cc089..5fafda5 100644
--- a/src/Rules/Selftest.hs
+++ b/src/Rules/Selftest.hs
@@ -3,8 +3,10 @@
module Rules.Selftest (selftestRules) where
import Development.Shake
-import Settings.Builders.Ar (chunksOfSize)
import Test.QuickCheck
+
+import Base
+import Settings.Builders.Ar (chunksOfSize)
import Way
instance Arbitrary Way where
@@ -22,6 +24,15 @@ selftestRules =
in concat res == xs && all (\r -> length r == 1 || length (concat r) <= n) res
test $ chunksOfSize 3 ["a","b","c","defg","hi","jk"] == [["a","b","c"],["defg"],["hi"],["jk"]]
+ test $ matchVersionedFilePath "foo/bar" ".a" "foo/bar.a" == True
+ test $ matchVersionedFilePath "foo/bar" ".a" "foo\\bar.a" == True
+ test $ matchVersionedFilePath "foo/bar" "a" "foo/bar.a" == True
+ test $ matchVersionedFilePath "foo/bar" "" "foo/bar.a" == False
+ test $ matchVersionedFilePath "foo/bar" "a" "foo/bar-0.1.a" == True
+ test $ matchVersionedFilePath "foo/bar-" "a" "foo/bar-0.1.a" == True
+ test $ matchVersionedFilePath "foo/bar/" "a" "foo/bar-0.1.a" == False
+
+ -- TODO: add automated tests for matchVersionedFilePath too
test :: Testable a => a -> Action ()
test = liftIO . quickCheck
More information about the ghc-commits
mailing list