{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
module Distribution.Types.TestType (
TestType(..),
knownTestTypes,
testTypeExe,
testTypeLib,
) where
import Distribution.Compat.Prelude
import Distribution.Version
import Prelude ()
import Distribution.Parsec
import Distribution.Pretty
import Text.PrettyPrint (char, text)
data TestType = TestTypeExe Version
| TestTypeLib Version
| TestTypeUnknown String Version
deriving (forall x. Rep TestType x -> TestType
forall x. TestType -> Rep TestType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TestType x -> TestType
$cfrom :: forall x. TestType -> Rep TestType x
Generic, Int -> TestType -> ShowS
[TestType] -> ShowS
TestType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestType] -> ShowS
$cshowList :: [TestType] -> ShowS
show :: TestType -> String
$cshow :: TestType -> String
showsPrec :: Int -> TestType -> ShowS
$cshowsPrec :: Int -> TestType -> ShowS
Show, ReadPrec [TestType]
ReadPrec TestType
Int -> ReadS TestType
ReadS [TestType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TestType]
$creadListPrec :: ReadPrec [TestType]
readPrec :: ReadPrec TestType
$creadPrec :: ReadPrec TestType
readList :: ReadS [TestType]
$creadList :: ReadS [TestType]
readsPrec :: Int -> ReadS TestType
$creadsPrec :: Int -> ReadS TestType
Read, TestType -> TestType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestType -> TestType -> Bool
$c/= :: TestType -> TestType -> Bool
== :: TestType -> TestType -> Bool
$c== :: TestType -> TestType -> Bool
Eq, Eq TestType
TestType -> TestType -> Bool
TestType -> TestType -> Ordering
TestType -> TestType -> TestType
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: TestType -> TestType -> TestType
$cmin :: TestType -> TestType -> TestType
max :: TestType -> TestType -> TestType
$cmax :: TestType -> TestType -> TestType
>= :: TestType -> TestType -> Bool
$c>= :: TestType -> TestType -> Bool
> :: TestType -> TestType -> Bool
$c> :: TestType -> TestType -> Bool
<= :: TestType -> TestType -> Bool
$c<= :: TestType -> TestType -> Bool
< :: TestType -> TestType -> Bool
$c< :: TestType -> TestType -> Bool
compare :: TestType -> TestType -> Ordering
$ccompare :: TestType -> TestType -> Ordering
Ord, Typeable, Typeable TestType
TestType -> DataType
TestType -> Constr
(forall b. Data b => b -> b) -> TestType -> TestType
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> TestType -> u
forall u. (forall d. Data d => d -> u) -> TestType -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TestType -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TestType -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TestType -> m TestType
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TestType -> m TestType
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TestType
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TestType -> c TestType
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TestType)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TestType)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TestType -> m TestType
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TestType -> m TestType
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TestType -> m TestType
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TestType -> m TestType
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TestType -> m TestType
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TestType -> m TestType
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TestType -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TestType -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> TestType -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> TestType -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TestType -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TestType -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TestType -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TestType -> r
gmapT :: (forall b. Data b => b -> b) -> TestType -> TestType
$cgmapT :: (forall b. Data b => b -> b) -> TestType -> TestType
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TestType)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TestType)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TestType)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TestType)
dataTypeOf :: TestType -> DataType
$cdataTypeOf :: TestType -> DataType
toConstr :: TestType -> Constr
$ctoConstr :: TestType -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TestType
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TestType
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TestType -> c TestType
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TestType -> c TestType
Data)
instance Binary TestType
instance Structured TestType
instance NFData TestType where rnf :: TestType -> ()
rnf = forall a. (Generic a, GNFData (Rep a)) => a -> ()
genericRnf
knownTestTypes :: [TestType]
knownTestTypes :: [TestType]
knownTestTypes = [ TestType
testTypeExe
, TestType
testTypeLib
]
testTypeExe :: TestType
testTypeExe :: TestType
testTypeExe = Version -> TestType
TestTypeExe ([Int] -> Version
mkVersion [Int
1,Int
0])
testTypeLib :: TestType
testTypeLib :: TestType
testTypeLib = Version -> TestType
TestTypeLib ([Int] -> Version
mkVersion [Int
0,Int
9])
instance Pretty TestType where
pretty :: TestType -> Doc
pretty (TestTypeExe Version
ver) = String -> Doc
text String
"exitcode-stdio-" Doc -> Doc -> Doc
<<>> forall a. Pretty a => a -> Doc
pretty Version
ver
pretty (TestTypeLib Version
ver) = String -> Doc
text String
"detailed-" Doc -> Doc -> Doc
<<>> forall a. Pretty a => a -> Doc
pretty Version
ver
pretty (TestTypeUnknown String
name Version
ver) = String -> Doc
text String
name Doc -> Doc -> Doc
<<>> Char -> Doc
char Char
'-' Doc -> Doc -> Doc
<<>> forall a. Pretty a => a -> Doc
pretty Version
ver
instance Parsec TestType where
parsec :: forall (m :: * -> *). CabalParsing m => m TestType
parsec = forall (m :: * -> *) ver a.
(CabalParsing m, Parsec ver) =>
(ver -> String -> a) -> m a
parsecStandard forall a b. (a -> b) -> a -> b
$ \Version
ver String
name -> case String
name of
String
"exitcode-stdio" -> Version -> TestType
TestTypeExe Version
ver
String
"detailed" -> Version -> TestType
TestTypeLib Version
ver
String
_ -> String -> Version -> TestType
TestTypeUnknown String
name Version
ver