| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Test.Tasty.Lens.Prism
Contents
Description
This module is intended to be imported qualified, for example:
import qualified Test.Tasty.Lens.Prism as Prism
- test :: (Eq s, Eq a, Show s, Show a, Serial IO s, Serial IO a, Serial Identity a, CoSerial IO a) => Prism' s a -> TestTree
- testSeries :: (Eq s, Eq a, Show s, Show a, Serial IO a, Serial Identity a, CoSerial IO a) => Prism' s a -> Series IO s -> TestTree
- testExhaustive :: (Eq s, Eq a, Show s, Show a, Serial IO s, Serial IO a, Serial Identity a, CoSerial IO a) => Prism' s a -> TestTree
- module Test.SmallCheck.Lens.Prism
Tests
test :: (Eq s, Eq a, Show s, Show a, Serial IO s, Serial IO a, Serial Identity a, CoSerial IO a) => Prism' s a -> TestTree Source
A Prism' is only legal if it's a valid Traversal' and if the following
laws hold:
preview l (review l b) ≡ Just b"
maybe s (review l) (preview l s) ≡ s
It uses the Serial and CoSerial instances for s and a. If you are
not creating your own orphan instances be aware of combinatorial explosion
since the default implementations usually aim for exhaustivity.
This also uses Test.Tasty.Lens.Traversal.test, with the
Maybe functor, to validate the Prism' is a valid Traversal'.
testSeries :: (Eq s, Eq a, Show s, Show a, Serial IO a, Serial Identity a, CoSerial IO a) => Prism' s a -> Series IO s -> TestTree Source
A Prism' is only legal if it's a valid Traversal' and if the following
laws hold:
preview l (review l b) ≡ Just b"
maybe s (review l) (preview l s) ≡ s
Here you explicitly pass a custom Series for s, while for a the
Serial instance is used. If you want to fine tune both Series, you
should create your own TestTree.
This also uses Test.Tasty.Lens.Traversal.testSeries, with
the Maybe functor and the custom s Series, to validate the Prism' is
a valid Traversal'.
testExhaustive :: (Eq s, Eq a, Show s, Show a, Serial IO s, Serial IO a, Serial Identity a, CoSerial IO a) => Prism' s a -> TestTree Source
A Prism' is only legal if it's a valid Traversal' and if the following
laws hold:
preview l (review l b) ≡ Just b"
maybe s (review l) (preview l s) ≡ s
This is the same as test except it uses
Test.Tasty.Lens.Traversal.testExhaustive to validate
Traversal' laws. Be aware of combinatorial explosions.
Re-exports
module Test.SmallCheck.Lens.Prism