[commit: ghc] wip/nfs-locking: #146, add tests for chunksOfSize (d001140)
git at git.haskell.org
git at git.haskell.org
Fri Oct 27 00:07:28 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/nfs-locking
Link : http://ghc.haskell.org/trac/ghc/changeset/d001140948a06ae50475eb919010d192e37b3829/ghc
>---------------------------------------------------------------
commit d001140948a06ae50475eb919010d192e37b3829
Author: Neil Mitchell <ndmitchell at gmail.com>
Date: Mon Jan 11 11:06:54 2016 +0000
#146, add tests for chunksOfSize
>---------------------------------------------------------------
d001140948a06ae50475eb919010d192e37b3829
src/Settings/Builders/Ar.hs | 2 +-
src/Test.hs | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/Settings/Builders/Ar.hs b/src/Settings/Builders/Ar.hs
index fc43d45..8cf175f 100644
--- a/src/Settings/Builders/Ar.hs
+++ b/src/Settings/Builders/Ar.hs
@@ -1,4 +1,4 @@
-module Settings.Builders.Ar (arBuilderArgs, arCmd) where
+module Settings.Builders.Ar (arBuilderArgs, arCmd, chunksOfSize) where
import Base
import Expression
diff --git a/src/Test.hs b/src/Test.hs
index a55e6e6..6cbc557 100644
--- a/src/Test.hs
+++ b/src/Test.hs
@@ -6,6 +6,7 @@ module Test (testRules) where
import Way
import Development.Shake
import Test.QuickCheck
+import Settings.Builders.Ar(chunksOfSize)
instance Arbitrary Way where
arbitrary = wayFromUnits <$> arbitrary
@@ -17,6 +18,10 @@ testRules :: Rules ()
testRules =
phony "selftest" $ do
test $ \(x :: Way) -> read (show x) == x
+ test $ \n xs ->
+ let res = chunksOfSize n xs
+ 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 :: Testable a => a -> Action ()
More information about the ghc-commits
mailing list