[Haskell-beginners] Using QuickCheck to verify that an expression can always be evaluated
daniel.is.fischer at googlemail.com
Fri Apr 15 15:46:00 CEST 2011
On Friday 15 April 2011 15:36:33, Amy de Buitléir wrote:
> Occasionally I write a QuickCheck test where I want to evaluate
> something just to make sure it doesn't crash, but I don't care about
> the actual value. For example, in the test below, I just want to make
> sure that the expression "foldl' apply newWorkbench gs" doesn't crash.
> I don't really care whether or not "devotion w /= -1", that's just an
> expression (which is always true) that I wrote to force evaluation of
> w. But I assume there's a better way to do this?
> prop_all_gene_sequences_are_legal :: [Gene] -> Property
> prop_all_gene_sequences_are_legal gs =
property $ w `seq` True
(replace seq with a stronger evaluation forcer if necessary)
> property $ devotion w /= -1
> where w = foldl' apply newWorkbench gs
> Thank you in advance for any suggestions.
More information about the Beginners