
16 Jan
2008
16 Jan
'08
6:50 p.m.
Don Stewart wrote:
I'd like some QuickCheck properties, so we can avoid the unlines . lines /= id fiasco. Given that, I'd support this too.
What is a good place to put those? I just ran some obvious tests from ghci:
test (\x y -> intercalate [x::Int] (split x y) == y) ] OK, passed 100 tests.
test (\p xs -> all (not . any p) (splitWith p xs :: [[Int]])) ] OK, passed 100 tests.
for the unbeliever:
test (\x y -> splitWith (==x) y == split (x::Int) y) ] OK, passed 100 tests.
to show lazyness:
split 'a' $ concat $ repeat "abcdefgh" ] ["","bcdefgh","bcdefgh","bcdefgh",...
split 'z' $ concat $ repeat "abcdefgh" ] ["abcdefghabcdefghabcdefghabcdefgh...
Fiasco avoided :) Twan