{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} module Test.Cardano.Ledger.ToolsSpec (spec) where import Cardano.Ledger.Tools import qualified Data.ByteString as BS import Test.Cardano.Ledger.Common import Test.QuickCheck.Instances.ByteString () spec :: Spec spec :: Spec spec = String -> Spec -> Spec forall a. HasCallStack => String -> SpecWith a -> SpecWith a describe String "Tools" (Spec -> Spec) -> Spec -> Spec forall a b. (a -> b) -> a -> b $ do String -> Gen Property -> Spec forall prop. (HasCallStack, Testable prop) => String -> prop -> Spec prop String "`integralToByteStringN . byteStringToNum` roundtrips" (Gen Property -> Spec) -> Gen Property -> Spec forall a b. (a -> b) -> a -> b $ do ByteString bs <- Gen ByteString forall a. Arbitrary a => Gen a arbitrary Property -> Gen Property forall a. a -> Gen a forall (f :: * -> *) a. Applicative f => a -> f a pure (Property -> Gen Property) -> Property -> Gen Property forall a b. (a -> b) -> a -> b $ Int -> Integer -> ByteString forall i. (Integral i, Bits i) => Int -> i -> ByteString integralToByteStringN (ByteString -> Int BS.length ByteString bs) (forall i. (Bits i, Num i) => ByteString -> i byteStringToNum @Integer ByteString bs) ByteString -> ByteString -> Property forall a. (Eq a, Show a) => a -> a -> Property === ByteString bs String -> Gen Property -> Spec forall prop. (HasCallStack, Testable prop) => String -> prop -> Spec prop String "`byteStringToNum . integralToByteStringN` roundtrips" (Gen Property -> Spec) -> Gen Property -> Spec forall a b. (a -> b) -> a -> b $ do Positive (Integer n :: Integer) <- Gen (Positive Integer) forall a. Arbitrary a => Gen a arbitrary Property -> Gen Property forall a. a -> Gen a forall (f :: * -> *) a. Applicative f => a -> f a pure (Property -> Gen Property) -> Property -> Gen Property forall a b. (a -> b) -> a -> b $ ByteString -> Integer forall i. (Bits i, Num i) => ByteString -> i byteStringToNum (Int -> Integer -> ByteString forall i. (Integral i, Bits i) => Int -> i -> ByteString integralToByteStringN Int 64 Integer n) Integer -> Integer -> Property forall a. (Eq a, Show a) => a -> a -> Property === Integer n