software-engineering-amsterdam / ST2017_WG_12

0 stars 0 forks source link

Lab3: Ex 4 #6

Open BertLisser opened 7 years ago

BertLisser commented 7 years ago
-- 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 commented 7 years ago

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.