Popularity
9.4
Declining
Activity
6.0
Growing
156
9
31
Monthly Downloads: 261
Programming language: Haskell
License: MIT License
Add another 'validity' Package
README
Validity and validity-based testing
Why?
to make writing correct software cheaper.
- Free generators
- Free shrinking
- Cheap properties
Cheap properties
- Property Combinators:
specify "inverse functions" $ inverseFunctions (+1) (-1)
specify "equivalent functions" $ equivalent ((+ 1) . (- 1)) id
specify "transitivity" $ transitivity ((>) :: Int -> Int -> Bool)
specify "symmetry" $ symmetry ((==) :: Int -> Int -> Bool)
- Test suite combinators:
ordSpec @Int
Ord Int
(<=) :: Int -> Int -> Bool
is reflexive for "even Int"'s
+++ OK, passed 100 tests.
is antisymmetric for "even Int"'s
+++ OK, passed 100 tests.
is transitive for "even Int"'s
+++ OK, passed 100 tests.
is equivalent to (\a b -> compare a b /= GT) for "even Int"'s
+++ OK, passed 100 tests.
(>=) :: Int -> Int -> Bool
is reflexive for "even Int"'s
+++ OK, passed 100 tests.
is antisymmetric for "even Int"'s
+++ OK, passed 100 tests.
is transitive for "even Int"'s
+++ OK, passed 100 tests.
is equivalent to (\a b -> compare a b /= LT) for "even Int"'s
+++ OK, passed 100 tests.
(<) :: Int -> Int -> Bool
is antireflexive for "even Int"'s
+++ OK, passed 100 tests.
is transitive for "even Int"'s
+++ OK, passed 100 tests.
is equivalent to (\a b -> compare a b == LT) for "even Int"'s
+++ OK, passed 100 tests.
(>) :: Int -> Int -> Bool
is antireflexive for "even Int"'s
+++ OK, passed 100 tests.
is transitive for "even Int"'s
+++ OK, passed 100 tests.
is equivalent to (\a b -> compare a b == GT) for "even Int"'s
+++ OK, passed 100 tests.
Free generators
data MyType = MyType
{ myRational :: Rational
, myBool :: Bool
} deriving (Show, Eq, Generic)
instance Validity MyType -- Implementation is derived via Generic
instance GenUnchecked MyType -- Implementation is derived via Generic
instance GenValid MyType -- Default implementation via GenUnchecked and Validity
genValid :: Gen MyType -- Free access to a generator
Free shrinking
shrinkValid :: MyType -> [MyType] -- Free access to a _valid_ shrinking function
Further Documentation
- [Usage example](docs/USAGE_EXAMPLE.md)
- [Fully worked example](docs/FULLY_WORKED_EXAMPLE.md)
- [High-level package overview](docs/PACKAGE_OVERVIEW.md)
Cachix cache
There is a cachix cache for this project.
To use it, use cachix use validity
or add the appropriate details to your nixos configuration.
Sponsor this project
Validity is free and open-source software. Building it takes time, energy and money. Please consider supporting the project at https://cs-syd.eu/support .