-
Notifications
You must be signed in to change notification settings - Fork 0
/
TypesTests.hs
64 lines (45 loc) · 2.95 KB
/
TypesTests.hs
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import Roller.Types
import Control.Applicative
import Data.Word
import Test.QuickCheck
main :: IO ()
main = do
print $ "Verify show DieTerm."
quickCheck prop_ShowDieTerm
print $ "Verify show AddedDieTerm."
quickCheck prop_ShowAddedDieTerm
print $ "Verify show SubtractedDieTerm."
quickCheck prop_ShowSubtractedDieTerm
print $ "Verify show ConstantTerm."
quickCheck prop_ShowConstantTerm
print $ "Verify show AddedConstantTerm."
quickCheck prop_ShowAddedConstantTerm
print $ "Verify show SubtractedConstantTerm."
quickCheck prop_ShowSubtractedConstantTerm
prop_ShowDieTerm :: CorrectNumberOfDiceGenerator -> CorrectNumberOfFacesOfEachDieGenerator -> Bool
prop_ShowDieTerm (CorrectNumberOfDiceGenerator x) (CorrectNumberOfFacesOfEachDieGenerator y) =
show (constructDieTerm x y) == show x ++ show dieSymbol ++ show y
prop_ShowAddedDieTerm :: CorrectNumberOfDiceGenerator -> CorrectNumberOfFacesOfEachDieGenerator -> Bool
prop_ShowAddedDieTerm (CorrectNumberOfDiceGenerator x) (CorrectNumberOfFacesOfEachDieGenerator y) =
show (constructAddedDieTerm x y) == show additionSymbol ++ show x ++ show dieSymbol ++ show y
prop_ShowSubtractedDieTerm :: CorrectNumberOfDiceGenerator -> CorrectNumberOfFacesOfEachDieGenerator -> Bool
prop_ShowSubtractedDieTerm (CorrectNumberOfDiceGenerator x) (CorrectNumberOfFacesOfEachDieGenerator y) =
show (constructSubtractedDieTerm x y) == show subtractionSymbol ++ show x ++ show dieSymbol ++ show y
prop_ShowConstantTerm :: CorrectConstatntGenerator -> Bool
prop_ShowConstantTerm (CorrectConstatntGenerator x) = show (constructConstantTerm x) == show x
prop_ShowAddedConstantTerm :: CorrectConstatntGenerator -> Bool
prop_ShowAddedConstantTerm (CorrectConstatntGenerator x) = show (constructAddedConstantTerm x) == show additionSymbol ++ show x
prop_ShowSubtractedConstantTerm :: CorrectConstatntGenerator -> Bool
prop_ShowSubtractedConstantTerm (CorrectConstatntGenerator x) = show (constructSubtractedConstantTerm x) == show subtractionSymbol ++ show x
newtype CorrectNumberOfDiceGenerator = CorrectNumberOfDiceGenerator NumberOfDice deriving Show
instance Arbitrary CorrectNumberOfDiceGenerator where arbitrary = CorrectNumberOfDiceGenerator <$> generateCorrectNumberOfDice
generateCorrectNumberOfDice :: Gen Word8
generateCorrectNumberOfDice = elements [0 .. 99]
newtype CorrectNumberOfFacesOfEachDieGenerator = CorrectNumberOfFacesOfEachDieGenerator NumberOfFacesOfEachDie deriving Show
instance Arbitrary CorrectNumberOfFacesOfEachDieGenerator where arbitrary = CorrectNumberOfFacesOfEachDieGenerator <$> generateCorrectNumberOfFacesOfEachDie
generateCorrectNumberOfFacesOfEachDie :: Gen Word8
generateCorrectNumberOfFacesOfEachDie = elements [0 .. 99]
newtype CorrectConstatntGenerator = CorrectConstatntGenerator Word8 deriving Show
instance Arbitrary CorrectConstatntGenerator where arbitrary = CorrectConstatntGenerator <$> generateCorrectConstant
generateCorrectConstant :: Gen Word8
generateCorrectConstant = elements [0 .. 99]