@@ -5,7 +5,7 @@ import Prelude (Unit, Ordering(..), (==), ($), bind, negate, not, (/=), (&&))
5
5
import Control.Monad.Eff (Eff )
6
6
import Control.Monad.Eff.Console (CONSOLE , log )
7
7
8
- import Data.Maybe (Maybe (..), isNothing )
8
+ import Data.Maybe (Maybe (..), isNothing , maybe )
9
9
import Data.String
10
10
11
11
import Test.Assert (ASSERT , assert )
@@ -160,11 +160,19 @@ testString = do
160
160
assert $ split (Pattern " d" ) " abc" == [" abc" ]
161
161
162
162
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
168
176
169
177
log " toCharArray"
170
178
assert $ toCharArray " " == []
0 commit comments