tasty-lens-0.3.1: Tasty TestTrees for Lens validation

Safe HaskellNone
LanguageHaskell2010

Test.Tasty.Lens.Lens

Contents

Description

This module is intended to be imported qualified, for example:

import qualified Test.Tasty.Lens.Lens as Lens

Synopsis

Tests

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

A Lens' is only legal if it's a valid Traversal' 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

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 Lens' is a valid Traversal'.

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

A Lens' is only legal if it's a valid Traversal' 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

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 Lens' 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) => Lens' s a -> TestTree Source

A Lens' is only legal if it's a valid Traversal' 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

This is like the same as test except it uses Test.Tasty.Lens.Traversal.testExhaustive to validate Traversal' laws. Be aware of combinatorial explosions.

Re-exports