feat[test]: roundtrips, test for read <-> show
This commit is contained in:
parent
8181113bfe
commit
60762c3493
2 changed files with 31 additions and 0 deletions
24
test/Test/Data/Map/Implicit.hs
Normal file
24
test/Test/Data/Map/Implicit.hs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
{-# LANGUAGE TypeApplications #-}
|
||||||
|
module Test.Data.Map.Implicit (prop_readShowIdentityRoundtrip, prop_readShowMaybeRoundtrip, runTests) where
|
||||||
|
import Test.QuickCheck.Roundtrip (roundtrips)
|
||||||
|
import Text.Show (show)
|
||||||
|
import Text.Read (read)
|
||||||
|
import Data.Map.Implicit (ImplicitMap)
|
||||||
|
import Data.Bool (Bool)
|
||||||
|
import Language.Scalie.Ast.Definition (Definition)
|
||||||
|
import Data.Functor.Identity (Identity)
|
||||||
|
import Test.QuickCheck.All (quickCheckAll)
|
||||||
|
import System.IO (IO)
|
||||||
|
import Control.Applicative (pure)
|
||||||
|
import Data.Maybe (Maybe)
|
||||||
|
|
||||||
|
prop_readShowIdentityRoundtrip :: ImplicitMap (Definition Identity) -> Bool
|
||||||
|
prop_readShowIdentityRoundtrip = roundtrips read show
|
||||||
|
|
||||||
|
prop_readShowMaybeRoundtrip :: ImplicitMap (Definition Maybe) -> Bool
|
||||||
|
prop_readShowMaybeRoundtrip = roundtrips read show
|
||||||
|
|
||||||
|
pure []
|
||||||
|
runTests :: IO Bool
|
||||||
|
runTests = $quickCheckAll
|
7
test/Test/QuickCheck/Roundtrip.hs
Normal file
7
test/Test/QuickCheck/Roundtrip.hs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{-# LANGUAGE Safe #-}
|
||||||
|
module Test.QuickCheck.Roundtrip (roundtrips) where
|
||||||
|
import Data.Eq ((==), Eq)
|
||||||
|
import Data.Bool (Bool)
|
||||||
|
|
||||||
|
roundtrips :: Eq t1 => (t2 -> t1) -> (t1 -> t2) -> t1 -> Bool
|
||||||
|
roundtrips back forth x = x == back (forth x)
|
Loading…
Add table
Add a link
Reference in a new issue