tasty-lens-0.3.1: Tasty TestTrees for Lens validation

Safe HaskellNone
LanguageHaskell2010

Test.Tasty.Lens.Iso

Contents

Description

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

import qualified Test.Tasty.Lens.Iso as Iso

Synopsis

Tests

test :: (Eq s, Eq a, Show s, Show a, Serial Identity s, Serial IO s, CoSerial IO s, Serial Identity a, Serial IO a, CoSerial IO a) => 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

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 uses Test.Tasty.Lens.Lens.test to validate the Iso' is a valid Lens' in both normal and reverse form.

testSeries :: (Eq s, Eq a, Show s, Show a, Serial Identity s, Serial IO s, CoSerial IO s, Serial Identity a, Serial IO a, CoSerial IO a) => Iso' s a -> Series IO s -> Series IO 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

As in test both s and a need to be Serial and CoSerial instances, but here you explicitly pass custom Series of s and a for the forward case, while the reverse case still uses Serial and CoSerial instances. If you want to fine tune both the forward and reverse cases, you should create your own TestTree.

This uses Test.Tasty.Lens.Lens.testSeries, with the custom Series for s and a, to validate the Iso' is a valid Lens' in both normal and reverse form.

testExhaustive :: (Eq s, Eq a, Show s, Show a, Serial Identity s, Serial IO s, CoSerial IO s, Serial Identity a, Serial IO a, CoSerial IO a) => 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

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

Re-exports