1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
{-# LANGUAGE OverloadedStrings #-}
module Test.NatRepr
( natTests
)
where
import Hedgehog
import qualified Hedgehog.Gen as HG
import Hedgehog.Range
import Test.Tasty
import Test.Tasty.Hedgehog
import Data.Parameterized.NatRepr
import Data.Parameterized.Some
import GHC.TypeLits (natVal)
prop_withKnownNat :: Property
prop_withKnownNat = property $
do nInt <- forAll $ HG.int (linearBounded :: Range Int)
case someNat nInt of
Nothing -> diff nInt (<) 0
Just (Some r) -> nInt === withKnownNat r (fromEnum $ natVal r)
natTests :: IO TestTree
natTests = testGroup "Nat" <$> return
[ testPropertyNamed "withKnownNat" "prop_withKnownNat" prop_withKnownNat
]
|