2021-06-19 16:42:32 +02:00
|
|
|
{-# LANGUAGE AllowAmbiguousTypes #-}
|
|
|
|
--------------------------------------------------------------------------------
|
2019-08-31 19:17:27 +02:00
|
|
|
module Test.Prelude
|
|
|
|
( module Xanthous.Prelude
|
|
|
|
, module Test.Tasty
|
|
|
|
, module Test.Tasty.HUnit
|
|
|
|
, module Test.Tasty.QuickCheck
|
2021-11-08 03:33:27 +01:00
|
|
|
, module Test.Tasty.Ingredients.Rerun
|
2019-08-31 19:17:27 +02:00
|
|
|
, module Test.QuickCheck.Classes
|
|
|
|
, testBatch
|
2021-06-19 16:42:32 +02:00
|
|
|
, jsonRoundTrip
|
2019-08-31 19:17:27 +02:00
|
|
|
) where
|
2021-06-19 16:42:32 +02:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
import Xanthous.Prelude hiding (assert, elements)
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
import Test.Tasty
|
|
|
|
import Test.Tasty.QuickCheck
|
|
|
|
import Test.Tasty.HUnit
|
2021-11-08 03:33:27 +01:00
|
|
|
import Test.Tasty.Ingredients.Rerun
|
2021-06-19 16:42:32 +02:00
|
|
|
import Test.QuickCheck.Classes
|
|
|
|
import Test.QuickCheck.Checkers (TestBatch, EqProp ((=-=)))
|
|
|
|
import Test.QuickCheck.Instances.ByteString ()
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
import qualified Data.Aeson as JSON
|
|
|
|
import Data.Aeson (ToJSON, FromJSON)
|
|
|
|
--------------------------------------------------------------------------------
|
2019-08-31 19:17:27 +02:00
|
|
|
|
|
|
|
testBatch :: TestBatch -> TestTree
|
|
|
|
testBatch (name, tests) = testGroup name $ uncurry testProperty <$> tests
|
2021-06-19 16:42:32 +02:00
|
|
|
|
|
|
|
jsonRoundTrip
|
|
|
|
:: forall a. (ToJSON a, FromJSON a, EqProp a, Arbitrary a, Show a) => TestTree
|
|
|
|
jsonRoundTrip = testProperty "JSON round trip" $ \(x :: a) ->
|
|
|
|
JSON.decode (JSON.encode x) =-= Just x
|