Merge branch 'testing' into Mapping
This commit is contained in:
commit
853c11b4df
@ -53,8 +53,8 @@ executable Pioneers
|
|||||||
|
|
||||||
test-suite QuickCheckTests
|
test-suite QuickCheckTests
|
||||||
type: exitcode-stdio-1.0
|
type: exitcode-stdio-1.0
|
||||||
hs-source-dirs: tests, src
|
hs-source-dirs: tests/Map, src
|
||||||
main-is: MainTestSuite.hs
|
main-is: MapTestSuite.hs
|
||||||
build-depends: base,
|
build-depends: base,
|
||||||
OpenGL >=2.9,
|
OpenGL >=2.9,
|
||||||
bytestring >=0.10,
|
bytestring >=0.10,
|
||||||
@ -78,5 +78,6 @@ test-suite QuickCheckTests
|
|||||||
attoparsec-binary >= 0.1,
|
attoparsec-binary >= 0.1,
|
||||||
QuickCheck,
|
QuickCheck,
|
||||||
test-framework,
|
test-framework,
|
||||||
|
test-framework-th,
|
||||||
test-framework-quickcheck2
|
test-framework-quickcheck2
|
||||||
Default-Language: Haskell2010
|
Default-Language: Haskell2010
|
||||||
|
@ -39,6 +39,3 @@ giveNeighbourhood mp n (a,b) = let ns = giveNeighbours mp (a,b) in
|
|||||||
-- removing duplicates in O(n log n), losing order and adding Ord requirement
|
-- removing duplicates in O(n log n), losing order and adding Ord requirement
|
||||||
remdups :: Ord a => [a] -> [a]
|
remdups :: Ord a => [a] -> [a]
|
||||||
remdups = map head . group . sort
|
remdups = map head . group . sort
|
||||||
|
|
||||||
prop_rd_idempot :: [Int] -> Bool
|
|
||||||
prop_rd_idempot xs = remdups xs == (remdups . remdups) xs
|
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
module Main where
|
|
||||||
|
|
||||||
import Test.Framework
|
|
||||||
import Test.Framework.Providers.QuickCheck2
|
|
||||||
|
|
||||||
import Map.Map
|
|
||||||
|
|
||||||
main :: IO ()
|
|
||||||
main = defaultMain tests
|
|
||||||
|
|
||||||
tests :: [Test]
|
|
||||||
tests =
|
|
||||||
[
|
|
||||||
testGroup "Map.Map"
|
|
||||||
[
|
|
||||||
testProperty "remdups idempotency" prop_rd_idempot
|
|
||||||
]
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
23
tests/Map/MapTestSuite.hs
Normal file
23
tests/Map/MapTestSuite.hs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
|
||||||
|
module Main where
|
||||||
|
|
||||||
|
import Test.QuickCheck
|
||||||
|
|
||||||
|
import Test.Framework
|
||||||
|
import Test.Framework.TH
|
||||||
|
import Test.Framework.Providers.QuickCheck2
|
||||||
|
|
||||||
|
import Map.Map
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = $(defaultMainGenerator)
|
||||||
|
|
||||||
|
prop_rd_idempot :: [Int] -> Bool
|
||||||
|
prop_rd_idempot xs = remdups xs == (remdups . remdups) xs
|
||||||
|
|
||||||
|
prop_rd_length :: [Int] -> Bool
|
||||||
|
prop_rd_length xs = length (remdups xs) <= length xs
|
||||||
|
|
||||||
|
prop_rd_sorted :: [Int] -> Property
|
||||||
|
prop_rd_sorted xs = (not . null) xs ==> head (remdups xs) == minimum xs
|
Loading…
Reference in New Issue
Block a user