@@ -213,7 +213,7 @@ allAreFilledTests count = overAll count allAreFilled
213
213
let x = fromMaybe zero e
214
214
l = TA .length xs
215
215
TA .fill x 0 l xs
216
- let b = TA .all (_ == x) xs
216
+ b <- TA .all (_ == x) xs
217
217
pure (b <?> " All aren't the filled value" )
218
218
219
219
@@ -237,23 +237,25 @@ allImpliesAnyTests :: Ref Int -> Effect Unit
237
237
allImpliesAnyTests count = overAll count allImpliesAny
238
238
where
239
239
allImpliesAny :: forall a b t . TestableArrayF a b D0 t Result
240
- allImpliesAny (WithOffset _ xs) =
240
+ allImpliesAny (WithOffset _ xs) = do
241
241
let pred x = x /= zero
242
- all' = TA .all pred xs <?> " All don't satisfy the predicate"
243
- any' = TA .any pred xs <?> " None satisfy the predicate"
244
- in pure $ (TA .length xs === zero) |=| all' ==> any'
242
+ all'' <- TA .all pred xs
243
+ let all' = all'' <?> " All don't satisfy the predicate"
244
+ any'' <- TA .any pred xs
245
+ let any' = any'' <?> " None satisfy the predicate"
246
+ pure $ (TA .length xs === zero) |=| all' ==> any'
245
247
246
248
247
249
-- | Should work with any arbitrary predicate, but we can't generate them
248
250
filterImpliesAllTests :: Ref Int -> Effect Unit
249
251
filterImpliesAllTests count = overAll count filterImpliesAll
250
252
where
251
253
filterImpliesAll :: forall a b t . TestableArrayF a b D0 t Result
252
- filterImpliesAll (WithOffset _ xs) =
254
+ filterImpliesAll (WithOffset _ xs) = do
253
255
let pred x = x /= zero
254
- ys = TA .filter pred xs
255
- all' = TA .all pred ys
256
- in pure $ all' <?> " Filter doesn't imply all"
256
+ ys <- TA .filter pred xs
257
+ all' <- TA .all pred ys
258
+ pure $ all' <?> " Filter doesn't imply all"
257
259
258
260
259
261
-- | Should work with any arbitrary predicate, but we can't generate them
@@ -263,8 +265,8 @@ filterIsTotalTests count = overAll count filterIsTotal
263
265
filterIsTotal :: forall a b t . TestableArrayF a b D0 t Result
264
266
filterIsTotal (WithOffset _ xs) = do
265
267
let pred x = x /= zero
266
- ys = TA .filter pred xs
267
- zs = TA .filter (not pred) ys
268
+ ys <- TA .filter pred xs
269
+ zs <- TA .filter (not pred) ys
268
270
azs <- TA .toArray zs
269
271
pure $ azs === []
270
272
@@ -276,8 +278,8 @@ filterIsIdempotentTests count = overAll count filterIsIdempotent
276
278
filterIsIdempotent :: forall a b t . TestableArrayF a b D0 t Result
277
279
filterIsIdempotent (WithOffset _ xs) = do
278
280
let pred x = x /= zero
279
- ys = TA .filter pred xs
280
- zs = TA .filter pred ys
281
+ ys <- TA .filter pred xs
282
+ zs <- TA .filter pred ys
281
283
azs <- TA .toArray zs
282
284
ays <- TA .toArray ys
283
285
pure $ azs === ays
@@ -295,9 +297,13 @@ withOffsetElemTests :: Ref Int -> Effect Unit
295
297
withOffsetElemTests count = overAll1 count withOffsetElem
296
298
where
297
299
withOffsetElem :: forall a b t . TestableArrayF a b D5 t Result
298
- withOffsetElem (WithOffset os xs) = pure $
299
- Array .all (\o -> TA .elem (unsafePartial $ unsafePerformEffect $ TA .unsafeAt xs o) Nothing xs) os
300
- <?> " All doesn't have an elem of itself"
300
+ withOffsetElem (WithOffset os xs) = do
301
+ let valid :: TA.Offset -> Boolean
302
+ valid o = unsafePerformEffect do
303
+ e <- unsafePartial $ TA .unsafeAt xs o
304
+ b <- TA .elem e Nothing xs
305
+ pure b
306
+ pure $ Array .all valid os <?> " All doesn't have an elem of itself"
301
307
302
308
303
309
-- | Should work with any arbitrary predicate, but we can't generate them
@@ -307,7 +313,8 @@ anyImpliesFindTests count = overAll count anyImpliesFind
307
313
anyImpliesFind :: forall a b t . TestableArrayF a b D0 t Result
308
314
anyImpliesFind (WithOffset _ xs) = do
309
315
let pred x = x /= zero
310
- p = TA .any pred xs <?> " All don't satisfy the predicate"
316
+ a <- TA .any pred xs
317
+ let p = a <?> " All don't satisfy the predicate"
311
318
idx <- TA .find pred xs
312
319
let q = case idx of
313
320
Nothing -> Failed " Doesn't have a value satisfying the predicate"
0 commit comments