Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lab 3: Ex. 4 #5

Open
BertLisser opened this issue Sep 27, 2017 · 0 comments
Open

Lab 3: Ex. 4 #5

BertLisser opened this issue Sep 27, 2017 · 0 comments

Comments

@BertLisser
Copy link

arbitrarySizedForm :: Int -> Gen Form
arbitrarySizedForm n
  | n <= 0    = do
    t  <- arbitrary
    return (Prop t)
  | n > 0     =  oneof [liftM Neg subForm,
         liftM Cnj subFormBracets,
         liftM Dsj subFormBracets,
         liftM2 Impl subForm subForm,
         liftM2 Equiv subForm subForm]
       where subForm        = arbitrarySizedForm (n `div` 2)
subFormBracets = listOf1 (arbitrarySizedForm (n `div` 4))

Better

arbitrarySizedForm :: Int -> Gen Form
arbitrarySizedForm n
  | n <= 0    = do
    t  <- arbitrary
    return (Prop t)
  | n > 0     =  oneof [liftM Neg subForm,
         liftM Cnj subFormBracets,
         liftM Dsj subFormBracets,
         liftM2 Impl subForm subForm,
         liftM2 Equiv subForm subForm]
       where subForm        = arbitrarySizedForm (n `div` 2)
subFormBracets = listOf (arbitrarySizedForm (n `div` 4))

Empty list of arguments at Cnj and Dsj are allowed.

quickCheck (withMaxSuccess 10 prop_checkEquiv)
quickCheck (withMaxSuccess 10 prop_checkCNF)

Better is

quickCheck (withMaxSize 5 prop_checkEquiv)
quickCheck (withMaxSize 5 prop_checkCNF)

This generates more tests with smaller samples.

Well done! (=9)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant