TESTS: add MyPrelude tests
This commit is contained in:
parent
b1ac2aa223
commit
f774a92dd6
@ -160,6 +160,7 @@ executable Test
|
||||
Parser.Meshparser
|
||||
Parser.PathParser
|
||||
QueueEx
|
||||
Test.MyPrelude
|
||||
Test.Vector
|
||||
|
||||
|
||||
|
43
Test/MyPrelude.hs
Normal file
43
Test/MyPrelude.hs
Normal 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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user