[Haskell-cafe] Replacing IO with pure values

Corentin Dupont corentin.dupont at gmail.com
Mon Nov 24 16:25:13 UTC 2014


This Stackoverflow give a lot of hints:
http://stackoverflow.com/questions/7370073/testing-functions-in-haskell-that-do-io

You cannot "Unit" test functions that performs, because by definition a
unit test is about testing an isolated piece of code that give the same
result for the same input, i.e. pure.
In my programs I separate the non-IO parts for the IO parts, so that I can
test the non-IO parts.
The IO parts are mainly the GUI parts of my apps, which I test manually.

Now it should be possible to trick the IO monad by supplying always the
same user input to your function, but I don't know how to do that.



On Mon, Nov 24, 2014 at 4:22 PM, martin <martin.drautzburg at web.de> wrote:

> Hello all,
>
> in order to nail down my problem state in "Replacing the world in a State
> Machine with IO", I'd like to answer a much
> simpler question:
>
> If I have function which reads IO and I want to test this function by
> passing it a series of pure values, how would I do
> this? I suppose I can do this by splitting my function in two, such that
> the outer function does IO and the inner is a
> pure function. Is there any other way?
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20141124/cf4291d6/attachment.html>


More information about the Haskell-Cafe mailing list