A question about GHC test coverage

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

A question about GHC test coverage

Richard A. O'Keefe
Step 1: write a module defining a data type.
Step 2: write a module with lots of QuickCheck tests for it.
Step 3: Compile with gcc -fhpc to get coverage data.
Step 4: run, find bugs, fix bugs, repeat from step 3.
Step 5: view coverage .html files, note functions not
        covered, add tests to step 2 file, repeat.
Step 6: Step back with a sigh of content.  Coverage high.

Step 7, some time later: encounter a bug in an untested function.

Why?  Because Step 1 includes

    instance Ord MyType
      where compare ... ... = ...

and the untested function was max.  The "inherited" definition
is of course fully consistent with compare, and comparison had
been tested because I thought of that, but there was an extra
requirement which need not detain us here.

My problem was that
(a) I was too dumb to think of writing tests for a function
    I hadn't written.
(b) Because I hadn't written max, 'hpc' didn't show it to me
    as something needing a test.

Obviously this was my fault:  if I have declared
   instance <some class> <my type>
it's my responsibility to test all of the functions in the
type-class.  But I might not actually *know* what all the
functions in the type-class are; Haskell does change from
time to type.  And being a bear of very little brain, I
could use some reminders "Hey, you've inherited this function
but not tested it".

Is that possible using ghc -hpc?



_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.