[Haskell-cafe] [newbie] How to test this function?
Donald Bruce Stewart
dons at cse.unsw.edu.au
Thu Sep 21 00:55:55 EDT 2006
> > Second, I want to test this function, without hitting the filesystem. In
> > C++ I would use a istringstream. I couldn't find a function that returns
> > a Handle from a String. The closer thing that may work that I could find
> > was making a pipe and convertind the file descriptor. Can I simplify that
> > function to take it out of the IO monad? How? I thought about
> > getContents, but that eats all input.
Oh, another thing to check would be that the correct characters are
returned, such as:
*A> quickCheck (\s -> all (`elem` ['a'..'e']) (take5 s))
OK, passed 100 tests.
So for all strings QuickCheck produced, all Chars in the string returned
by take5 where elements of ['a'..'e'].
More information about the Haskell-Cafe