]> Git — Sourcephile - gargantext.git/blob - src-test/Parsers/Types.hs
Added Arbitrary instance for ParseError
[gargantext.git] / src-test / Parsers / Types.hs
1 {-# LANGUAGE NoImplicitPrelude #-}
2
3 module Parsers.Types where
4
5 import Gargantext.Prelude
6
7 import Test.QuickCheck
8
9 import Text.Parsec.Pos
10 import Text.Parsec.Error (ParseError(..), Message(..), newErrorMessage)
11
12 instance Arbitrary Message where
13 arbitrary = do
14 msgContent <- arbitrary
15 oneof $ return <$> [SysUnExpect msgContent
16 , UnExpect msgContent
17 , Expect msgContent
18 , Message msgContent
19 ]
20
21 instance Arbitrary SourcePos where
22 arbitrary = do
23 sn <- arbitrary
24 l <- arbitrary
25 c <- arbitrary
26 return $ newPos sn l c
27
28 instance Arbitrary ParseError where
29 arbitrary = do
30 sp <- arbitrary
31 msg <- arbitrary
32 return $ newErrorMessage msg sp