genvalidity-sydtest-lens 0.0.0.0 → 1.0.0.0
raw patch · 5 files changed
+49/−87 lines, 5 filesdep ~genvalidity
Dependency ranges changed: genvalidity
Files
- CHANGELOG.md +11/−0
- LICENSE +1/−1
- genvalidity-sydtest-lens.cabal +8/−5
- src/Test/Syd/Validity/Lens.hs +16/−63
- test/Test/Syd/Validity/LensSpec.hs +13/−18
+ CHANGELOG.md view
@@ -0,0 +1,11 @@+# Changelog++## [1.0.0.0] - 2021-11-20++* Compatibility with `genvalidity >= 1.0.0.0`+* Renamed every combinator that ends in `OnValid` (or similar) to not have that suffix anymore.++### Removed++* Every combinator that relates to unchecked or invalid values.+
LICENSE view
@@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2020 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
genvalidity-sydtest-lens.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.2.+-- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack name: genvalidity-sydtest-lens-version: 0.0.0.0+version: 1.0.0.0 synopsis: Standard spec's for lens for sydtest description: Standard spec's for lens (van Laarhoven encoding) category: Testing@@ -13,10 +13,13 @@ bug-reports: https://github.com/NorfairKing/validity/issues author: Tom Sydney Kerckhove maintainer: syd@cs-syd.eu-copyright: Copyright: (c) 2020 Tom Sydney Kerckhove+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@@ -33,7 +36,7 @@ build-depends: QuickCheck , base >=4.9 && <=5- , genvalidity >=0.5+ , genvalidity >=1.0 , genvalidity-sydtest , microlens , sydtest@@ -52,7 +55,7 @@ sydtest-discover:sydtest-discover build-depends: base- , genvalidity >=0.7+ , genvalidity , genvalidity-sydtest , genvalidity-sydtest-lens , microlens
src/Test/Syd/Validity/Lens.hs view
@@ -5,18 +5,15 @@ -- | Standard test `Spec`s for optics module Test.Syd.Validity.Lens- ( lensSpecOnValid,- lensSpec,+ ( lensSpec, lensSpecOnArbitrary, lensSpecOnGen, lensLaw1, lensLaw2, lensLaw3,- lensGettingProducesValidOnValid, lensGettingProducesValid, lensGettingProducesValidOnArbitrary, lensGettingProducesValidOnGen,- lensSettingProducesValidOnValid, lensSettingProducesValid, lensSettingProducesValidOnArbitrary, lensSettingProducesValidOnGen,@@ -34,49 +31,27 @@ -- -- Example usage: ----- > lensSpecOnValid ((_2) :: Lens (Rational, Rational) (Rational, Rational) Rational Rational)-lensSpecOnValid ::- forall s b.- (Show b, Eq b, GenValid b, Show s, Eq s, GenValid s) =>- Lens s s b b ->- Spec-lensSpecOnValid l =- lensSpecOnGen- l- (genValid @b)- "valid values"- shrinkValid- (genValid @s)- "valid values"- shrinkValid---- | Standard test spec for properties lenses for unchecked values------ Example usage:--- -- > lensSpec ((_2) :: Lens (Int, Int) (Int, Int) Int Int) lensSpec :: forall s b. ( Show b, Eq b,- GenUnchecked b,- Validity b,+ GenValid b, Show s, Eq s,- GenUnchecked s,- Validity s+ GenValid s ) => Lens s s b b -> Spec lensSpec l = lensSpecOnGen l- (genUnchecked @b)- "unchecked values"- shrinkUnchecked- (genUnchecked @s)- "unchecked values"- shrinkUnchecked+ (genValid @b)+ "valid values"+ shrinkValid+ (genValid @s)+ "valid values"+ shrinkValid -- | Standard test spec for properties lenses for arbitrary values --@@ -210,21 +185,11 @@ -- -- Example Usage: ----- prop> lensGettingProducesValidOnValid ((_2) :: Lens (Rational, Rational) (Rational, Rational) Rational Rational)-lensGettingProducesValidOnValid ::- (Show s, GenValid s, Show b, GenValid b) => Lens s s b b -> Property-lensGettingProducesValidOnValid l =- lensGettingProducesValidOnGen l genValid shrinkValid---- | A property combinator to test whether getting values via a lens on unchecked values produces valid values.------ Example Usage:--- -- prop> lensGettingProducesValid ((_2) :: Lens (Int, Int) (Int, Int) Int Int) lensGettingProducesValid ::- (Show s, GenUnchecked s, Show b, Validity b) => Lens s s b b -> Property+ (Show s, GenValid s, Show b, Validity b) => Lens s s b b -> Property lensGettingProducesValid l =- lensGettingProducesValidOnGen l genUnchecked shrinkUnchecked+ lensGettingProducesValidOnGen l genValid shrinkValid -- | A property combinator to test whether getting values via a lens on arbitrary values produces valid values. --@@ -258,30 +223,18 @@ -- -- Example usage: ----- prop> lensSettingProducesValidOnValid ((_2) :: Lens (Rational, Rational) (Rational, Rational) Rational Rational)-lensSettingProducesValidOnValid ::- (Show s, GenValid s, Show b, GenValid b, Show t, Validity t) =>- Lens s t a b ->- Property-lensSettingProducesValidOnValid l =- lensSettingProducesValidOnGen l genValid shrinkValid genValid shrinkValid---- | A property combinator to test whether setting unchecked values via a lens on unchecked values produces valid values.------ Example usage:--- -- prop> lensSettingProducesValid ((_2) :: Lens (Int, Int) (Int, Int) Int Int) lensSettingProducesValid ::- (Show s, GenUnchecked s, Show b, GenUnchecked b, Show t, Validity t) =>+ (Show s, GenValid s, Show b, GenValid b, Show t, Validity t) => Lens s t a b -> Property lensSettingProducesValid l = lensSettingProducesValidOnGen l- genUnchecked- shrinkUnchecked- genUnchecked- shrinkUnchecked+ genValid+ shrinkValid+ genValid+ shrinkValid -- | A property combinator to test whether setting arbitrary values via a lens on arbitrary values produces valid values. --
test/Test/Syd/Validity/LensSpec.hs view
@@ -1,6 +1,5 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TypeApplications #-} module Test.Syd.Validity.LensSpec where @@ -12,10 +11,10 @@ spec :: Spec spec = do- describe "lensSpecOnValid" $- lensSpecOnValid+ describe "lensSpec" $ do+ lensSpec ((_2) :: Lens (Int, Int) (Int, Int) Int Int)+ lensSpec ((_2) :: Lens (Rational, Rational) (Rational, Rational) Rational Rational)- describe "lensSpec" $ lensSpec ((_2) :: Lens (Int, Int) (Int, Int) Int Int) describe "lensSpecOnArbitrary" $ lensSpecOnArbitrary ((_2) :: Lens (Rational, Rational) (Rational, Rational) Rational Rational)@@ -28,13 +27,12 @@ ((,) <$> (negate . abs <$> genValid) <*> (negate . abs <$> genValid)) "tuples of negative valid doubles" (const [])- describe "lensGettingProducesValidOnValid" $- it "holds for (_2) for doubles" $- lensGettingProducesValidOnValid- ((_2) :: Lens (Rational, Rational) (Rational, Rational) Rational Rational)- describe "lensGettingProducesValid" $+ describe "lensGettingProducesValid" $ do it "holds for (_2) for ints" $ lensGettingProducesValid ((_2) :: Lens (Int, Int) (Int, Int) Int Int)+ it "holds for (_2) for doubles" $+ lensGettingProducesValid+ ((_2) :: Lens (Rational, Rational) (Rational, Rational) Rational Rational) describe "lensGettingProducesValidOnArbitrary" $ it "holds for (_2) for doubles" $ lensGettingProducesValidOnArbitrary@@ -45,13 +43,12 @@ ((_2) :: Lens (Rational, Rational) (Rational, Rational) Rational Rational) ((,) <$> (negate . abs <$> genValid) <*> (negate . abs <$> genValid)) (const [])- describe "lensSettingProducesValidOnValid" $- it "holds for (_2) for doubles" $- lensSettingProducesValidOnValid- ((_2) :: Lens (Rational, Rational) (Rational, Rational) Rational Rational)- describe "lensSettingProducesValid" $+ describe "lensSettingProducesValid" $ do it "holds for (_2) for ints" $ lensSettingProducesValid ((_2) :: Lens (Int, Int) (Int, Int) Int Int)+ it "holds for (_2) for doubles" $+ lensSettingProducesValid+ ((_2) :: Lens (Rational, Rational) (Rational, Rational) Rational Rational) describe "lensSettingProducesValidOnArbitrary" $ it "holds for (_2) for doubles" $ lensSettingProducesValidOnArbitrary@@ -65,9 +62,9 @@ ((,) <$> (negate . abs <$> genValid) <*> (negate . abs <$> genValid)) (const []) describe "myBoolLens" $- lensSpecOnValid myBoolLens+ lensSpec myBoolLens describe "myRationalLens" $- lensSpecOnValid myRationalLens+ lensSpec myRationalLens data MyRecord = MyRecord { myBool :: Bool,@@ -76,8 +73,6 @@ deriving (Show, Eq, Generic) instance Validity MyRecord--instance GenUnchecked MyRecord instance GenValid MyRecord