vendredi 5 octobre 2018

doctest QuickCheck – can I import QC instances only in doctests?

I'm using doctest, and like the fact that I can test non-exported functions from where they're defined:

module Foo (frobnicate) where

-- |
-- >>> randomInt = 42
-- True
randomInt :: Int
randomInt = 42

I've so far kept QuickCheck instances in the test-suite so the library doesn't depend on testing packages, but this means I can't run QuickCheck from doctests.

I can of course not use doctest and run QC from test-suite, but then I have to export each function that I want to test.

Is there a way to have doctests that use QC instances without having the main library depend on QC, (and without re-writing the instances in the doctest "repl")?

Aucun commentaire:

Enregistrer un commentaire