{-# LANGUAGE DeriveGeneric              #-}
{-# LANGUAGE DerivingStrategies         #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
{-# LANGUAGE StandaloneDeriving         #-}

{-# OPTIONS_GHC -Wno-orphans  #-}

module Test.Data.CDDL
  ( Any (..)
  , tests
  ) where

import Codec.CBOR.Term qualified as CBOR
import Codec.Serialise (Serialise (..), deserialise, serialise)
import Data.Bifunctor (bimap)

import GHC.Generics (Generic (..))

import Test.QuickCheck as QC
import Test.QuickCheck.Instances.ByteString ()
import Test.QuickCheck.Instances.Text ()

import Control.DeepSeq
import Test.Tasty
import Test.Tasty.QuickCheck (testProperty)

newtype Any = Any { Any -> Term
getAny :: CBOR.Term }
  deriving stock (Any -> Any -> Bool
(Any -> Any -> Bool) -> (Any -> Any -> Bool) -> Eq Any
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Any -> Any -> Bool
== :: Any -> Any -> Bool
$c/= :: Any -> Any -> Bool
/= :: Any -> Any -> Bool
Eq, Eq Any
Eq Any =>
(Any -> Any -> Ordering)
-> (Any -> Any -> Bool)
-> (Any -> Any -> Bool)
-> (Any -> Any -> Bool)
-> (Any -> Any -> Bool)
-> (Any -> Any -> Any)
-> (Any -> Any -> Any)
-> Ord Any
Any -> Any -> Bool
Any -> Any -> Ordering
Any -> Any -> Any
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Any -> Any -> Ordering
compare :: Any -> Any -> Ordering
$c< :: Any -> Any -> Bool
< :: Any -> Any -> Bool
$c<= :: Any -> Any -> Bool
<= :: Any -> Any -> Bool
$c> :: Any -> Any -> Bool
> :: Any -> Any -> Bool
$c>= :: Any -> Any -> Bool
>= :: Any -> Any -> Bool
$cmax :: Any -> Any -> Any
max :: Any -> Any -> Any
$cmin :: Any -> Any -> Any
min :: Any -> Any -> Any
Ord, Int -> Any -> ShowS
[Any] -> ShowS
Any -> String
(Int -> Any -> ShowS)
-> (Any -> String) -> ([Any] -> ShowS) -> Show Any
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Any -> ShowS
showsPrec :: Int -> Any -> ShowS
$cshow :: Any -> String
show :: Any -> String
$cshowList :: [Any] -> ShowS
showList :: [Any] -> ShowS
Show, (forall x. Any -> Rep Any x)
-> (forall x. Rep Any x -> Any) -> Generic Any
forall x. Rep Any x -> Any
forall x. Any -> Rep Any x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Any -> Rep Any x
from :: forall x. Any -> Rep Any x
$cto :: forall x. Rep Any x -> Any
to :: forall x. Rep Any x -> Any
Generic)
  deriving newtype [Any] -> Encoding
Any -> Encoding
(Any -> Encoding)
-> (forall s. Decoder s Any)
-> ([Any] -> Encoding)
-> (forall s. Decoder s [Any])
-> Serialise Any
forall s. Decoder s [Any]
forall s. Decoder s Any
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
$cencode :: Any -> Encoding
encode :: Any -> Encoding
$cdecode :: forall s. Decoder s Any
decode :: forall s. Decoder s Any
$cencodeList :: [Any] -> Encoding
encodeList :: [Any] -> Encoding
$cdecodeList :: forall s. Decoder s [Any]
decodeList :: forall s. Decoder s [Any]
Serialise

instance NFData CBOR.Term where
  rnf :: Term -> ()
rnf (CBOR.TBool Bool
x)     = Bool -> ()
forall a. NFData a => a -> ()
rnf Bool
x
  rnf (CBOR.TBytes ByteString
x)    = ByteString -> ()
forall a. NFData a => a -> ()
rnf ByteString
x
  rnf (CBOR.TBytesI ByteString
x)   = ByteString -> ()
forall a. NFData a => a -> ()
rnf ByteString
x
  rnf (CBOR.TDouble Double
x)   = Double -> ()
forall a. NFData a => a -> ()
rnf Double
x
  rnf (CBOR.TFloat Float
x)    = Float -> ()
forall a. NFData a => a -> ()
rnf Float
x
  rnf (CBOR.THalf Float
x)     = Float -> ()
forall a. NFData a => a -> ()
rnf Float
x
  rnf (CBOR.TInt Int
x)      = Int -> ()
forall a. NFData a => a -> ()
rnf Int
x
  rnf (CBOR.TInteger Integer
x)  = Integer -> ()
forall a. NFData a => a -> ()
rnf Integer
x
  rnf (CBOR.TList [Term]
x)     = [Term] -> ()
forall a. NFData a => a -> ()
rnf [Term]
x
  rnf (CBOR.TListI [Term]
x)    = [Term] -> ()
forall a. NFData a => a -> ()
rnf [Term]
x
  rnf (CBOR.TMap [(Term, Term)]
x)      = [(Term, Term)] -> ()
forall a. NFData a => a -> ()
rnf [(Term, Term)]
x
  rnf (CBOR.TMapI [(Term, Term)]
x)     = [(Term, Term)] -> ()
forall a. NFData a => a -> ()
rnf [(Term, Term)]
x
  rnf (CBOR.TSimple Word8
x)   = Word8 -> ()
forall a. NFData a => a -> ()
rnf Word8
x
  rnf (CBOR.TString Text
x)   = Text -> ()
forall a. NFData a => a -> ()
rnf Text
x
  rnf (CBOR.TStringI Text
x)  = Text -> ()
forall a. NFData a => a -> ()
rnf Text
x
  rnf (CBOR.TTagged Word64
x Term
y) = Word64 -> ()
forall a. NFData a => a -> ()
rnf Word64
x () -> () -> ()
forall a b. a -> b -> b
`seq` Term -> ()
forall a. NFData a => a -> ()
rnf Term
y
  rnf Term
CBOR.TNull         = ()

deriving instance NFData Any

instance Arbitrary Any where
    -- | Generate a subset of `CBOR.Term` for which `deserialise` is a left
    -- inverse of `serialise`.  `CBOR.Integer, `CBOR.Tagged`, `CBOR.Half` and
    -- `CBOR.Simple` are excluded.
    arbitrary :: Gen Any
arbitrary = [Gen Any] -> Gen Any
forall a. [Gen a] -> Gen a
oneof [ Term -> Any
Any (Term -> Any) -> (Int -> Term) -> Int -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Term
CBOR.TInt     (Int -> Any) -> Gen Int -> Gen Any
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Int
forall a. Arbitrary a => Gen a
arbitrary
                      , Term -> Any
Any (Term -> Any) -> (ByteString -> Term) -> ByteString -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Term
CBOR.TBytes   (ByteString -> Any) -> Gen ByteString -> Gen Any
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen ByteString
forall a. Arbitrary a => Gen a
arbitrary
                      , Term -> Any
Any (Term -> Any) -> (ByteString -> Term) -> ByteString -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Term
CBOR.TBytesI  (ByteString -> Any) -> Gen ByteString -> Gen Any
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen ByteString
forall a. Arbitrary a => Gen a
arbitrary
                      , Term -> Any
Any (Term -> Any) -> (Text -> Term) -> Text -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Term
CBOR.TString  (Text -> Any) -> Gen Text -> Gen Any
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Text
forall a. Arbitrary a => Gen a
arbitrary
                      , Term -> Any
Any (Term -> Any) -> (Text -> Term) -> Text -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Term
CBOR.TStringI (Text -> Any) -> Gen Text -> Gen Any
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Text
forall a. Arbitrary a => Gen a
arbitrary
                      , Term -> Any
Any (Term -> Any) -> ([Any] -> Term) -> [Any] -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Term] -> Term
CBOR.TList  ([Term] -> Term) -> ([Any] -> [Term]) -> [Any] -> Term
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Any -> Term) -> [Any] -> [Term]
forall a b. (a -> b) -> [a] -> [b]
map Any -> Term
getAny ([Any] -> Any) -> Gen [Any] -> Gen Any
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen [Any] -> Gen [Any]
forall {a}. Gen a -> Gen a
resized Gen [Any]
forall a. Arbitrary a => Gen a
arbitrary
                      , Term -> Any
Any (Term -> Any) -> ([Any] -> Term) -> [Any] -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Term] -> Term
CBOR.TListI ([Term] -> Term) -> ([Any] -> [Term]) -> [Any] -> Term
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Any -> Term) -> [Any] -> [Term]
forall a b. (a -> b) -> [a] -> [b]
map Any -> Term
getAny ([Any] -> Any) -> Gen [Any] -> Gen Any
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen [Any] -> Gen [Any]
forall {a}. Gen a -> Gen a
resized Gen [Any]
forall a. Arbitrary a => Gen a
arbitrary
                      , Term -> Any
Any (Term -> Any) -> ([(Any, Any)] -> Term) -> [(Any, Any)] -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Term, Term)] -> Term
CBOR.TMap   ([(Term, Term)] -> Term)
-> ([(Any, Any)] -> [(Term, Term)]) -> [(Any, Any)] -> Term
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Any, Any) -> (Term, Term)) -> [(Any, Any)] -> [(Term, Term)]
forall a b. (a -> b) -> [a] -> [b]
map ((Any -> Term) -> (Any -> Term) -> (Any, Any) -> (Term, Term)
forall a b c d. (a -> b) -> (c -> d) -> (a, c) -> (b, d)
forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap Any -> Term
getAny Any -> Term
getAny) ([(Any, Any)] -> Any) -> Gen [(Any, Any)] -> Gen Any
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen [(Any, Any)] -> Gen [(Any, Any)]
forall {a}. Gen a -> Gen a
resized Gen [(Any, Any)]
forall a. Arbitrary a => Gen a
arbitrary
                      , Term -> Any
Any (Term -> Any) -> ([(Any, Any)] -> Term) -> [(Any, Any)] -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Term, Term)] -> Term
CBOR.TMapI  ([(Term, Term)] -> Term)
-> ([(Any, Any)] -> [(Term, Term)]) -> [(Any, Any)] -> Term
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Any, Any) -> (Term, Term)) -> [(Any, Any)] -> [(Term, Term)]
forall a b. (a -> b) -> [a] -> [b]
map ((Any -> Term) -> (Any -> Term) -> (Any, Any) -> (Term, Term)
forall a b c d. (a -> b) -> (c -> d) -> (a, c) -> (b, d)
forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap Any -> Term
getAny Any -> Term
getAny) ([(Any, Any)] -> Any) -> Gen [(Any, Any)] -> Gen Any
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen [(Any, Any)] -> Gen [(Any, Any)]
forall {a}. Gen a -> Gen a
resized Gen [(Any, Any)]
forall a. Arbitrary a => Gen a
arbitrary
                      , Term -> Any
Any (Term -> Any) -> (Bool -> Term) -> Bool -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Term
CBOR.TBool    (Bool -> Any) -> Gen Bool -> Gen Any
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Bool
forall a. Arbitrary a => Gen a
arbitrary
                      , Any -> Gen Any
forall a. a -> Gen a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Term -> Any
Any Term
CBOR.TNull)
                      , Term -> Any
Any (Term -> Any) -> (Float -> Term) -> Float -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Float -> Term
CBOR.TFloat   (Float -> Any) -> Gen Float -> Gen Any
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Float
forall a. Arbitrary a => Gen a
arbitrary
                      , Term -> Any
Any (Term -> Any) -> (Double -> Term) -> Double -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Term
CBOR.TDouble  (Double -> Any) -> Gen Double -> Gen Any
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Double
forall a. Arbitrary a => Gen a
arbitrary
                      ]
      where
        resized :: Gen a -> Gen a
resized Gen a
gen = (Int -> Gen a) -> Gen a
forall a. (Int -> Gen a) -> Gen a
sized ((Int -> Gen a) -> Gen a) -> (Int -> Gen a) -> Gen a
forall a b. (a -> b) -> a -> b
$ \Int
s -> Int -> Gen a -> Gen a
forall a. Int -> Gen a -> Gen a
resize (Int
s Int -> Int -> Int
forall a. Integral a => a -> a -> a
`div` Int
4 Int -> Int -> Int
forall a. Ord a => a -> a -> a
`min` Int
8) Gen a
gen

    shrink :: Any -> [Any]
shrink (Any Term
term) =
      case Term
term of
        CBOR.TInt Int
a      -> Term -> Any
Any (Term -> Any) -> (Int -> Term) -> Int -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Term
CBOR.TInt       (Int -> Any) -> [Int] -> [Any]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> [Int]
forall a. Arbitrary a => a -> [a]
shrink Int
a
        CBOR.TBytes ByteString
a    -> Term -> Any
Any (Term -> Any) -> (ByteString -> Term) -> ByteString -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Term
CBOR.TBytes     (ByteString -> Any) -> [ByteString] -> [Any]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> [ByteString]
forall a. Arbitrary a => a -> [a]
shrink ByteString
a
        CBOR.TBytesI ByteString
a   -> Term -> Any
Any (Term -> Any) -> (ByteString -> Term) -> ByteString -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Term
CBOR.TBytesI    (ByteString -> Any) -> [ByteString] -> [Any]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> [ByteString]
forall a. Arbitrary a => a -> [a]
shrink ByteString
a
        CBOR.TString Text
a   -> Term -> Any
Any (Term -> Any) -> (Text -> Term) -> Text -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Term
CBOR.TString    (Text -> Any) -> [Text] -> [Any]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> [Text]
forall a. Arbitrary a => a -> [a]
shrink Text
a
        CBOR.TStringI Text
a  -> Term -> Any
Any (Term -> Any) -> (Text -> Term) -> Text -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Term
CBOR.TStringI   (Text -> Any) -> [Text] -> [Any]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> [Text]
forall a. Arbitrary a => a -> [a]
shrink Text
a
        CBOR.TList [Term]
a     -> Term -> Any
Any (Term -> Any) -> ([Any] -> Term) -> [Any] -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Term] -> Term
CBOR.TList  ([Term] -> Term) -> ([Any] -> [Term]) -> [Any] -> Term
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Any -> Term) -> [Any] -> [Term]
forall a b. (a -> b) -> [a] -> [b]
map Any -> Term
getAny ([Any] -> Any) -> [[Any]] -> [Any]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Any] -> [[Any]]
forall a. Arbitrary a => a -> [a]
shrink ((Term -> Any) -> [Term] -> [Any]
forall a b. (a -> b) -> [a] -> [b]
map Term -> Any
Any [Term]
a)
        CBOR.TListI [Term]
a    -> Term -> Any
Any (Term -> Any) -> ([Any] -> Term) -> [Any] -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Term] -> Term
CBOR.TListI ([Term] -> Term) -> ([Any] -> [Term]) -> [Any] -> Term
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Any -> Term) -> [Any] -> [Term]
forall a b. (a -> b) -> [a] -> [b]
map Any -> Term
getAny ([Any] -> Any) -> [[Any]] -> [Any]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Any] -> [[Any]]
forall a. Arbitrary a => a -> [a]
shrink ((Term -> Any) -> [Term] -> [Any]
forall a b. (a -> b) -> [a] -> [b]
map Term -> Any
Any [Term]
a)
        CBOR.TMap [(Term, Term)]
a      -> Term -> Any
Any (Term -> Any) -> ([(Any, Any)] -> Term) -> [(Any, Any)] -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Term, Term)] -> Term
CBOR.TMap   ([(Term, Term)] -> Term)
-> ([(Any, Any)] -> [(Term, Term)]) -> [(Any, Any)] -> Term
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Any, Any) -> (Term, Term)) -> [(Any, Any)] -> [(Term, Term)]
forall a b. (a -> b) -> [a] -> [b]
map ((Any -> Term) -> (Any -> Term) -> (Any, Any) -> (Term, Term)
forall a b c d. (a -> b) -> (c -> d) -> (a, c) -> (b, d)
forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap Any -> Term
getAny Any -> Term
getAny)
                        ([(Any, Any)] -> Any) -> [[(Any, Any)]] -> [Any]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Any, Any)] -> [[(Any, Any)]]
forall a. Arbitrary a => a -> [a]
shrink ((Term -> Any) -> (Term -> Any) -> (Term, Term) -> (Any, Any)
forall a b c d. (a -> b) -> (c -> d) -> (a, c) -> (b, d)
forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap Term -> Any
Any Term -> Any
Any ((Term, Term) -> (Any, Any)) -> [(Term, Term)] -> [(Any, Any)]
forall a b. (a -> b) -> [a] -> [b]
`map` [(Term, Term)]
a)
        CBOR.TMapI [(Term, Term)]
a     -> Term -> Any
Any (Term -> Any) -> ([(Any, Any)] -> Term) -> [(Any, Any)] -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Term, Term)] -> Term
CBOR.TMapI  ([(Term, Term)] -> Term)
-> ([(Any, Any)] -> [(Term, Term)]) -> [(Any, Any)] -> Term
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Any, Any) -> (Term, Term)) -> [(Any, Any)] -> [(Term, Term)]
forall a b. (a -> b) -> [a] -> [b]
map ((Any -> Term) -> (Any -> Term) -> (Any, Any) -> (Term, Term)
forall a b c d. (a -> b) -> (c -> d) -> (a, c) -> (b, d)
forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap Any -> Term
getAny Any -> Term
getAny)
                        ([(Any, Any)] -> Any) -> [[(Any, Any)]] -> [Any]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Any, Any)] -> [[(Any, Any)]]
forall a. Arbitrary a => a -> [a]
shrink ((Term -> Any) -> (Term -> Any) -> (Term, Term) -> (Any, Any)
forall a b c d. (a -> b) -> (c -> d) -> (a, c) -> (b, d)
forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap Term -> Any
Any Term -> Any
Any ((Term, Term) -> (Any, Any)) -> [(Term, Term)] -> [(Any, Any)]
forall a b. (a -> b) -> [a] -> [b]
`map` [(Term, Term)]
a)
        CBOR.TBool Bool
a     -> Term -> Any
Any (Term -> Any) -> (Bool -> Term) -> Bool -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Term
CBOR.TBool      (Bool -> Any) -> [Bool] -> [Any]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Bool -> [Bool]
forall a. Arbitrary a => a -> [a]
shrink Bool
a
        Term
CBOR.TNull       -> []
        CBOR.TFloat Float
a    -> Term -> Any
Any (Term -> Any) -> (Float -> Term) -> Float -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Float -> Term
CBOR.TFloat  (Float -> Any) -> [Float] -> [Any]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Float -> [Float]
forall a. Arbitrary a => a -> [a]
shrink Float
a
        CBOR.TDouble Double
a   -> Term -> Any
Any (Term -> Any) -> (Double -> Term) -> Double -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Term
CBOR.TDouble (Double -> Any) -> [Double] -> [Any]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Double -> [Double]
forall a. Arbitrary a => a -> [a]
shrink Double
a
        Term
_                -> []

instance CoArbitrary Any where
instance CoArbitrary CBOR.Term where
deriving instance Generic CBOR.Term


tests :: TestTree
tests :: TestTree
tests = String -> [TestTree] -> TestTree
testGroup String
"Test.Data.CDDL"
          [ String -> (Any -> Property) -> TestTree
forall a. Testable a => String -> a -> TestTree
testProperty String
"serialise Any"  Any -> Property
prop_serialise_any
          ]

prop_serialise_any :: Any -> Property
prop_serialise_any :: Any -> Property
prop_serialise_any Any
a = ByteString -> Any
forall a. Serialise a => ByteString -> a
deserialise (Any -> ByteString
forall a. Serialise a => a -> ByteString
serialise Any
a) Any -> Any -> Property
forall a. (Eq a, Show a) => a -> a -> Property
=== Any
a