Property.hs (1125B)
1 2 module Ob.Tests.Property ( 3 tests 4 ) where 5 6 import Data.Word (Word32, Word64) 7 import Numeric.Natural (Natural) 8 import Test.Hspec 9 import Test.Hspec.Core.QuickCheck (modifyMaxSuccess) 10 import Test.QuickCheck 11 import qualified Urbit.Ob.Ob as Ob 12 13 planets :: Gen Word32 14 planets = arbitrary `suchThat` (> 0xFFFF) 15 16 word64 :: Gen Word64 17 word64 = arbitrary 18 19 nat :: Gen Natural 20 nat = do 21 a <- fmap fromIntegral word64 22 b <- fmap fromIntegral word64 23 return (a * b) 24 25 tests :: Spec 26 tests = do 27 describe "fynd" $ 28 modifyMaxSuccess (const 1000) $ 29 it "inverts fein" $ 30 forAll nat $ \x -> 31 Ob.fynd (Ob.fein x) == x 32 33 describe "fein" $ 34 modifyMaxSuccess (const 1000) $ 35 it "inverts fynd" $ 36 forAll nat $ \x -> 37 Ob.fein (Ob.fynd x) == x 38 39 describe "feis" $ 40 modifyMaxSuccess (const 1000) $ 41 it "inverts tail" $ 42 forAll planets $ \planet -> property $ 43 Ob.feis (Ob.tail planet) == planet 44 45 describe "tail" $ 46 modifyMaxSuccess (const 1000) $ 47 it "inverts feis" $ 48 forAll planets $ \planet -> property $ 49 Ob.tail (Ob.feis planet) == planet 50