[Haskell-cafe] Test command line programs
aslatter at gmail.com
Tue Oct 26 17:32:10 EDT 2010
On Tue, Oct 26, 2010 at 11:11 AM, Dupont Corentin
<corentin.dupont at gmail.com> wrote:
> Hello again café,
> I have a command line program that takes input from various handles
> (actually network sockets) like this:
>> s <- hGetLine h
> I'd like to unit test this. How can I do?
> I'd like to inject data on the handle so that all the input chain is tested.
I haven't tested it yet, but this "mock handle" will eventually work in GHC 7:
At least, the bug report about how it didn't work has now been closed :-)
I don't remember which operations worked and which didn't - getChar
would work, but getContents would fail.
The others have great advice, that you should try to isolate the logic
of your code from IO for precisely this reason - so it is easily
More information about the Haskell-Cafe