module System.DotFS.Test.Unit where
import System.DotFS.Test.Utility
import System.DotFS.Test.Tests
import Control.Monad
import Test.QuickCheck
import System.DotFS.Core.Datatypes
import Test.QuickCheck.Test
import System.Exit
runTests :: IO ()
runTests = $(mkChecks tests)
instance Arbitrary DFSExpr where
arbitrary = sized expr
where
expr n | n <= 0 = atom
| otherwise = oneof [ atom
, liftM2 UniOp unioperator subform
, liftM3 BiOp bioperator subform subform'
]
where
atom = oneof [ liftM Var (elements ["P", "Q", "R", "S"])
, liftM Prim arbitrary
]
subform = expr (n `div` 2)
subform' = expr (n `div` 4)
unioperator = elements [Not]
bioperator = elements [Add, Sub, Mul, Div, And, Or, Eq, LTOp, GTOp, GEQ, LEQ, NEQ]
instance Arbitrary Value where
arbitrary = oneof [ liftM VBool arbitrary
, liftM VInt arbitrary
, liftM VString arbitraryStr
]