File: TastyExtras.hs

package info (click to toggle)
haskell-text-builder-dev 0.3.5-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 124 kB
  • sloc: haskell: 1,186; makefile: 5
file content (37 lines) | stat: -rw-r--r-- 928 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{-# OPTIONS_GHC -Wno-orphans #-}

module TextBuilderDev.TastyExtras where

import qualified Data.Text.Lazy.Builder as TextLazyBuilder
import Test.Tasty
import Test.Tasty.QuickCheck
import qualified TextBuilderDev as B
import Prelude hiding (choose)

-- * --

instance Arbitrary TextLazyBuilder.Builder where
  arbitrary =
    TextLazyBuilder.fromLazyText <$> arbitrary

-- * --

isomorphismLaws ::
  (B.IsomorphicToTextBuilder a, Eq a, Show a, Arbitrary a) =>
  String ->
  Proxy a ->
  TestTree
isomorphismLaws subject proxy =
  testGroup subject
    $ [ testProperty "fromTextBuilder . toTextBuilder == id"
          $ (===)
          <$> B.fromTextBuilder
          . B.toTextBuilder
          <*> flip asProxyTypeOf proxy,
        testProperty "toTextBuilder . fromTextBuilder == id"
          $ (===)
          <$> B.toTextBuilder
          . flip asProxyTypeOf proxy
          . B.fromTextBuilder
          <*> id
      ]