@@ -110,6 +110,10 @@ main = do
110110 , TQC. testProperty " Word32" (setByteArrayProp (Proxy :: Proxy Word32 ))
111111 , TQC. testProperty " Word64" (setByteArrayProp (Proxy :: Proxy Word64 ))
112112 , TQC. testProperty " Word" (setByteArrayProp (Proxy :: Proxy Word ))
113+ , TQC. testProperty " Float" (setByteArrayProp (Proxy :: Proxy Float ))
114+ , TQC. testProperty " Double" (setByteArrayProp (Proxy :: Proxy Double ))
115+ , TQC. testProperty " Float -0.0" (\ n off len -> setByteArrayTest (Proxy :: Proxy Float ) n off len 0.0 (- 0.0 ))
116+ , TQC. testProperty " Double -0.0" (\ n off len -> setByteArrayTest (Proxy :: Proxy Double ) n off len 0.0 (- 0.0 ))
113117 ]
114118 ]
115119 , testGroup " Resize"
@@ -175,6 +179,8 @@ main = do
175179 , renameLawsToTest " Int16" (primLaws (Proxy :: Proxy Int16 ))
176180 , renameLawsToTest " Int32" (primLaws (Proxy :: Proxy Int32 ))
177181 , renameLawsToTest " Int64" (primLaws (Proxy :: Proxy Int64 ))
182+ , renameLawsToTest " Float" (primLaws (Proxy :: Proxy Float ))
183+ , renameLawsToTest " Double" (primLaws (Proxy :: Proxy Double ))
178184 , renameLawsToTest " Const" (primLaws (Proxy :: Proxy (Const Int16 Int16 )))
179185 , renameLawsToTest " Down" (primLaws (Proxy :: Proxy (Down Int16 )))
180186 , renameLawsToTest " Identity" (primLaws (Proxy :: Proxy (Identity Int16 )))
@@ -207,22 +213,25 @@ int32 :: Proxy Int32
207213int32 = Proxy
208214
209215
210- setByteArrayProp :: forall a . (Prim a , Eq a , Arbitrary a , Show a ) => Proxy a -> QC. Property
211- setByteArrayProp _ = QC. property $ \ (QC. NonNegative (n :: Int )) (QC. NonNegative (off :: Int )) (QC. NonNegative (len :: Int )) (x :: a ) (y :: a ) ->
216+ setByteArrayProp :: (Prim a , Eq a , Arbitrary a , Show a ) => Proxy a -> QC. Property
217+ setByteArrayProp p = QC. property (setByteArrayTest p)
218+
219+ setByteArrayTest :: (Prim a , Eq a , Arbitrary a , Show a ) => Proxy a -> QC. NonNegative Int -> QC. NonNegative Int -> QC. NonNegative Int -> a -> a -> QC. Property
220+ setByteArrayTest _ (QC. NonNegative (n :: Int )) (QC. NonNegative (off :: Int )) (QC. NonNegative (len :: Int )) (x :: a ) (y :: a ) =
212221 (off < n && off + len <= n) ==>
213222 -- We use PrimArray in this test because it makes it easier to
214223 -- get the element-vs-byte distinction right.
215- let actual = runST $ do
224+ let ! ( PrimArray actual) = runST $ do
216225 m <- newPrimArray n
217226 forM_ (enumFromTo 0 (n - 1 )) $ \ ix -> writePrimArray m ix x
218227 setPrimArray m off len y
219228 unsafeFreezePrimArray m
220- expected = runST $ do
229+ ! ( PrimArray expected) = runST $ do
221230 m <- newPrimArray n
222231 forM_ (enumFromTo 0 (n - 1 )) $ \ ix -> writePrimArray m ix x
223232 forM_ (enumFromTo off (off + len - 1 )) $ \ ix -> writePrimArray m ix y
224233 unsafeFreezePrimArray m
225- in expected === actual
234+ in ByteArray expected === ByteArray actual -- compare as ByteArray, so that actual bytes are compared
226235
227236
228237-- Tests that using resizeByteArray to shrink a byte array produces
0 commit comments