File: GCoArbitraryExample.hs

package info (click to toggle)
haskell-quickcheck 2.14.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 432 kB
  • sloc: haskell: 5,104; sh: 32; makefile: 5
file content (24 lines) | stat: -rw-r--r-- 602 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
{-# LANGUAGE DeriveGeneric, ScopedTypeVariables, TemplateHaskell #-}

module Main where

import GHC.Generics (Generic)
import Test.QuickCheck
import Test.QuickCheck.Function

data D a = C1 a | C2 deriving (Eq, Show, Read, Generic)


instance Arbitrary a => Arbitrary (D a) where arbitrary = error "not implemented"
instance CoArbitrary a => CoArbitrary (D a)

instance (Show a, Read a) => Function (D a) where
  function = functionShow

prop_coarbitrary (Fun _ f) =
  expectFailure $
  withMaxSuccess 1000 $
  f (C1 (2::Int)) `elem` [0, 1 :: Int]

return []
main = do True <- $quickCheckAll; return ()