Skip to content

Commit 80ffb57

Browse files
committed
Update tests
1 parent 10b098b commit 80ffb57

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

test/Test/Data/List.purs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import Control.Monad.Eff (Eff)
66
import Control.Monad.Eff.Console (CONSOLE, log)
77

88
import Data.Foldable (foldMap, foldl)
9-
import Data.List (List(Nil, Cons), (..), length, range, foldM, unzip, zip, zipWithA, zipWith, intersectBy, intersect, (\\), deleteBy, delete, unionBy, union, nubBy, nub, groupBy, group', group, span, dropWhile, drop, takeWhile, take, sortBy, sort, catMaybes, mapMaybe, filterM, filter, concat, concatMap, reverse, alterAt, modifyAt, updateAt, deleteAt, insertAt, findLastIndex, findIndex, elemLastIndex, elemIndex, (!!), uncons, init, tail, last, head, insertBy, insert, snoc, null, singleton, fromFoldable, transpose, mapWithIndex, (:))
9+
import Data.List (List(..), (..), length, range, foldM, unzip, zip, zipWithA, zipWith, intersectBy, intersect, (\\), deleteBy, delete, unionBy, union, nubBy, nub, groupBy, group', group, span, dropWhile, drop, takeWhile, take, sortBy, sort, catMaybes, mapMaybe, filterM, filter, concat, concatMap, reverse, alterAt, modifyAt, updateAt, deleteAt, insertAt, findLastIndex, findIndex, elemLastIndex, elemIndex, (!!), uncons, init, tail, last, head, insertBy, insert, snoc, null, singleton, fromFoldable, transpose, mapWithIndex, (:))
1010
import Data.Maybe (Maybe(..), isNothing, fromJust)
11-
import Data.Monoid.Additive (Additive(Additive))
11+
import Data.Monoid.Additive (Additive(..))
12+
import Data.NonEmpty ((:|))
13+
import Data.NonEmpty as NE
1214
import Data.Tuple (Tuple(..))
1315
import Data.Unfoldable (replicate, replicateA, unfoldr)
1416

@@ -232,13 +234,13 @@ testList = do
232234
assert $ spanResult.rest == l [4, 5, 6, 7]
233235

234236
log "group should group consecutive equal elements into lists"
235-
assert $ group (l [1, 2, 2, 3, 3, 3, 1]) == l [l [1], l [2, 2], l [3, 3, 3], l [1]]
237+
assert $ group (l [1, 2, 2, 3, 3, 3, 1]) == l [NE.singleton 1, 2 :| l [2], 3 :| l [3, 3], NE.singleton 1]
236238

237239
log "group' should sort then group consecutive equal elements into lists"
238-
assert $ group' (l [1, 2, 2, 3, 3, 3, 1]) == l [l [1, 1], l [2, 2], l [3, 3, 3]]
240+
assert $ group' (l [1, 2, 2, 3, 3, 3, 1]) == l [1 :| l [1], 2 :| l [2], 3 :| l [3, 3]]
239241

240242
log "groupBy should group consecutive equal elements into lists based on an equivalence relation"
241-
assert $ groupBy (\x y -> odd x && odd y) (l [1, 1, 2, 2, 3, 3]) == l [l [1, 1], l [2], l [2], l [3, 3]]
243+
assert $ groupBy (\x y -> odd x && odd y) (l [1, 1, 2, 2, 3, 3]) == l [1 :| l [1], NE.singleton 2, NE.singleton 2, 3 :| l [3]]
242244

243245
log "nub should remove duplicate elements from the list, keeping the first occurence"
244246
assert $ nub (l [1, 2, 2, 3, 4, 1]) == l [1, 2, 3, 4]

test/Test/Data/List/Lazy.purs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ module Test.Data.List.Lazy (testListLazy) where
22

33
import Prelude
44

5+
import Control.Lazy (defer)
56
import Control.Monad.Eff (Eff)
67
import Control.Monad.Eff.Console (CONSOLE, log)
78

8-
import Math ((%))
99
import Data.List.Lazy (List, nil, cons, singleton, transpose, take, iterate, filter, uncons, foldM, range, unzip, zip, length, zipWithA, replicate, repeat, zipWith, intersectBy, intersect, deleteBy, delete, unionBy, union, nubBy, nub, groupBy, group, span, dropWhile, drop, takeWhile, slice, catMaybes, mapMaybe, filterM, concat, concatMap, reverse, alterAt, modifyAt, updateAt, deleteAt, insertAt, findLastIndex, findIndex, elemLastIndex, elemIndex, init, tail, last, head, insertBy, insert, snoc, null, replicateM, fromFoldable, (:), (\\), (!!))
1010
import Data.Maybe (Maybe(..), isNothing, fromJust)
11+
import Data.NonEmpty ((:|))
12+
import Data.NonEmpty as NE
1113
import Data.Tuple (Tuple(..))
12-
import Control.Lazy (defer)
1314

1415
import Partial.Unsafe (unsafePartial)
1516

@@ -222,13 +223,13 @@ testListLazy = do
222223
assert $ spanResult.rest == l [4, 5, 6, 7]
223224

224225
log "group should group consecutive equal elements into lists"
225-
assert $ group (l [1, 2, 2, 3, 3, 3, 1]) == l [l [1], l [2, 2], l [3, 3, 3], l [1]]
226+
assert $ group (l [1, 2, 2, 3, 3, 3, 1]) == l [NE.singleton 1, 2 :| l [2], 3 :| l [3, 3], NE.singleton 1]
226227

227228
-- log "group' should sort then group consecutive equal elements into lists"
228229
-- assert $ group' (l [1, 2, 2, 3, 3, 3, 1]) == l [l [1, 1], l [2, 2], l [3, 3, 3]]
229230

230231
log "groupBy should group consecutive equal elements into lists based on an equivalence relation"
231-
assert $ groupBy (\x y -> odd x && odd y) (l [1, 1, 2, 2, 3, 3]) == l [l [1, 1], l [2], l [2], l [3, 3]]
232+
assert $ groupBy (\x y -> odd x && odd y) (l [1, 1, 2, 2, 3, 3]) == l [1 :| l [1], NE.singleton 2, NE.singleton 2, 3 :| l [3]]
232233

233234
log "nub should remove duplicate elements from the list, keeping the first occurence"
234235
assert $ nub (l [1, 2, 2, 3, 4, 1]) == l [1, 2, 3, 4]

0 commit comments

Comments
 (0)