@@ -10,16 +10,16 @@ import Test.Assert (assert)
10
10
11
11
testList = do
12
12
13
- log " singleton should construct an array with a single value"
13
+ log " singleton should construct an list with a single value"
14
14
assert $ singleton 1 == toList [1 ]
15
15
assert $ singleton " foo" == toList [" foo" ]
16
16
assert $ singleton nil == toList [toList []]
17
17
18
- log " range should create an inclusive array of integers for the specified start and end"
18
+ log " range should create an inclusive list of integers for the specified start and end"
19
19
assert $ (range 0 5 ) == toList [0 , 1 , 2 , 3 , 4 , 5 ]
20
20
assert $ (range 2 (-3 )) == toList [2 , 1 , 0 , -1 , -2 , -3 ]
21
21
22
- log " replicate should produce an array containg an item a specified number of times"
22
+ log " replicate should produce an list containg an item a specified number of times"
23
23
assert $ replicate 3 true == toList [true , true , true ]
24
24
assert $ replicate 1 " foo" == toList [" foo" ]
25
25
assert $ replicate 0 " foo" == toList []
@@ -34,88 +34,88 @@ testList = do
34
34
-- some
35
35
-- many
36
36
37
- log " null should return false for non-empty arrays "
37
+ log " null should return false for non-empty lists "
38
38
assert $ null (toList [1 ]) == false
39
39
assert $ null (toList [1 , 2 , 3 ]) == false
40
40
41
- log " null should return true for an empty array "
41
+ log " null should return true for an empty list "
42
42
assert $ null nil == true
43
43
44
- log " length should return the number of items in an array "
44
+ log " length should return the number of items in an list "
45
45
assert $ length nil == 0
46
46
assert $ length (toList [1 ]) == 1
47
47
assert $ length (toList [1 , 2 , 3 , 4 , 5 ]) == 5
48
48
49
- log " snoc should add an item to the end of an array "
49
+ log " snoc should add an item to the end of an list "
50
50
assert $ toList [1 , 2 , 3 ] `snoc` 4 == toList [1 , 2 , 3 , 4 ]
51
51
assert $ nil `snoc` 1 == toList [1 ]
52
52
53
- log " insert should add an item at the appropriate place in a sorted array "
53
+ log " insert should add an item at the appropriate place in a sorted list "
54
54
assert $ insert 1.5 (toList [1.0 , 2.0 , 3.0 ]) == toList [1.0 , 1.5 , 2.0 , 3.0 ]
55
55
assert $ insert 4 (toList [1 , 2 , 3 ]) == toList [1 , 2 , 3 , 4 ]
56
56
assert $ insert 0 (toList [1 , 2 , 3 ]) == toList [0 , 1 , 2 , 3 ]
57
57
58
- log " insertBy should add an item at the appropriate place in a sorted array using the specified comparison"
58
+ log " insertBy should add an item at the appropriate place in a sorted list using the specified comparison"
59
59
assert $ insertBy (flip compare) 4 (toList [1 , 2 , 3 ]) == toList [4 , 1 , 2 , 3 ]
60
60
assert $ insertBy (flip compare) 0 (toList [1 , 2 , 3 ]) == toList [1 , 2 , 3 , 0 ]
61
61
62
- log " head should return a Just-wrapped first value of a non-empty array "
62
+ log " head should return a Just-wrapped first value of a non-empty list "
63
63
assert $ head (toList [" foo" , " bar" ]) == Just " foo"
64
64
65
- log " head should return Nothing for an empty array "
65
+ log " head should return Nothing for an empty list "
66
66
assert $ head nil == Nothing
67
67
68
- log " last should return a Just-wrapped last value of a non-empty array "
68
+ log " last should return a Just-wrapped last value of a non-empty list "
69
69
assert $ last (toList [" foo" , " bar" ]) == Just " bar"
70
70
71
- log " last should return Nothing for an empty array "
71
+ log " last should return Nothing for an empty list "
72
72
assert $ last nil == Nothing
73
73
74
- log " tail should return a Just-wrapped array containing all the items in an array apart from the first for a non-empty array "
74
+ log " tail should return a Just-wrapped list containing all the items in an list apart from the first for a non-empty list "
75
75
assert $ tail (toList [" foo" , " bar" , " baz" ]) == Just (toList [" bar" , " baz" ])
76
76
77
- log " tail should return Nothing for an empty array "
77
+ log " tail should return Nothing for an empty list "
78
78
assert $ tail nil == Nothing
79
79
80
- log " init should return a Just-wrapped array containing all the items in an array apart from the first for a non-empty array "
80
+ log " init should return a Just-wrapped list containing all the items in an list apart from the first for a non-empty list "
81
81
assert $ init (toList [" foo" , " bar" , " baz" ]) == Just (toList [" foo" , " bar" ])
82
82
83
- log " init should return Nothing for an empty array "
83
+ log " init should return Nothing for an empty list "
84
84
assert $ init nil == Nothing
85
85
86
- log " uncons should return nothing when used on an empty array "
86
+ log " uncons should return nothing when used on an empty list "
87
87
assert $ isNothing (uncons nil)
88
88
89
- log " uncons should split an array into a head and tail record when there is at least one item"
89
+ log " uncons should split an list into a head and tail record when there is at least one item"
90
90
let u1 = uncons (toList [1 ])
91
91
assert $ (fromJust u1).head == 1
92
92
assert $ (fromJust u1).tail == toList []
93
93
let u2 = uncons (toList [1 , 2 , 3 ])
94
94
assert $ (fromJust u2).head == 1
95
95
assert $ (fromJust u2).tail == toList [2 , 3 ]
96
96
97
- log " (!!) should return Just x when the index is within the bounds of the array "
97
+ log " (!!) should return Just x when the index is within the bounds of the list "
98
98
assert $ toList [1 , 2 , 3 ] !! 0 == (Just 1 )
99
99
assert $ toList [1 , 2 , 3 ] !! 1 == (Just 2 )
100
100
assert $ toList [1 , 2 , 3 ] !! 2 == (Just 3 )
101
101
102
- log " (!!) should return Nothing when the index is outside of the bounds of the array "
102
+ log " (!!) should return Nothing when the index is outside of the bounds of the list "
103
103
assert $ toList [1 , 2 , 3 ] !! 6 == Nothing
104
104
assert $ toList [1 , 2 , 3 ] !! (-1 ) == Nothing
105
105
106
- log " elemIndex should return the index of an item that a predicate returns true for in an array "
106
+ log " elemIndex should return the index of an item that a predicate returns true for in an list "
107
107
assert $ elemIndex 1 (toList [1 , 2 , 1 ]) == Just 0
108
108
assert $ elemIndex 4 (toList [1 , 2 , 1 ]) == Nothing
109
109
110
- log " elemLastIndex should return the last index of an item in an array "
110
+ log " elemLastIndex should return the last index of an item in an list "
111
111
assert $ elemLastIndex 1 (toList [1 , 2 , 1 ]) == Just 2
112
112
assert $ elemLastIndex 4 (toList [1 , 2 , 1 ]) == Nothing
113
113
114
- log " findIndex should return the index of an item that a predicate returns true for in an array "
114
+ log " findIndex should return the index of an item that a predicate returns true for in an list "
115
115
assert $ findIndex (/= 1 ) (toList [1 , 2 , 1 ]) == Just 1
116
116
assert $ findIndex (== 3 ) (toList [1 , 2 , 1 ]) == Nothing
117
117
118
- log " findLastIndex should return the last index of an item in an array "
118
+ log " findLastIndex should return the last index of an item in an list "
119
119
assert $ findLastIndex (/= 1 ) (toList [2 , 1 , 2 ]) == Just 2
120
120
assert $ findLastIndex (== 3 ) (toList [2 , 1 , 2 ]) == Nothing
121
121
@@ -159,11 +159,11 @@ testList = do
159
159
log " alterAt should return Nothing if the index is out of range"
160
160
assert $ (alterAt 1 (Just <<< (+ 1 )) nil) == Nothing
161
161
162
- log " reverse should reverse the order of items in an array "
162
+ log " reverse should reverse the order of items in an list "
163
163
assert $ (reverse (toList [1 , 2 , 3 ])) == toList [3 , 2 , 1 ]
164
164
assert $ (reverse nil) == nil
165
165
166
- log " concat should join an array of arrays "
166
+ log " concat should join an list of lists "
167
167
assert $ (concat (toList [toList [1 , 2 ], toList [3 , 4 ]] )) == toList [1 , 2 , 3 , 4 ]
168
168
assert $ (concat (toList [toList [1 ], nil])) == toList [1 ]
169
169
assert $ (concat (toList [nil, nil])) == nil
@@ -178,10 +178,10 @@ testList = do
178
178
assert $ filterM (Just <<< odd) (range 0 10 ) == Just (toList [1 , 3 , 5 , 7 , 9 ])
179
179
assert $ filterM (const Nothing ) (range 0 10 ) == Nothing
180
180
181
- log " mapMaybe should transform every item in an array , throwing out Nothing values"
181
+ log " mapMaybe should transform every item in an list , throwing out Nothing values"
182
182
assert $ mapMaybe (\x -> if x /= 0 then Just x else Nothing ) (toList [0 , 1 , 0 , 0 , 2 , 3 ]) == toList [1 , 2 , 3 ]
183
183
184
- log " catMaybe should take an array of Maybe values and throw out Nothings"
184
+ log " catMaybe should take an list of Maybe values and throw out Nothings"
185
185
assert $ catMaybes (toList [Nothing , Just 2 , Nothing , Just 4 ]) == toList [2 , 4 ]
186
186
187
187
log " sort should reorder a list into ascending order based on the result of compare"
@@ -190,38 +190,38 @@ testList = do
190
190
log " sortBy should reorder a list into ascending order based on the result of a comparison function"
191
191
assert $ sortBy (flip compare) (toList [1 , 3 , 2 , 5 , 6 , 4 ]) == toList [6 , 5 , 4 , 3 , 2 , 1 ]
192
192
193
- log " take should keep the specified number of items from the front of an array , discarding the rest"
193
+ log " take should keep the specified number of items from the front of an list , discarding the rest"
194
194
assert $ (take 1 (toList [1 , 2 , 3 ])) == toList [1 ]
195
195
assert $ (take 2 (toList [1 , 2 , 3 ])) == toList [1 , 2 ]
196
196
assert $ (take 1 nil) == nil
197
197
198
- log " takeWhile should keep all values that match a predicate from the front of an array "
198
+ log " takeWhile should keep all values that match a predicate from the front of an list "
199
199
assert $ (takeWhile (/= 2 ) (toList [1 , 2 , 3 ])) == toList [1 ]
200
200
assert $ (takeWhile (/= 3 ) (toList [1 , 2 , 3 ])) == toList [1 , 2 ]
201
201
assert $ (takeWhile (/= 1 ) nil) == nil
202
202
203
- log " drop should remove the specified number of items from the front of an array "
203
+ log " drop should remove the specified number of items from the front of an list "
204
204
assert $ (drop 1 (toList [1 , 2 , 3 ])) == toList [2 , 3 ]
205
205
assert $ (drop 2 (toList [1 , 2 , 3 ])) == toList [3 ]
206
206
assert $ (drop 1 nil) == nil
207
207
208
- log " dropWhile should remove all values that match a predicate from the front of an array "
208
+ log " dropWhile should remove all values that match a predicate from the front of an list "
209
209
assert $ (dropWhile (/= 1 ) (toList [1 , 2 , 3 ])) == toList [1 , 2 , 3 ]
210
210
assert $ (dropWhile (/= 2 ) (toList [1 , 2 , 3 ])) == toList [2 , 3 ]
211
211
assert $ (dropWhile (/= 1 ) nil) == nil
212
212
213
- log " span should split an array in two based on a predicate"
213
+ log " span should split an list in two based on a predicate"
214
214
let spanResult = span (< 4 ) (toList [1 , 2 , 3 , 4 , 5 , 6 , 7 ])
215
215
assert $ spanResult.init == toList [1 , 2 , 3 ]
216
216
assert $ spanResult.rest == toList [4 , 5 , 6 , 7 ]
217
217
218
- log " group should group consecutive equal elements into arrays "
218
+ log " group should group consecutive equal elements into lists "
219
219
assert $ group (toList [1 , 2 , 2 , 3 , 3 , 3 , 1 ]) == toList [toList [1 ], toList [2 , 2 ], toList [3 , 3 , 3 ], toList [1 ]]
220
220
221
- log " group' should sort then group consecutive equal elements into arrays "
221
+ log " group' should sort then group consecutive equal elements into lists "
222
222
assert $ group' (toList [1 , 2 , 2 , 3 , 3 , 3 , 1 ]) == toList [toList [1 , 1 ], toList [2 , 2 ], toList [3 , 3 , 3 ]]
223
223
224
- log " groupBy should group consecutive equal elements into arrays based on an equivalence relation"
224
+ log " groupBy should group consecutive equal elements into lists based on an equivalence relation"
225
225
assert $ groupBy (\x y -> odd x && odd y) (toList [1 , 1 , 2 , 2 , 3 , 3 ]) == toList [toList [1 , 1 ], toList [2 ], toList [2 ], toList [3 , 3 ]]
226
226
227
227
log " nub should remove duplicate items from the list"
@@ -231,28 +231,28 @@ testList = do
231
231
let nubPred = \x y -> if odd x then false else x == y
232
232
assert $ nubBy nubPred (toList [1 , 2 , 2 , 3 , 3 , 4 , 4 , 1 ]) == toList [1 , 2 , 3 , 3 , 4 , 1 ]
233
233
234
- log " union should produce the union of two arrays "
234
+ log " union should produce the union of two lists "
235
235
assert $ union (toList [1 , 2 , 3 ]) (toList [2 , 3 , 4 ]) == toList [1 , 2 , 3 , 4 ]
236
236
assert $ union (toList [1 , 1 , 2 , 3 ]) (toList [2 , 3 , 4 ]) == toList [1 , 1 , 2 , 3 , 4 ]
237
237
238
- log " unionBy should produce the union of two arrays using the specified equality relation"
238
+ log " unionBy should produce the union of two lists using the specified equality relation"
239
239
assert $ unionBy (\_ y -> y < 5 ) (toList [1 , 2 , 3 ]) (toList [2 , 3 , 4 , 5 , 6 ]) == toList [1 , 2 , 3 , 5 , 6 ]
240
240
241
- log " delete should remove the first matching item from an array "
241
+ log " delete should remove the first matching item from an list "
242
242
assert $ delete 1 (toList [1 , 2 , 1 ]) == toList [2 , 1 ]
243
243
assert $ delete 2 (toList [1 , 2 , 1 ]) == toList [1 , 1 ]
244
244
245
- log " deleteBy should remove the first equality-relation-matching item from an array "
245
+ log " deleteBy should remove the first equality-relation-matching item from an list "
246
246
assert $ deleteBy (/=) 2 (toList [1 , 2 , 1 ]) == toList [2 , 1 ]
247
247
assert $ deleteBy (/=) 1 (toList [1 , 2 , 1 ]) == toList [1 , 1 ]
248
248
249
249
log " (\\\\ ) should return the difference between two lists"
250
250
assert $ toList [1 , 2 , 3 , 4 , 3 , 2 , 1 ] \\ toList [1 , 1 , 2 , 3 ] == toList [4 , 3 , 2 ]
251
251
252
- log " intersect should return the intersection of two arrays "
252
+ log " intersect should return the intersection of two lists "
253
253
assert $ intersect (toList [1 , 2 , 3 , 4 , 3 , 2 , 1 ]) (toList [1 , 1 , 2 , 3 ]) == toList [1 , 2 , 3 , 3 , 2 , 1 ]
254
254
255
- log " intersectBy should return the intersection of two arrays using the specified equivalence relation"
255
+ log " intersectBy should return the intersection of two lists using the specified equivalence relation"
256
256
assert $ intersectBy (\x y -> (x * 2 ) == y) (toList [1 , 2 , 3 ]) (toList [2 , 6 ]) == toList [1 , 3 ]
257
257
258
258
log " zipWith should use the specified function to zip two lists together"
0 commit comments