{-# LANGUAGE ScopedTypeVariables #-}

module Test.Cardano.Ledger.Binary.PlainSpec (spec) where

import Cardano.Ledger.Binary.Plain
import Test.Cardano.Ledger.Binary.Arbitrary ()
import Test.Hspec
import Test.Hspec.QuickCheck

spec :: Spec
spec :: Spec
spec = do
  forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe String
"Plain" forall a b. (a -> b) -> a -> b
$ do
    forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop String
"decodeFullFromHexText . serializeAsHexText" forall a b. (a -> b) -> a -> b
$ \(Term
term :: Term) ->
      case forall a. FromCBOR a => Text -> Either DecoderError a
decodeFullFromHexText forall a b. (a -> b) -> a -> b
$ forall a. ToCBOR a => a -> Text
serializeAsHexText Term
term of
        Left DecoderError
err -> HasCallStack => String -> Expectation
expectationFailure forall a b. (a -> b) -> a -> b
$ String
"Unexpected hex rountrip error: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show DecoderError
err
        Right (Term
res :: Term) -> Term
res forall a. (HasCallStack, Show a, Eq a) => a -> a -> Expectation
`shouldBe` Term
term