Property.hs (1641B)
1 2 module Co.Tests.Property ( 3 tests 4 ) where 5 6 import qualified Data.Text as T 7 import Data.Word (Word64) 8 import Numeric.Natural (Natural) 9 import Test.Hspec 10 import Test.Hspec.Core.QuickCheck (modifyMaxSuccess) 11 import Test.QuickCheck 12 import qualified Urbit.Ob.Co as Co 13 14 nats :: Gen Natural 15 nats = fmap fromIntegral (arbitrary :: Gen Word64) 16 17 patps :: Gen Co.Patp 18 patps = fmap Co.patp nats 19 20 patqs :: Gen Co.Patq 21 patqs = fmap Co.patq nats 22 23 patpStrings :: Gen T.Text 24 patpStrings = fmap Co.renderPatp patps 25 26 patqStrings :: Gen T.Text 27 patqStrings = fmap Co.renderPatq patqs 28 29 tests :: Spec 30 tests = do 31 describe "fromPatp" $ 32 modifyMaxSuccess (const 1000) $ 33 it "inverts patp" $ 34 forAll nats $ \x -> Co.fromPatp (Co.patp x) == x 35 36 describe "patp" $ 37 modifyMaxSuccess (const 1000) $ 38 it "inverts fromPatp" $ 39 forAll patps $ \x -> Co.patp (Co.fromPatp x) == x 40 41 describe "renderPatp" $ 42 modifyMaxSuccess (const 1000) $ 43 it "inverts parsePatp" $ 44 forAll patpStrings $ \x -> 45 case Co.parsePatp x of 46 Left _ -> False 47 Right p -> Co.renderPatp p == x 48 49 describe "fromPatq" $ 50 modifyMaxSuccess (const 1000) $ 51 it "inverts patq" $ 52 forAll nats $ \x -> Co.fromPatq (Co.patq x) == x 53 54 describe "patq" $ 55 modifyMaxSuccess (const 1000) $ 56 it "inverts fromPatq" $ 57 forAll patqs $ \x -> Co.patq (Co.fromPatq x) == x 58 59 describe "renderPatq" $ 60 modifyMaxSuccess (const 1000) $ 61 it "inverts parsePatq" $ 62 forAll patqStrings $ \x -> 63 case Co.parsePatq x of 64 Left _ -> False 65 Right p -> Co.renderPatq p == x 66