[Haskell-beginners] test-framework

Mateusz Neumann mateusz at neumanny.net
Fri Jun 29 23:34:33 CEST 2012


On Fri, 29 Jun 2012 11:50:13 -0400
Michael Orlitzky <michael at orlitzky.com> wrote:

> On 06/29/12 03:58, Mateusz Neumann wrote:
> > On Fri, 29 Jun 2012 08:43:33 +0100
> > Lorenzo Bolla <lbolla at gmail.com> wrote:
> > 
> >> Are the examples in the package distribution of any help?
> >> https://github.com/batterseapower/test-framework/blob/master/example/Test/Framework/Example.lhs
> >>
> >> L.
> > 
> > I was thinking more about parametres set in Haskell code itself.
> > There is something like TestOptions
> > (http://hackage.haskell.org/packages/archive/test-framework/0.6/doc/html/Test-Framework-Options.html#t:TestOptions)
> > and RunnerOptions
> > (http://hackage.haskell.org/packages/archive/test-framework/0.6/doc/html/Test-Framework-Runners-Options.html)
> > but I do not find any examples of using them.  Similarly, I do not
> > know how to set them up.
> > 
> 
> Here's an example main function that also uses test-framework-doctest.
> 
> There's only one trick used: because TestOptions/RunnerOptions are
> instances of monoid, we can use "mempty" to get an empty set of
> options. This is a little more fun than creating an empty record by
> hand.
> 
> 
> main :: IO ()
> main = do
>   dt <- docTest ["src/Everything.hs"] ["-isrc"]
> 
>   let empty_test_opts = mempty :: TestOptions
>   let my_test_opts = empty_test_opts {
>     topt_maximum_generated_tests = Just 500
>   }
> 
>   let empty_runner_opts = mempty :: RunnerOptions
>   let my_runner_opts = empty_runner_opts {
>     ropt_test_options = Just my_test_opts
>   }
> 
>   defaultMainWithOpts ([dt] ++ tests) my_runner_opts

Thanks a lot.  That works just as I wanted it to do :)  Just for the
record, the relevant part of my code looks like this:

main :: IO ()
main = defaultMainWithOpts tests runnerOpts
  where
    testOpts = (mempty :: TestOptions)
        { topt_maximum_generated_tests = Just 500
        }
    runnerOpts = (mempty :: RunnerOptions)
        { ropt_test_options = Just testOpts
        }


> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
> 



-- 
Mateusz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 230 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120629/8e5324b6/attachment.pgp>


More information about the Beginners mailing list