File: FocusList.hs

package info (click to toggle)
haskell-focuslist 0.1.1.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 124 kB
  • sloc: haskell: 755; makefile: 6
file content (45 lines) | stat: -rw-r--r-- 1,344 bytes parent folder | download | duplicates (2)
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
38
39
40
41
42
43
44
45
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

module Test.FocusList where

import Data.GenValidity.Sequence ()
import Test.Hspec (Spec)
import Test.QuickCheck (Gen)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.Hedgehog (testProperty)
import Test.Tasty.Hspec (testSpec)
import Test.Validity (GenInvalid, GenUnchecked, GenValid(genValid), Validity(validate), check, eqSpec, genValidSpec)

import Data.FocusList (Focus, FocusList, genValidFL, invariantFL)

import Test.FocusList.Invariants (testInvariantsInFocusList)

instance GenUnchecked Focus

instance GenUnchecked a => GenUnchecked (FocusList a)

instance Validity (FocusList a) where
  validate fl = check (invariantFL fl) "the FocusList has been constructed correctly"

instance (GenValid a, GenUnchecked a) => GenValid (FocusList a) where
  genValid :: Gen (FocusList a)
  genValid = genValidFL genValid

instance (GenInvalid a, GenUnchecked a) => GenInvalid (FocusList a)

focusListTestsIO :: IO TestTree
focusListTestsIO = do
  specs <- testSpec "validity tests" validitySpec
  pure $
    testGroup
      "FocusList"
      [ testProperty "invariants in FocusList" testInvariantsInFocusList
      , specs
      ]

validitySpec :: Spec
validitySpec = do
  eqSpec @(FocusList String)
  genValidSpec @(FocusList String)