TESTS: add MyPrelude tests

This commit is contained in:
hasufell 2014-12-18 03:53:27 +01:00
parent b1ac2aa223
commit f774a92dd6
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
3 changed files with 49 additions and 0 deletions

View File

@ -160,6 +160,7 @@ executable Test
Parser.Meshparser
Parser.PathParser
QueueEx
Test.MyPrelude
Test.Vector

43
Test/MyPrelude.hs Normal file
View File

@ -0,0 +1,43 @@
{-# OPTIONS_HADDOCK ignore-exports #-}
{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-}
module Test.MyPrelude where
import MyPrelude
import Test.QuickCheck
splitByProp1 :: Positive Int
-> NonEmptyList (Positive Int)
-> NonEmptyList (Positive Int)
-> Bool
splitByProp1 (Positive x) (NonEmpty xs) (NonEmpty ys) =
splitBy (== negate x) (xs' ++ [negate x] ++ ys') == [xs', ys']
where
xs' = fmap getPositive xs
ys' = fmap getPositive ys
splitByProp2 :: Positive Int
-> NonEmptyList (Positive Int)
-> NonEmptyList (Positive Int)
-> Bool
splitByProp2 (Positive x) (NonEmpty xs) (NonEmpty ys) =
splitBy (== negate x) (xs' ++ [negate x] ++ ys' ++ [negate x] ++ xs')
==
[xs', ys', xs']
where
xs' = fmap getPositive xs
ys' = fmap getPositive ys
-- splitting by an element that is not in the list should leave the list
-- untouched
splitByProp3 :: Positive Int
-> NonEmptyList (Positive Int)
-> Bool
splitByProp3 (Positive x) (NonEmpty xs) =
splitBy (== negate x) xs' == [xs']
where
xs' = fmap getPositive xs

View File

@ -2,6 +2,7 @@
import Test.QuickCheck
import Test.MyPrelude
import Test.Vector
@ -51,3 +52,7 @@ main = do
putStrLn "testing det:"
deepCheck detProp1
deepCheck detProp2
putStrLn "testing splitBy"
deepCheck splitByProp1
deepCheck splitByProp2
deepCheck splitByProp3