blob: b9550c0faf660ed3217108b984410ac3c0b4ae5c (
plain)
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
|
{-# LANGUAGE TemplateHaskell #-}
module Properties (
runTests
) where
import Data.Maybe (fromJust)
import Error.Base (unwrap)
import Evaluator (eval)
import Operators (primitives)
import Parser (Expr (..), parseLispValue, parseQuote)
import Test.QuickCheck
addition = fromJust $ lookup "+" primitives
multiplication = fromJust $ lookup "*" primitives
prop_commutativeAdd :: [Integer] -> Property
prop_commutativeAdd xs =
not (null xs) ==> rhs == lhs
where rhs = (unwrap . addition) exprs
lhs = (unwrap . addition . reverse) exprs
exprs = map IntLiteral xs
prop_commutativeMul :: [Integer] -> Property
prop_commutativeMul xs =
not (null xs) ==> rhs == lhs
where rhs = (unwrap . multiplication) exprs
lhs = (unwrap . multiplication . reverse) exprs
exprs = map IntLiteral xs
return []
runTests = $quickCheckAll
|