genvalidity-aeson 0.3.0.0 → 1.0.0.0
raw patch · 7 files changed
+103/−48 lines, 7 filesdep +criteriondep +deepseqdep +genvalidity-criteriondep ~aesondep ~basedep ~genvaliditysetup-changed
Dependencies added: criterion, deepseq, genvalidity-criterion
Dependency ranges changed: aeson, base, genvalidity
Files
- CHANGELOG.md +26/−0
- LICENSE +1/−1
- Setup.hs +0/−3
- bench/Main.hs +15/−0
- genvalidity-aeson.cabal +29/−13
- src/Data/GenValidity/Aeson.hs +21/−26
- test/Test/Validity/AesonSpec.hs +11/−5
+ CHANGELOG.md view
@@ -0,0 +1,26 @@+# Changelog++## [1.0.0.0] - 2021-11-20++### Changed++* Compatibility with `genvalidity >= 1.0.0.0`+* Improved shrinking for 'Value'.++## [0.3.0.1] - 2020-02-10++### Added++* Added benchmarks.+* Added a test to make sure that it generates renderable values.++## [0.3.0.0] - 2019-03-06++### Changed++* Removed the 'GenUnchecked' and 'GenInvalid' instance for 'Value'.++## Older versions++No history before version 0.3.0.0+
LICENSE view
@@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 Tom Sydney Kerckhove+Copyright (c) 2016-2021 Tom Sydney Kerckhove Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
− Setup.hs
@@ -1,3 +0,0 @@-import Distribution.Simple--main = defaultMain
+ bench/Main.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE AllowAmbiguousTypes #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeApplications #-}++module Main where++import Criterion.Main as Criterion+import Data.Aeson+import Data.GenValidity.Aeson ()+import Data.GenValidity.Criterion++main :: IO ()+main =+ Criterion.defaultMain+ [genValidBench @Array, genValidBench @Object, genValidBench @Value]
genvalidity-aeson.cabal view
@@ -1,25 +1,24 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.1.+-- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack------ hash: d45a5c5de46da85d9d5f805bc0b5b69757c4d185ca5656d39b3c8225a0df0bb5 name: genvalidity-aeson-version: 0.3.0.0+version: 1.0.0.0 synopsis: GenValidity support for aeson-description: Please see README.md category: Testing homepage: https://github.com/NorfairKing/validity#readme bug-reports: https://github.com/NorfairKing/validity/issues author: Tom Sydney Kerckhove-maintainer: syd.kerckhove@gmail.com,- nick.van.den.broeck666@gmail.com-copyright: Copyright: (c) 2017-2019 Tom Sydney Kerckhove+maintainer: syd@cs-syd.eu+copyright: Copyright: (c) 2016-2021 Tom Sydney Kerckhove license: MIT license-file: LICENSE build-type: Simple+extra-source-files:+ LICENSE+ CHANGELOG.md source-repository head type: git@@ -34,9 +33,9 @@ src build-depends: QuickCheck- , aeson- , base <5- , genvalidity >=0.8+ , aeson >=1.4.0.0+ , base >=4.10 && <5+ , genvalidity >=1.0 , genvalidity-scientific >=0.2 , genvalidity-text >=0.5 , genvalidity-unordered-containers >=0.2@@ -55,10 +54,27 @@ test/ ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall build-depends:- aeson- , base >=4.9 && <=5+ aeson >=1.4.0.0+ , base >=4.10 && <5+ , deepseq , genvalidity , genvalidity-aeson , genvalidity-hspec , hspec+ default-language: Haskell2010++benchmark genvalidity-aeson-bench+ type: exitcode-stdio-1.0+ main-is: Main.hs+ other-modules:+ Paths_genvalidity_aeson+ hs-source-dirs:+ bench/+ ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall+ build-depends:+ aeson >=1.4.0.0+ , base >=4.10 && <5+ , criterion+ , genvalidity-aeson+ , genvalidity-criterion default-language: Haskell2010
src/Data/GenValidity/Aeson.hs view
@@ -1,10 +1,8 @@ {-# OPTIONS_GHC -fno-warn-orphans #-}-{-# LANGUAGE CPP #-} module Data.GenValidity.Aeson where-#if !MIN_VERSION_base(4,8,0)-import Data.Functor ((<$>))-#endif++import Data.Aeson import Data.Foldable (toList) import Data.GenValidity import Data.GenValidity.HashMap ()@@ -12,28 +10,25 @@ import Data.GenValidity.Text () import Data.GenValidity.Vector () import Data.Validity.Aeson ()--import Data.Aeson- import Test.QuickCheck instance GenValid Value where- genValid =- oneof- [ Object <$> genValid- , Array <$> genValid- , String <$> genValid- , Number <$> genValid- , Bool <$> genValid- , pure Null- ]- shrinkValid (Object hm) =- (Object <$> shrinkValid hm) ++- toList hm ++ concatMap shrinkValid (toList hm)- shrinkValid (Array a) =- (Array <$> shrinkValid a) ++- toList a ++ concatMap shrinkValid (toList a)- shrinkValid (String s) = String <$> shrinkValid s- shrinkValid (Number s) = Number <$> shrinkValid s- shrinkValid (Bool s) = Bool <$> shrinkValid s- shrinkValid Null = []+ genValid =+ oneof+ [ Object <$> genValid,+ Array <$> genValid,+ String <$> genValid,+ Number <$> genValid,+ Bool <$> genValid,+ pure Null+ ]+ shrinkValid (Object hm) =+ toList hm+ ++ (Object <$> shrinkValid hm)+ shrinkValid (Array a) =+ toList a+ ++ (Array <$> shrinkValid a)+ shrinkValid (String s) = String <$> shrinkValid s+ shrinkValid (Number s) = Number <$> shrinkValid s+ shrinkValid (Bool s) = Bool <$> shrinkValid s+ shrinkValid Null = []
test/Test/Validity/AesonSpec.hs view
@@ -2,11 +2,17 @@ module Test.Validity.AesonSpec where -import Test.Hspec--import Data.Aeson (Value)+import Control.DeepSeq+import Control.Exception (evaluate)+import Data.Aeson (Value, encode) import Data.GenValidity.Aeson ()-import Test.Validity.GenValidity+import Test.Hspec+import Test.Validity spec :: Spec-spec = genValidSpec @Value+spec = do+ genValidSpec @Value+ describe "genValid :: Gen Value" $+ it "produces deepseqable values" $+ forAllValid $ \v ->+ evaluate (deepseq (encode (v :: Value)) ()) `shouldReturn` ()