urbit-hob

Haskell utilities for phonemic base wrangling.
git clone git://git.jtobin.io/urbit-hob.git
Log | Files | Refs | README | LICENSE

Property.hs (1141B)


      1 
      2 module Title.Tests.Property (
      3   tests
      4   ) where
      5 
      6 import Data.Word (Word8, Word16, Word32, Word64)
      7 import Test.Hspec
      8 import Test.QuickCheck
      9 import Urbit.Ob.Co (Patp)
     10 import qualified Urbit.Ob.Co as Co
     11 import qualified Urbit.Ob.Title as Title
     12 
     13 galaxies :: Gen Patp
     14 galaxies = fmap (Co.patp . fromIntegral) (arbitrary :: Gen Word8)
     15 
     16 stars :: Gen Patp
     17 stars = do
     18   star <- arbitrary `suchThat` (> (0xFF :: Word16))
     19   return (Co.patp (fromIntegral star))
     20 
     21 planets :: Gen Patp
     22 planets = do
     23   planet <- arbitrary `suchThat` (> (0xFFFF :: Word32))
     24   return (Co.patp (fromIntegral planet))
     25 
     26 moons :: Gen Patp
     27 moons = do
     28   moon <- arbitrary `suchThat` (> (0xFFFFFFFF :: Word64))
     29   return (Co.patp (fromIntegral moon))
     30 
     31 tests :: Spec
     32 tests =
     33   describe "clan" $ do
     34     it "identifies galaxies correctly" $
     35       forAll galaxies $ \x -> Title.clan x == Title.Galaxy
     36 
     37     it "identifies stars correctly" $
     38       forAll stars $ \x -> Title.clan x == Title.Star
     39 
     40     it "identifies planets correctly" $
     41       forAll planets $ \x -> Title.clan x == Title.Planet
     42 
     43     it "identifies moons correctly" $
     44       forAll moons $ \x -> Title.clan x == Title.Moon
     45