packages feed

liblawless 0.13.2 → 0.13.3

raw patch · 5 files changed

+203/−2 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

+ Tests/TestAeson.hs view
@@ -0,0 +1,72 @@+-- | Test encoding and decoding options.++{-# LANGUAGE TemplateHaskell, ExtendedDefaultRules #-}+{-# OPTIONS_GHC -Wno-orphans #-}++module TestAeson where++import Test.Framework+import Test.Framework.TH+import Test.Framework.Providers.QuickCheck2 (testProperty)+import Test.QuickCheck++import Data.String (String)++import Lawless+import Aeson+import Text+import Generics++import Data.Text (pack)++default (Text)++data TestData = TestData+    {+        _tdName ∷ Text,+        _tdCount ∷ Integer+    } deriving (Show, Eq, Ord, Generic)+makeLenses ''TestData+instance ToJSON TestData where+    toEncoding = moludeToJSONEncoding+instance FromJSON TestData where+    parseJSON = moludeParseJSON++instance Arbitrary Text where+    arbitrary = pack <$> arbitrary++instance Arbitrary TestData where+    arbitrary = TestData <$> arbitrary <*> arbitrary++prop_TestEncodingSimple :: TestData -> Property+prop_TestEncodingSimple (td :: TestData) =+    let+        enc = encode td++        dec ∷ Either String TestData+        dec = eitherDecode enc+    in+        collect "dec ∘ enc ≍ id" $ isn't _Left dec++data Cluster = Cluster+    {+        _clName ∷ Text,+        _clRegion ∷ Text+    } deriving (Show, Eq, Ord, Generic)+instance ToJSON Cluster where+    toEncoding = moludeToJSONEncoding+instance FromJSON Cluster where+    parseJSON = moludeParseJSON++data Schema1 = Schema1+    {+        _sc1Name ∷ Text,+        _sc1Cluster ∷ Cluster+    } deriving (Show, Eq, Ord, Generic)+instance ToJSON Schema1 where+    toEncoding = moludeToJSONEncoding+instance FromJSON Schema1 where+    parseJSON = moludeParseJSON++properties ∷ Test+properties = $(testGroupGenerator)
+ Tests/TestSepList.hs view
@@ -0,0 +1,35 @@+{-# LANGUAGE TemplateHaskell #-}+{-# OPTIONS_GHC -Wno-orphans #-}++module TestSepList (properties) where++import Lawless+import Textual++import Test.Framework+import Test.Framework.TH+import Test.Framework.Providers.QuickCheck2 (testProperty)+import Test.QuickCheck++import qualified Data.ByteString.Lazy as L++import Data.Binary+++instance Arbitrary (SepList Char) where+  arbitrary = foldl1Of folded (<>) . over traversed sepList <$> listOf1 arbitrary++prop_Semigroup :: SepList Char -> SepList Char -> Property+prop_Semigroup (a :: SepList Char) (b :: SepList Char) =+  (a <> b) ^. slItems === (a ^. slItems) <> (b ^. slItems)++prop_Serialize :: SepList Char -> Property+prop_Serialize (a :: SepList Char) =+  let+    sz = L.toStrict $ encode a+    de = decode $ L.fromStrict sz+  in+    (de ^. slItems) === (a ^. slItems)++properties ∷ Test+properties = $(testGroupGenerator)
+ Tests/TestTemporary.hs view
@@ -0,0 +1,41 @@+{-# LANGUAGE TemplateHaskell #-}+{-# OPTIONS_GHC -Wno-orphans #-}++{-|+Module:             TestTemporary+Description:        Test that temporary files are unbuffered and binary.+Copyright:          © 2016 All rights reserved.+License:            GPL-3+Maintainer:         Evan Cofsky <>+Stability:          experimental+Portability:        POSIX+-}++module TestTemporary where++import Lawless+import Test.Framework+import Test.Framework.TH+import Test.Framework.Providers.QuickCheck2 (testProperty)+import Test.QuickCheck+import Text+import Paths+import Temporary+import qualified Data.ByteString as B+import System.IO hiding (utf8)+import Test.QuickCheck.Monadic+import Data.Text.Encoding (encodeUtf8)++instance Arbitrary Text where+    arbitrary = view packed <$> listOf1 arbitrary++prop_CheckBuffering (line ∷ Text) = monadicIO $ do+    let l = encodeUtf8 line+    m ← run $ withTempHandle $(mkRelFile "testTemp") $ \h → do+        B.hPut h l+        hSeek h AbsoluteSeek 0+        B.hGetContents h+    assert (l ≡ m)++properties ∷ Test+properties = $(testGroupGenerator)
+ Tests/TestTime.hs view
@@ -0,0 +1,52 @@+{-# LANGUAGE TemplateHaskell #-}+{-# OPTIONS_GHC -Wno-orphans #-}++module TestTime where++import Test.Framework+import Test.Framework.TH+import Test.Framework.Providers.QuickCheck2 (testProperty)+import Test.QuickCheck++import qualified Data.ByteString.Lazy as L++import Data.Time.Clock+import Data.Time.Calendar+import Data.Binary++import Lawless+import Time++instance Arbitrary Day where+  arbitrary = toEnum <$> arbitrary++instance Arbitrary DiffTime where+  arbitrary = fromRational <$> suchThat arbitrary (\t -> t >= 0.0 && t <= 86401.0)++instance Arbitrary UTCTime where+  arbitrary =+    UTCTime <$> arbitrary <*> arbitrary++instance Arbitrary Time where+  arbitrary = review _Time <$> arbitrary++prop_PrismToTime :: UTCTime -> Property+prop_PrismToTime (ut :: UTCTime) =+  ut ^.re _Time ^. day === utctDay ut .&&.+  ut ^.re _Time ^. time === utctDayTime ut++prop_PrismFromTime :: Time -> Property+prop_PrismFromTime (t :: Time) =+  utctDay (t ^. _Time) === t ^. day .&&.+  utctDayTime (t ^. _Time) === t ^. time++prop_Serialize :: Time -> Property+prop_Serialize (t :: Time) =+  let+    sz = L.toStrict $ encode t+    de = decode $ L.fromStrict sz+  in+    de === t++properties ∷ Test+properties = $(testGroupGenerator)
liblawless.cabal view
@@ -1,5 +1,5 @@ name:                liblawless-version:             0.13.2+version:             0.13.3 synopsis:            Prelude based on protolude for GHC 8 and beyond. license:             GPL-3 license-file:        LICENSE@@ -11,6 +11,7 @@ extra-source-files:                    CHANGELOG                    README.md+                   Tests/*.hs cabal-version:       >=1.24 description:     A Prelude relpacement for GHC 8 with a focus on building@@ -23,7 +24,7 @@ source-repository this   type:     git   location: https://gitlab.com/misandrist/liblawless.git-  tag: v0.13.2+  tag: v0.13.3  library   exposed-modules: