I have type that derives Show.
It's useful for development & required for testing, but not necessary for my application's logic, so it does not require any testing.
I want to make HPC aware of that to get 100% coverage for my tests. Is there any way to exclude it?
A setting? a pragma? a test to trick it?
I tried seqing show but it didn't work at first (later it did and solved the issue, and I posted an answer, see it).
I also tried extending with CPP to use a macro condition that will exclude the Show just when testing, but quickCheckAll was not fond of that and I didn't even get through compilation (which is actually understandable in case of test-failure).
I eventually seqed all Show has to offer so GHC will see that I've been there, and acknowledge I've covered it.
The following covers it on my type:
prop_fieldShow :: (Show i, Show a) => Field i a -> Bool
prop_fieldShow field = showList [field] `seq` showsPrec 0 field `seq` show field `seq` True
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With