All Projects → NorfairKing → Validity

NorfairKing / Validity

Validity and validity-based testing

Programming Languages

haskell
3896 projects

Validity and validity-based testing

Build Status

Package Hackage Stackage
validity Hackage Stackage
validity-aeson Hackage Stackage
validity-bytestring Hackage Stackage
validity-containers Hackage Stackage
validity-path Hackage Stackage
validity-persistent Hackage Stackage
validity-primitive Hackage Stackage
validity-scientific Hackage Stackage
validity-text Hackage Stackage
validity-time Hackage Stackage
validity-unordered-containers Hackage Stackage
validity-uuid Hackage Stackage
validity-vector Hackage Stackage
genvalidity Hackage Stackage
genvalidity-aeson Hackage Stackage
genvalidity-bytestring Hackage Stackage
genvalidity-containers Hackage Stackage
genvalidity-criterion Hackage Stackage
genvalidity-path Hackage Stackage
genvalidity-persistent Hackage Stackage
genvalidity-property Hackage Stackage
genvalidity-scientific Hackage Stackage
genvalidity-text Hackage Stackage
genvalidity-time Hackage Stackage
genvalidity-unordered-containers Hackage Stackage
genvalidity-uuid Hackage Stackage
genvalidity-vector Hackage Stackage
genvalidity-hspec Hackage Stackage
genvalidity-hspec-aeson Hackage Stackage
genvalidity-hspec-binary Hackage Stackage
genvalidity-hspec-cereal Hackage Stackage
genvalidity-hspec-hashable Hackage Stackage
genvalidity-hspec-persistent Hackage Stackage
genvalidity-hspec-optics Hackage Stackage
genvalidity-sydtest Hackage Stackage
genvalidity-sydtest-aeson Hackage Stackage
genvalidity-sydtest-binary Hackage Stackage
genvalidity-sydtest-cereal Hackage Stackage
genvalidity-sydtest-hashable Hackage Stackage
genvalidity-sydtest-persistent Hackage Stackage
genvalidity-sydtest-optics Hackage Stackage

Why?

Make write correct software cheaper.

  • Cheap properties
  • Free generators
  • Free shrinking

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

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 .

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].