Skip to content
Snippets Groups Projects
Commit bcb4c5f8 authored by Joachim Breitner's avatar Joachim Breitner
Browse files

Test Distribution.Client.Dependency.Modular.PSQ.splits with QuickCheck

parent 7da27034
No related merge requests found
...@@ -177,7 +177,9 @@ Test-Suite unit-tests ...@@ -177,7 +177,9 @@ Test-Suite unit-tests
filepath, filepath,
test-framework, test-framework,
test-framework-hunit, test-framework-hunit,
test-framework-quickcheck2,
HUnit, HUnit,
QuickCheck (>= 2.5),
cabal-install, cabal-install,
Cabal Cabal
ghc-options: -Wall ghc-options: -Wall
......
...@@ -4,12 +4,11 @@ module UnitTests.Distribution.Client.Dependency.Modular.PSQ ( ...@@ -4,12 +4,11 @@ module UnitTests.Distribution.Client.Dependency.Modular.PSQ (
import Distribution.Client.Dependency.Modular.PSQ import Distribution.Client.Dependency.Modular.PSQ
import Test.Framework as TF (Test) import Test.Framework as TF (Test)
import Test.Framework.Providers.HUnit (testCase) import Test.Framework.Providers.QuickCheck2
import Test.HUnit (Assertion, assertEqual)
tests :: [TF.Test] tests :: [TF.Test]
tests = [ testCase "splitsAltImplementation" splitsTest tests = [ testProperty "splitsAltImplementation" splitsTest
] ]
-- | Original splits implementation -- | Original splits implementation
...@@ -19,12 +18,5 @@ splits' xs = ...@@ -19,12 +18,5 @@ splits' xs =
(PSQ []) (PSQ [])
(\ k v ys -> cons k (v, ys) (fmap (\ (w, zs) -> (w, cons k v zs)) (splits' ys))) (\ k v ys -> cons k (v, ys) (fmap (\ (w, zs) -> (w, cons k v zs)) (splits' ys)))
splitsTest :: Assertion splitsTest :: [(Int, Int)] -> Bool
splitsTest = do splitsTest psq = splits' (PSQ psq) == splits (PSQ psq)
assertEqual "" (splits' psq1) (splits psq1)
assertEqual "" (splits' psq2) (splits psq2)
assertEqual "" (splits' psq3) (splits psq3)
where
psq1 = PSQ [ (1,2), (3,4), (5,6), (7,8) ] :: PSQ Int Int
psq2 = PSQ [ (1,2) ] :: PSQ Int Int
psq3 = PSQ [] :: PSQ Int Int
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment