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

Lab3: Ex 4 #6

Open
BertLisser opened this issue Sep 28, 2017 · 1 comment
Open

Lab3: Ex 4 #6

BertLisser opened this issue Sep 28, 2017 · 1 comment

Comments

@BertLisser
Copy link

BertLisser commented Sep 28, 2017

-- Generators for exercise 2 and 4 - By Michael {
formNProps :: Int -> Int -> Gen Form
formNProps maxProp 0 = liftM Prop (choose (1, maxProp))
formNProps maxProp n | n > 0 = oneof [liftM Prop (choose (1, maxProp)), liftM Neg subform,
                                      liftM Cnj (vectorOf 2 subform), liftM Dsj (vectorOf 2 subform),
                                      liftM2 Impl subform subform, liftM2 Equiv subform subform]
where subform = formNProps maxProp (n - 1)

You missed important test cases. Namely Dsj and Cnj with a list of variable length (the empty list included)

I have only looked at the quickCheck testing. The manually test random generation is difficult to follow, which all these cases.

Well done (=9)

@Oipo
Copy link
Contributor

Oipo commented Oct 2, 2017

The reason we (or more accurately, I) did not include variable lengths of Cnj and Dsj, is because anything more than 2 would make it grow explosively and make tests not finish within a couple minutes. Anything less than 2 would end up skewing the distribution of generated forms towards smaller forms, leading to forms with lower amounts of Properties. Lower amounts of Properties would lead to difficulties generating forms with a specific number of Properties when using n > 5 or so.

So the choices here are made by considering these pro's and cons: using Cnj and Dsj of exactly length 2 leads to a generator usable in more situations.

I guess we could have introduced a specific generator for small/empty Cnj and Dsj, but then the testing would become even more convoluted and disparate.

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

2 participants