@@ -5,7 +5,7 @@ import Prelude (Unit, Ordering(..), (==), ($), bind, negate, not, (/=), (&&))
55import Control.Monad.Eff (Eff )
66import Control.Monad.Eff.Console (CONSOLE , log )
77
8- import Data.Maybe (Maybe (..), isNothing )
8+ import Data.Maybe (Maybe (..), isNothing , maybe )
99import Data.String
1010
1111import Test.Assert (ASSERT , assert )
@@ -160,11 +160,19 @@ testString = do
160160 assert $ split (Pattern " d" ) " abc" == [" abc" ]
161161
162162 log " splitAt"
163- assert $ splitAt 1 " " == Nothing
164- assert $ splitAt 0 " a" == Just [" " , " a" ]
165- assert $ splitAt 1 " ab" == Just [" a" , " b" ]
166- assert $ splitAt 3 " aabcc" == Just [" aab" , " cc" ]
167- assert $ splitAt (-1 ) " abc" == Nothing
163+ let testSplitAt i str res =
164+ assert $ case splitAt i str of
165+ Nothing ->
166+ isNothing res
167+ Just { before, after } ->
168+ maybe false (\r ->
169+ r.before == before && r.after == after) res
170+
171+ testSplitAt 1 " " Nothing
172+ testSplitAt 0 " a" $ Just {before: " " , after: " a" }
173+ testSplitAt 1 " ab" $ Just {before: " a" , after: " b" }
174+ testSplitAt 3 " aabcc" $ Just {before: " aab" , after: " cc" }
175+ testSplitAt (-1 ) " abc" $ Nothing
168176
169177 log " toCharArray"
170178 assert $ toCharArray " " == []
0 commit comments