Skip to content

Commit 52693b7

Browse files
committed
Simplify
1 parent aa126bc commit 52693b7

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

test/Properties/TypedArray.purs

+5-8
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ import Data.ArrayBuffer.Typed as TA
1010
import Data.ArrayBuffer.Typed.Gen (WithOffset(..), genFloat32, genFloat64, genInt16, genInt32, genInt8, genTypedArray, genUint16, genUint32, genUint8, genWithOffset)
1111
import Data.ArrayBuffer.Types (ArrayView, Float32Array, Float64Array, Int16Array, Int32Array, Int8Array, Uint16Array, Uint8Array, Uint8ClampedArray, Uint32Array)
1212
import Data.ArrayBuffer.ValueMapping (class BytesPerValue)
13-
import Data.Maybe (Maybe(..), fromMaybe)
13+
import Data.Maybe (Maybe(..), fromMaybe, isJust)
14+
import Data.Traversable (traverse)
1415
import Data.Typelevel.Num (class Nat, D0, D1, D2, D5, d0, d1, toInt')
1516
import Data.Vec (head, index) as Vec
1617
import Effect (Effect)
1718
import Effect.Console (log)
1819
import Effect.Ref (Ref)
1920
import Effect.Ref as Ref
2021
import Effect.Unsafe (unsafePerformEffect)
21-
import Partial.Unsafe (unsafePartial)
2222
import Test.QuickCheck (class Testable, Result(..), quickCheckGen, (/==), (<?>), (===))
2323
import Test.QuickCheck.Combinators ((==>), (|=|))
2424
import Test.QuickCheck.Gen (Gen)
@@ -298,12 +298,9 @@ withOffsetElemTests count = overAll1 count withOffsetElem
298298
where
299299
withOffsetElem :: forall a b t. TestableArrayF a b D5 t Result
300300
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+
let fetch o = TA.at xs o
302+
exs <- traverse fetch os
303+
pure $ Array.all isJust exs <?> "All doesn't have an elem of itself"
307304

308305

309306
-- | Should work with any arbitrary predicate, but we can't generate them

0 commit comments

Comments
 (0)