smallcheck-lens-0.1: SmallCheck lens laws

Safe HaskellNone
LanguageHaskell2010

Test.Tasty.SmallCheck.Lens

Contents

Description

Preassembled tasty test trees using Serial instances and one-to-one zipping of elements in Series (see zipLogic) when Serial functions are needed.

If you need more exhaustive testing coverage or if you experience combinatorial explosion you can either override the default Serial instances with custom ones or you can create your own tasty test trees using the functions at Test.SmallCheck.Lens.

Synopsis

Test Trees

testIso :: (Eq s, Eq a, Show s, Show a, Serial IO a, Serial Identity a, CoSerial IO a, Serial IO s, Serial Identity s, CoSerial IO s) => Iso' s a -> TestTree Source

An Iso' is only legal if the following laws hold:

  1. s ^. l . from l ≡ s
  2. s ^. from l . l ≡ s

An Iso' is also a valid Lens' in both normal and reverse form. Check testLens.

testLens :: (Eq s, Eq a, Show s, Show a, Serial IO a, Serial Identity a, CoSerial IO a, Serial IO s) => Lens' s a -> TestTree Source

A Lens' is only legal if it is a valid Traversal' (see testTraversal), and if the following laws hold:

  1. view l (set l b a)  ≡ b
  2. set l (view l a) a  ≡ a
  3. set l c (set l b a) ≡ set l c a

testPrism :: (Eq s, Eq a, Show s, Show a, Serial IO a, Serial Identity a, CoSerial IO a, Serial IO s) => Prism' s a -> TestTree Source

A Prism' is only legal if it is a valid Traversal' (see testTraversal), and if the following laws hold:

  1. preview l (review l b) ≡ Just b"
  2. maybe s (review l) (preview l s) ≡ s

testSetter :: (Eq s, Show s, Show a, Serial IO a, Serial Identity a, CoSerial IO a, Serial IO s) => ASetter' s a -> TestTree Source

A Setter is only legal if the following laws hold:

  1. set l y (set l x a) ≡ set l y a
  2. over l id ≡ id
  3. over l f . over l g ≡ over l (f . g)

testTraversal :: forall s a. (Eq s, Show s, Show a, Serial IO a, Serial Identity a, CoSerial IO a, Serial IO s) => Traversal' s a -> TestTree Source

A Traversal' is only legal if it is a valid Setter' (see testSetter), and if the following laws hold:

  1. t pure ≡ pure
  2. fmap (t f) . t g ≡ getCompose . t (Compose . fmap f . g)