packages feed

yaya-hedgehog 0.2.1.2 → 0.2.1.3

raw patch · 7 files changed

+228/−1 lines, 7 filesdep ~yayadep ~yaya-hedgehog

Dependency ranges changed: yaya, yaya-hedgehog

Files

CHANGELOG.md view
@@ -5,6 +5,24 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to the [Haskell Package Versioning Policy](https://pvp.haskell.org/). +## 0.2.1.3 – 2024–03–11++### Added++- The tests for `yaya` were previously in their own `yaya-test` package, but that has been folded into this package. Ideally, the tests would live in the `yaya` package, but Cabal doesn’t play well with circular dependencies between packages (even if the component dependencies aren’t circular).++## 0.2.1.2++Unknown changes.++## 0.2.1.1++Unknown changes.++## 0.2.1.0++Unknown changes.+ ## 0.2.0.2 – 2023–12–21  ### Changed
+ tests/Test/Fold.hs view
@@ -0,0 +1,42 @@+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE Unsafe #-}+{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}++module Test.Fold (tests) where++import safe "base" Control.Category (Category (id))+import safe "base" Control.Monad ((=<<))+import safe "base" Data.Bool (Bool)+import safe "base" Data.Function (($))+import safe "base" Data.Proxy (Proxy (Proxy))+import safe "base" System.IO (IO)+import safe "hedgehog" Hedgehog (Property, checkParallel, discover, forAll, property)+import safe qualified "hedgehog" Hedgehog.Gen as Gen+import safe "yaya" Yaya.Fold (Mu)+import safe "yaya" Yaya.Fold.Common (size)+import safe "yaya-hedgehog" Yaya.Hedgehog.Expr (Expr, genExpr, genMuExpr)+import safe "yaya-hedgehog" Yaya.Hedgehog.Fold+  ( law_cataCancel,+    law_cataCompose,+    law_cataRefl,+  )++-- TODO: For some reason HLint is complaining that TemplateHaskell is unused.+{-# HLINT ignore "Unused LANGUAGE pragma" #-}++prop_muCataCancel :: Property+prop_muCataCancel =+  property $ law_cataCancel size =<< forAll (genExpr (Gen.sized genMuExpr))++prop_muCataRefl :: Property+prop_muCataRefl =+  property $ law_cataRefl =<< forAll (Gen.sized genMuExpr)++prop_muCataCompose :: Property+prop_muCataCompose =+  property $+    law_cataCompose (Proxy :: Proxy (Mu Expr)) size id+      =<< forAll (Gen.sized genMuExpr)++tests :: IO Bool+tests = checkParallel $$discover
+ tests/Test/Fold/Common.hs view
@@ -0,0 +1,39 @@+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE Unsafe #-}+{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}++module Test.Fold.Common (tests) where++import safe "base" Control.Category (Category ((.)))+import safe "base" Control.Monad ((=<<))+import safe "base" Data.Bool (Bool)+import safe "base" Data.Functor (Functor (fmap))+import safe "base" Data.Ord (Ord ((<)))+import safe "base" System.IO (IO)+import safe "hedgehog" Hedgehog+  ( Property,+    assert,+    checkParallel,+    discover,+    forAll,+    property,+  )+import safe qualified "hedgehog" Hedgehog.Gen as Gen+import safe "yaya" Yaya.Fold (Recursive (cata), zipAlgebras)+import safe "yaya" Yaya.Fold.Common (height, size)+import safe "yaya" Yaya.Pattern (uncurry)+import safe "yaya-hedgehog" Yaya.Hedgehog.Expr (genMuExpr)+import safe "base" Prelude (Integral (toInteger))++-- TODO: For some reason HLint is complaining that TemplateHaskell is unused.+{-# HLINT ignore "Unused LANGUAGE pragma" #-}++prop_heightLtSize :: Property+prop_heightLtSize =+  property+    ( assert . uncurry (<) . fmap toInteger . cata (zipAlgebras height size)+        =<< forAll (Gen.sized genMuExpr)+    )++tests :: IO Bool+tests = checkParallel $$discover
+ tests/Test/Fold/Native.hs view
@@ -0,0 +1,42 @@+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE Unsafe #-}+{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}++module Test.Fold.Native (tests) where++import safe "base" Control.Category (Category (id))+import safe "base" Control.Monad ((=<<))+import safe "base" Data.Bool (Bool)+import safe "base" Data.Function (($))+import safe "base" Data.Proxy (Proxy (Proxy))+import safe "base" System.IO (IO)+import safe "hedgehog" Hedgehog (Property, checkParallel, discover, forAll, property)+import safe qualified "hedgehog" Hedgehog.Gen as Gen+import safe "yaya" Yaya.Fold.Common (size)+import safe "yaya" Yaya.Fold.Native (Fix)+import safe "yaya-hedgehog" Yaya.Hedgehog.Expr (Expr, genExpr, genFixExpr)+import safe "yaya-hedgehog" Yaya.Hedgehog.Fold+  ( law_cataCancel,+    law_cataCompose,+    law_cataRefl,+  )++-- TODO: For some reason HLint is complaining that TemplateHaskell is unused.+{-# HLINT ignore "Unused LANGUAGE pragma" #-}++prop_fixCataCancel :: Property+prop_fixCataCancel =+  property $ law_cataCancel size =<< forAll (genExpr (Gen.sized genFixExpr))++prop_fixCataRefl :: Property+prop_fixCataRefl =+  property $ law_cataRefl =<< forAll (Gen.sized genFixExpr)++prop_fixCataCompose :: Property+prop_fixCataCompose =+  property $+    law_cataCompose (Proxy :: Proxy (Fix Expr)) size id+      =<< forAll (Gen.sized genFixExpr)++tests :: IO Bool+tests = checkParallel $$discover
+ tests/Test/Retrofit.hs view
@@ -0,0 +1,35 @@+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE Unsafe #-}++-- | The point of this module is that it should compile _without_ importing any+--   other Yaya modules.+module Test.Retrofit (tests) where++import safe "base" Data.Bool (Bool)+import safe "base" Data.Eq (Eq)+import safe "base" Data.Int (Int)+import safe "base" System.IO (IO)+import safe "base" Text.Show (Show)+import safe "hedgehog" Hedgehog (checkParallel, discover)+import safe "yaya" Yaya.Retrofit (defaultRules, extractPatternFunctor)++data DExpr+  = Lit Int+  | Add DExpr DExpr+  | Mult DExpr DExpr+  deriving stock (Eq, Show)++extractPatternFunctor defaultRules ''DExpr++-- -- | This can be derived in this case, but we want to ensure we could define it+-- --   if necessary.+-- instance Eq DExpr where+--   (==) = recursiveEq++-- -- | This can be derived in this case, but we want to ensure we could define it+-- --   if necessary.+-- instance Show DExpr where+--   showsPrec = recursiveShowsPrec++tests :: IO Bool+tests = checkParallel $$discover
+ tests/test.hs view
@@ -0,0 +1,10 @@+{-# LANGUAGE Unsafe #-}++import safe "base" System.IO (IO)+import safe "hedgehog" Hedgehog.Main (defaultMain)+import qualified "this" Test.Fold as Fold+import qualified "this" Test.Fold.Common as Fold.Common+import qualified "this" Test.Retrofit as Retrofit++main :: IO ()+main = defaultMain [Fold.tests, Fold.Common.tests, Retrofit.tests]
yaya-hedgehog.cabal view
@@ -1,7 +1,7 @@ cabal-version:  3.0  name:        yaya-hedgehog-version:     0.2.1.2+version:     0.2.1.3 synopsis:    Hedgehog testing support for the Yaya recursion scheme              library. description: If you use Yaya in your own code and have tests written@@ -204,3 +204,44 @@     -- “Build_doctests.hs”, we set it here, and that means it has to match     -- doctests.hs, which is `Unsafe`.     Unsafe++-- NB: This suite should be in the `yaya` package, but it can’t because it+--     depends on `yaya-hedgehog`.+test-suite yaya+  import: defaults+  type: exitcode-stdio-1.0+  hs-source-dirs:+    tests+  main-is: test.hs+  other-modules:+    Test.Fold+    Test.Fold.Common+    Test.Fold.Native+    Test.Retrofit+  build-depends:+    deriving-compat,+    hedgehog,+    yaya >= 0.5.0,+    yaya-hedgehog >= 0.2.0,+  ghc-options:+    -rtsopts+    -threaded+    -trust adjunctions+    -trust array+    -trust base-orphans+    -trust binary+    -trust bytestring+    -trust containers+    -trust distributive+    -trust exceptions+    -trust ghc-prim+    -trust hashable+    -trust profunctors+    -trust semigroupoids+    -trust stm+    -trust text+    -trust transformers-compat+    -with-rtsopts=-N+  if impl(ghc < 9.6)+    ghc-options:+      -trust foldable1-classes-compat