A question about GHC test coverage

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?
participants (1)
-
ok@cs.otago.ac.nz