packages feed

data-array-byte 0.1.0.1 → 0.1.0.2

raw patch · 3 files changed

+48/−31 lines, 3 filesdep ~basedep ~deepseqdep ~template-haskell

Dependency ranges changed: base, deepseq, template-haskell

Files

changelog.md view
@@ -1,3 +1,7 @@+# 0.1.0.2++* Update tests.+ # 0.1.0.1  * Relax required `cabal-version` to 1.10.
data-array-byte.cabal view
@@ -1,6 +1,6 @@ cabal-version:      >=1.10 name:               data-array-byte-version:            0.1.0.1+version:            0.1.0.2 license:            BSD3 license-file:       LICENSE copyright:          (c) Roman Leshchinskiy 2009-2012@@ -8,7 +8,8 @@ author:             Roman Leshchinskiy <rl@cse.unsw.edu.au> tested-with:     ghc ==8.0.2 ghc ==8.2.2 ghc ==8.4.4 ghc ==8.6.5 ghc ==8.8.4-    ghc ==8.10.7 ghc ==9.0.2 ghc ==9.2.4 ghc ==9.4.2+    ghc ==8.10.7 ghc ==9.0.2 ghc ==9.2.8 ghc ==9.4.8 ghc ==9.6.7+    ghc ==9.8.4 ghc ==9.10.3 ghc ==9.12.2 ghc ==9.14.1  homepage:           https://github.com/Bodigrim/data-array-byte bug-reports:        https://github.com/Bodigrim/data-array-byte/issues@@ -34,14 +35,14 @@  library     default-language: Haskell2010-    ghc-options:      -Wall-    build-depends:-        base >=4.9 && <4.18,-        deepseq >=1.4 && <1.5,-        template-haskell >=2.11 && <2.20      if impl(ghc <9.4)         exposed-modules: Data.Array.Byte+        ghc-options:     -Wall+        build-depends:+            base <5,+            deepseq <2,+            template-haskell <3  test-suite data-array-byte-tests     type:             exitcode-stdio-1.0@@ -50,9 +51,11 @@     default-language: Haskell2010     ghc-options:      -Wall     build-depends:-        base,-        data-array-byte,+        base <5,         quickcheck-classes-base >=0.6 && <0.7,-        tasty >=1.4 && <1.5,-        tasty-quickcheck >=0.10 && <0.11,+        tasty >=1.4 && <1.6,+        tasty-quickcheck >=0.10 && <0.12,         template-haskell++    if impl(ghc <9.4)+        build-depends: data-array-byte
test/Main.hs view
@@ -1,8 +1,10 @@ -- Derived from @primitive@ package. +{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE TemplateHaskell #-}--{-# OPTIONS_GHC -fno-warn-orphans #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE UndecidableInstances #-}+{- HLINT ignore "Redundant compare" -}  import Control.Monad (when, unless) import Data.Array.Byte (ByteArray)@@ -14,7 +16,7 @@ import Language.Haskell.TH.Syntax (lift) import Test.QuickCheck.Classes.Base (eqLaws, ordLaws, monoidLaws, showLaws, isListLaws, semigroupLaws, semigroupMonoidLaws, Laws(..)) import Test.Tasty (defaultMain, testGroup, TestTree)-import Test.Tasty.QuickCheck (testProperty, Arbitrary(..), (===), Property, NonNegative(..), property)+import Test.Tasty.QuickCheck (testProperty, (===), Property, NonNegative(..), property, Arbitrary(..))  main :: IO () main = do@@ -23,13 +25,13 @@     [ testProperty "equality" byteArrayEqProp     , testProperty "reflexivity" byteArrayReflexivityProp     , testProperty "compare" byteArrayCompareProp-    , lawsToTest (eqLaws (Proxy :: Proxy ByteArray))-    , lawsToTest (ordLaws (Proxy :: Proxy ByteArray))-    , lawsToTest (monoidLaws (Proxy :: Proxy ByteArray))-    , lawsToTest (showLaws (Proxy :: Proxy ByteArray))-    , lawsToTest (isListLaws (Proxy :: Proxy ByteArray))-    , lawsToTest (semigroupLaws (Proxy :: Proxy ByteArray))-    , lawsToTest (semigroupMonoidLaws (Proxy :: Proxy ByteArray))+    , lawsToTest (eqLaws (Proxy :: Proxy MyByteArray))+    , lawsToTest (ordLaws (Proxy :: Proxy MyByteArray))+    , lawsToTest (monoidLaws (Proxy :: Proxy MyByteArray))+    , lawsToTest (showLaws (Proxy :: Proxy MyByteArray))+    , lawsToTest (isListLaws (Proxy :: Proxy MyByteArray))+    , lawsToTest (semigroupLaws (Proxy :: Proxy MyByteArray))+    , lawsToTest (semigroupMonoidLaws (Proxy :: Proxy MyByteArray))     , testProperty "stimes" byteArrayStimesProp     , testProperty "lift" byteArrayLiftProp     ]@@ -49,8 +51,8 @@ compareLengthFirst :: [Word8] -> [Word8] -> Ordering compareLengthFirst xs ys = (compare `on` length) xs ys <> compare xs ys -byteArrayStimesProp :: NonNegative Int -> ByteArray -> Property-byteArrayStimesProp (NonNegative n) xs = stimes n xs === stimesMonoid n xs+byteArrayStimesProp :: NonNegative Int -> MyByteArray -> Property+byteArrayStimesProp (NonNegative n) (MyByteArray xs) = stimes n xs === stimesMonoid n xs  byteArrayLiftProp :: Property byteArrayLiftProp =@@ -72,20 +74,28 @@     when (show arr6 /= "[0xde, 0xad, 0x00, 0x01, 0xb0]") $         fail $ "ByteArray Show incorrect: " ++ show arr6     unless (arr1 > arr3) $-        fail $ "ByteArray Ord incorrect"+        fail "ByteArray Ord incorrect"     unless (arr1 == arr2) $-        fail $ "ByteArray Eq incorrect"+        fail "ByteArray Eq incorrect"     unless (mappend arr1 arr4 == arr5) $-        fail $ "ByteArray Monoid mappend incorrect"+        fail "ByteArray Monoid mappend incorrect"     unless (mappend arr1 (mappend arr3 arr4) == mappend (mappend arr1 arr3) arr4) $-        fail $ "ByteArray Monoid mappend not associative"+        fail "ByteArray Monoid mappend not associative"     unless (mconcat [arr1, arr2, arr3, arr4, arr5] == (arr1 <> arr2 <> arr3 <> arr4 <> arr5)) $-        fail $ "ByteArray Monoid mconcat incorrect"+        fail "ByteArray Monoid mconcat incorrect"     unless (stimes (3 :: Int) arr4 == (arr4 <> arr4 <> arr4)) $-        fail $ "ByteArray Semigroup stimes incorrect"+        fail "ByteArray Semigroup stimes incorrect" -instance Arbitrary ByteArray where-  arbitrary = mkByteArray <$> arbitrary+newtype MyByteArray = MyByteArray ByteArray+  deriving (Eq, Ord, Semigroup, Monoid, Show)++instance IsList MyByteArray where+    type Item MyByteArray = Item ByteArray+    fromList = MyByteArray . fromList+    toList (MyByteArray ba) = toList ba++instance Arbitrary MyByteArray where+  arbitrary = MyByteArray . mkByteArray <$> arbitrary  mkByteArray :: [Word8] -> ByteArray mkByteArray = fromList