packages feed

less-arbitrary 0.1.3.0 → 0.1.4.0

raw patch · 3 files changed

+24/−8 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Test.LessArbitrary: ($$$?) :: CostGen a -> CostGen a -> CostGen a
+ Test.LessArbitrary: ($$$?) :: HasCallStack => CostGen a -> CostGen a -> CostGen a
- Test.LessArbitrary: oneof :: [CostGen a] -> CostGen a
+ Test.LessArbitrary: oneof :: HasCallStack => [CostGen a] -> CostGen a

Files

CHANGELOG.md view
@@ -1,5 +1,8 @@ # Revision history for less-arbitrary +0.1.4.0 -- 2020-12-14+* Added `HasCallStack` constraint to get better error locations.+ 0.1.3.0 -- 2020-12-14 * Added `suchThat`. 
less-arbitrary.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 4ea65eec84a09bbf7d6249aa61d255e145ccba99f5e263d6bdc399a966156b71+-- hash: 3086e65c4d07897ec67398597f75a2ce6165eb0b5419288640f12e83614b7c02  name:           less-arbitrary-version:        0.1.3.0+version:        0.1.4.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?
src/Test/LessArbitrary.hs view
@@ -50,6 +50,7 @@ import GHC.Generics as G import GHC.Generics as Generic import GHC.TypeLits+import GHC.Stack import qualified Test.QuickCheck as QC import Data.Hashable @@ -70,11 +71,14 @@  -- ~\~ begin <<less-arbitrary.md|spend>>[0] spend :: Cost -> CostGen ()-spend c = CostGen $ State.modify (-c+)+spend c = do+  CostGen $ State.modify (-c+)+  checkBudget -- ~\~ end  -- ~\~ begin <<less-arbitrary.md|budget>>[0]-($$$?) :: CostGen a+($$$?) :: HasCallStack+       => CostGen a        -> CostGen a        -> CostGen a cheapVariants $$$? costlyVariants = do@@ -83,13 +87,20 @@      | budget > -10000      -> cheapVariants      | otherwise            -> error $        "Recursive structure with no loop breaker."- -- ~\~ end -- ~\~ begin <<less-arbitrary.md|budget>>[1]+checkBudget :: HasCallStack => CostGen ()+checkBudget = do+  budget <- CostGen State.get+  if budget < -10000+    then error "Recursive structure with no loop breaker."+    else return ()+-- ~\~ end+-- ~\~ begin <<less-arbitrary.md|budget>>[2] currentBudget :: CostGen Cost currentBudget = CostGen State.get -- ~\~ end--- ~\~ begin <<less-arbitrary.md|budget>>[2]+-- ~\~ begin <<less-arbitrary.md|budget>>[3] -- unused: loop breaker message type name type family ShowType k where   ShowType (D1 ('MetaData name _ _ _) _) = name@@ -312,7 +323,8 @@ forAll :: CostGen a -> (a -> CostGen b) -> CostGen b forAll gen prop = gen >>= prop -oneof   :: [CostGen a] -> CostGen a+oneof   :: HasCallStack+        => [CostGen a] -> CostGen a oneof [] = error            "LessArbitrary.oneof used with empty list" oneof gs = choose (0,length gs - 1) >>= (gs !!)@@ -341,7 +353,8 @@        cg `suchThat` pred -- ~\~ end -- ~\~ begin <<less-arbitrary.md|lifting-arbitrary>>[2]-frequency :: [(Int, CostGen a)] -> CostGen a+frequency   :: HasCallStack+            => [(Int, CostGen a)] -> CostGen a frequency [] =   error $ "LessArbitrary.frequency "        ++ "used with empty list"