less-arbitrary 0.1.0.2 → 0.1.1.0
raw patch · 3 files changed
+23/−5 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Test.LessArbitrary: instance GHC.Classes.Eq Test.LessArbitrary.Cost
- Test.LessArbitrary: instance GHC.Classes.Ord Test.LessArbitrary.Cost
- Test.LessArbitrary: instance GHC.Enum.Bounded Test.LessArbitrary.Cost
- Test.LessArbitrary: instance GHC.Enum.Enum Test.LessArbitrary.Cost
- Test.LessArbitrary: instance GHC.Num.Num Test.LessArbitrary.Cost
+ Test.LessArbitrary: budgetChoose :: CostGen Int
Files
- less-arbitrary.cabal +3/−2
- src/Test/LessArbitrary.hs +10/−3
- src/Test/LessArbitrary/Cost.hs +10/−0
less-arbitrary.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: a17a820a8212ed918b2dba9a4251f2a286fa2cac941ffa702fbc35323f5309b1+-- hash: 2784cd23f761bc388cdc69ce5a87b11f9d38fa3598fdf1b60aabd3c87fd65ffa name: less-arbitrary-version: 0.1.0.2+version: 0.1.1.0 synopsis: Linear time testing with variant of Arbitrary class that always terminates. description: Ever found non-terminating Arbitrary instance? Ever wondered what would be a runtime cost of particular Arbitrary instance?@@ -40,6 +40,7 @@ exposed-modules: Test.LessArbitrary other-modules:+ Test.LessArbitrary.Cost Paths_less_arbitrary hs-source-dirs: src
src/Test/LessArbitrary.hs view
@@ -12,6 +12,7 @@ {-# language TypeApplications #-} {-# language TypeOperators #-} {-# language TypeFamilies #-}+{-# language TupleSections #-} {-# language UndecidableInstances #-} {-# language AllowAmbiguousTypes #-} {-# language DataKinds #-}@@ -19,6 +20,7 @@ LessArbitrary(..) , oneof , choose+ , budgetChoose , CostGen(..) , (<$$$>) , ($$$?)@@ -51,10 +53,9 @@ import qualified Test.QuickCheck as QC import Data.Hashable --- ~\~ begin <<less-arbitrary.md|costgen>>[0]-newtype Cost = Cost Int - deriving (Eq,Ord,Enum,Bounded,Num)+import Test.LessArbitrary.Cost +-- ~\~ begin <<less-arbitrary.md|costgen>>[0] newtype CostGen a = CostGen { runCostGen :: State.StateT Cost QC.Gen a }@@ -323,6 +324,12 @@ => (a, a) -> CostGen a choose (a,b) = CostGen $ lift $ QC.choose (a, b)++-- | Choose but only up to the budget (for array and list sizes)+budgetChoose :: CostGen Int+budgetChoose = do+ Cost b <- currentBudget+ CostGen $ lift $ QC.choose (1, b) -- ~\~ end -- ~\~ begin <<less-arbitrary.md|lifting-arbitrary>>[2] frequency :: [(Int, CostGen a)] -> CostGen a
+ src/Test/LessArbitrary/Cost.hs view
@@ -0,0 +1,10 @@+-- ~\~ language=Haskell filename=src/Test/LessArbitrary/Cost.hs+-- ~\~ begin <<less-arbitrary.md|src/Test/LessArbitrary/Cost.hs>>[0]+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+module Test.LessArbitrary.Cost where++-- ~\~ begin <<less-arbitrary.md|cost>>[0]+newtype Cost = Cost Int+ deriving (Eq,Ord,Enum,Bounded,Num)+-- ~\~ end+-- ~\~ end