{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
module PlutusTx.Coverage ( CoverageAnnotation(..)
, CoverageIndex(..)
, CoverageMetadata(..)
, Metadata(..)
, CoverageData(..)
, CoverageReport(..)
, CovLoc(..)
, covLocFile
, covLocStartLine
, covLocEndLine
, covLocStartCol
, covLocEndCol
, metadataSet
, coverageAnnotations
, ignoredAnnotations
, coverageMetadata
, coveredAnnotations
, addCoverageMetadata
, addLocationToCoverageIndex
, addBoolCaseToCoverageIndex
, coverageDataFromLogMsg
) where
import Control.Lens
import Codec.Serialise
import PlutusCore.Flat
import Control.DeepSeq
import Data.Aeson (FromJSON, FromJSONKey, ToJSON, ToJSONKey)
import Data.Foldable
import Data.Map (Map)
import Data.Map qualified as Map
import Data.Set (Set)
import Data.Set qualified as Set
import Data.String
import Text.Read
import Control.Monad.Writer
import Prettyprinter
import Prelude
import Flat hiding (to)
data CovLoc = CovLoc { CovLoc -> String
_covLocFile :: String
, CovLoc -> Int
_covLocStartLine :: Int
, CovLoc -> Int
_covLocEndLine :: Int
, CovLoc -> Int
_covLocStartCol :: Int
, CovLoc -> Int
_covLocEndCol :: Int }
deriving stock (Eq CovLoc
CovLoc -> CovLoc -> Bool
CovLoc -> CovLoc -> Ordering
CovLoc -> CovLoc -> CovLoc
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 :: CovLoc -> CovLoc -> CovLoc
$cmin :: CovLoc -> CovLoc -> CovLoc
max :: CovLoc -> CovLoc -> CovLoc
$cmax :: CovLoc -> CovLoc -> CovLoc
>= :: CovLoc -> CovLoc -> Bool
$c>= :: CovLoc -> CovLoc -> Bool
> :: CovLoc -> CovLoc -> Bool
$c> :: CovLoc -> CovLoc -> Bool
<= :: CovLoc -> CovLoc -> Bool
$c<= :: CovLoc -> CovLoc -> Bool
< :: CovLoc -> CovLoc -> Bool
$c< :: CovLoc -> CovLoc -> Bool
compare :: CovLoc -> CovLoc -> Ordering
$ccompare :: CovLoc -> CovLoc -> Ordering
Ord, CovLoc -> CovLoc -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CovLoc -> CovLoc -> Bool
$c/= :: CovLoc -> CovLoc -> Bool
== :: CovLoc -> CovLoc -> Bool
$c== :: CovLoc -> CovLoc -> Bool
Eq, Int -> CovLoc -> ShowS
[CovLoc] -> ShowS
CovLoc -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CovLoc] -> ShowS
$cshowList :: [CovLoc] -> ShowS
show :: CovLoc -> String
$cshow :: CovLoc -> String
showsPrec :: Int -> CovLoc -> ShowS
$cshowsPrec :: Int -> CovLoc -> ShowS
Show, ReadPrec [CovLoc]
ReadPrec CovLoc
Int -> ReadS CovLoc
ReadS [CovLoc]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CovLoc]
$creadListPrec :: ReadPrec [CovLoc]
readPrec :: ReadPrec CovLoc
$creadPrec :: ReadPrec CovLoc
readList :: ReadS [CovLoc]
$creadList :: ReadS [CovLoc]
readsPrec :: Int -> ReadS CovLoc
$creadsPrec :: Int -> ReadS CovLoc
Read, forall x. Rep CovLoc x -> CovLoc
forall x. CovLoc -> Rep CovLoc x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CovLoc x -> CovLoc
$cfrom :: forall x. CovLoc -> Rep CovLoc x
Generic)
deriving anyclass ([CovLoc] -> Encoding
CovLoc -> Encoding
forall s. Decoder s [CovLoc]
forall s. Decoder s CovLoc
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: forall s. Decoder s [CovLoc]
$cdecodeList :: forall s. Decoder s [CovLoc]
encodeList :: [CovLoc] -> Encoding
$cencodeList :: [CovLoc] -> Encoding
decode :: forall s. Decoder s CovLoc
$cdecode :: forall s. Decoder s CovLoc
encode :: CovLoc -> Encoding
$cencode :: CovLoc -> Encoding
Serialise)
deriving Get CovLoc
CovLoc -> Encoding
CovLoc -> Int -> Int
forall a. (a -> Encoding) -> Get a -> (a -> Int -> Int) -> Flat a
size :: CovLoc -> Int -> Int
$csize :: CovLoc -> Int -> Int
decode :: Get CovLoc
$cdecode :: Get CovLoc
encode :: CovLoc -> Encoding
$cencode :: CovLoc -> Encoding
Flat via (AsSerialize CovLoc)
deriving anyclass (CovLoc -> ()
forall a. (a -> ()) -> NFData a
rnf :: CovLoc -> ()
$crnf :: CovLoc -> ()
NFData, [CovLoc] -> Encoding
[CovLoc] -> Value
CovLoc -> Encoding
CovLoc -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [CovLoc] -> Encoding
$ctoEncodingList :: [CovLoc] -> Encoding
toJSONList :: [CovLoc] -> Value
$ctoJSONList :: [CovLoc] -> Value
toEncoding :: CovLoc -> Encoding
$ctoEncoding :: CovLoc -> Encoding
toJSON :: CovLoc -> Value
$ctoJSON :: CovLoc -> Value
ToJSON, Value -> Parser [CovLoc]
Value -> Parser CovLoc
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [CovLoc]
$cparseJSONList :: Value -> Parser [CovLoc]
parseJSON :: Value -> Parser CovLoc
$cparseJSON :: Value -> Parser CovLoc
FromJSON)
makeLenses ''CovLoc
instance Pretty CovLoc where
pretty :: forall ann. CovLoc -> Doc ann
pretty (CovLoc String
file Int
l1 Int
l2 Int
c1 Int
c2) =
forall a. Monoid a => [a] -> a
mconcat [ forall a ann. Pretty a => a -> Doc ann
pretty String
file, Doc ann
":", forall a ann. Pretty a => a -> Doc ann
pretty Int
l1, Doc ann
",", forall a ann. Pretty a => a -> Doc ann
pretty Int
c1, Doc ann
"-", forall a ann. Pretty a => a -> Doc ann
pretty Int
l2, Doc ann
",", forall a ann. Pretty a => a -> Doc ann
pretty Int
c2]
data CoverageAnnotation = CoverLocation CovLoc
| CoverBool CovLoc Bool
deriving stock (Eq CoverageAnnotation
CoverageAnnotation -> CoverageAnnotation -> Bool
CoverageAnnotation -> CoverageAnnotation -> Ordering
CoverageAnnotation -> CoverageAnnotation -> CoverageAnnotation
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 :: CoverageAnnotation -> CoverageAnnotation -> CoverageAnnotation
$cmin :: CoverageAnnotation -> CoverageAnnotation -> CoverageAnnotation
max :: CoverageAnnotation -> CoverageAnnotation -> CoverageAnnotation
$cmax :: CoverageAnnotation -> CoverageAnnotation -> CoverageAnnotation
>= :: CoverageAnnotation -> CoverageAnnotation -> Bool
$c>= :: CoverageAnnotation -> CoverageAnnotation -> Bool
> :: CoverageAnnotation -> CoverageAnnotation -> Bool
$c> :: CoverageAnnotation -> CoverageAnnotation -> Bool
<= :: CoverageAnnotation -> CoverageAnnotation -> Bool
$c<= :: CoverageAnnotation -> CoverageAnnotation -> Bool
< :: CoverageAnnotation -> CoverageAnnotation -> Bool
$c< :: CoverageAnnotation -> CoverageAnnotation -> Bool
compare :: CoverageAnnotation -> CoverageAnnotation -> Ordering
$ccompare :: CoverageAnnotation -> CoverageAnnotation -> Ordering
Ord, CoverageAnnotation -> CoverageAnnotation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CoverageAnnotation -> CoverageAnnotation -> Bool
$c/= :: CoverageAnnotation -> CoverageAnnotation -> Bool
== :: CoverageAnnotation -> CoverageAnnotation -> Bool
$c== :: CoverageAnnotation -> CoverageAnnotation -> Bool
Eq, Int -> CoverageAnnotation -> ShowS
[CoverageAnnotation] -> ShowS
CoverageAnnotation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CoverageAnnotation] -> ShowS
$cshowList :: [CoverageAnnotation] -> ShowS
show :: CoverageAnnotation -> String
$cshow :: CoverageAnnotation -> String
showsPrec :: Int -> CoverageAnnotation -> ShowS
$cshowsPrec :: Int -> CoverageAnnotation -> ShowS
Show, ReadPrec [CoverageAnnotation]
ReadPrec CoverageAnnotation
Int -> ReadS CoverageAnnotation
ReadS [CoverageAnnotation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CoverageAnnotation]
$creadListPrec :: ReadPrec [CoverageAnnotation]
readPrec :: ReadPrec CoverageAnnotation
$creadPrec :: ReadPrec CoverageAnnotation
readList :: ReadS [CoverageAnnotation]
$creadList :: ReadS [CoverageAnnotation]
readsPrec :: Int -> ReadS CoverageAnnotation
$creadsPrec :: Int -> ReadS CoverageAnnotation
Read, forall x. Rep CoverageAnnotation x -> CoverageAnnotation
forall x. CoverageAnnotation -> Rep CoverageAnnotation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CoverageAnnotation x -> CoverageAnnotation
$cfrom :: forall x. CoverageAnnotation -> Rep CoverageAnnotation x
Generic)
deriving anyclass ([CoverageAnnotation] -> Encoding
CoverageAnnotation -> Encoding
forall s. Decoder s [CoverageAnnotation]
forall s. Decoder s CoverageAnnotation
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: forall s. Decoder s [CoverageAnnotation]
$cdecodeList :: forall s. Decoder s [CoverageAnnotation]
encodeList :: [CoverageAnnotation] -> Encoding
$cencodeList :: [CoverageAnnotation] -> Encoding
decode :: forall s. Decoder s CoverageAnnotation
$cdecode :: forall s. Decoder s CoverageAnnotation
encode :: CoverageAnnotation -> Encoding
$cencode :: CoverageAnnotation -> Encoding
Serialise)
deriving Get CoverageAnnotation
CoverageAnnotation -> Encoding
CoverageAnnotation -> Int -> Int
forall a. (a -> Encoding) -> Get a -> (a -> Int -> Int) -> Flat a
size :: CoverageAnnotation -> Int -> Int
$csize :: CoverageAnnotation -> Int -> Int
decode :: Get CoverageAnnotation
$cdecode :: Get CoverageAnnotation
encode :: CoverageAnnotation -> Encoding
$cencode :: CoverageAnnotation -> Encoding
Flat via (AsSerialize CoverageAnnotation)
deriving anyclass (CoverageAnnotation -> ()
forall a. (a -> ()) -> NFData a
rnf :: CoverageAnnotation -> ()
$crnf :: CoverageAnnotation -> ()
NFData, [CoverageAnnotation] -> Encoding
[CoverageAnnotation] -> Value
CoverageAnnotation -> Encoding
CoverageAnnotation -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [CoverageAnnotation] -> Encoding
$ctoEncodingList :: [CoverageAnnotation] -> Encoding
toJSONList :: [CoverageAnnotation] -> Value
$ctoJSONList :: [CoverageAnnotation] -> Value
toEncoding :: CoverageAnnotation -> Encoding
$ctoEncoding :: CoverageAnnotation -> Encoding
toJSON :: CoverageAnnotation -> Value
$ctoJSON :: CoverageAnnotation -> Value
ToJSON, Value -> Parser [CoverageAnnotation]
Value -> Parser CoverageAnnotation
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [CoverageAnnotation]
$cparseJSONList :: Value -> Parser [CoverageAnnotation]
parseJSON :: Value -> Parser CoverageAnnotation
$cparseJSON :: Value -> Parser CoverageAnnotation
FromJSON, ToJSONKeyFunction [CoverageAnnotation]
ToJSONKeyFunction CoverageAnnotation
forall a.
ToJSONKeyFunction a -> ToJSONKeyFunction [a] -> ToJSONKey a
toJSONKeyList :: ToJSONKeyFunction [CoverageAnnotation]
$ctoJSONKeyList :: ToJSONKeyFunction [CoverageAnnotation]
toJSONKey :: ToJSONKeyFunction CoverageAnnotation
$ctoJSONKey :: ToJSONKeyFunction CoverageAnnotation
ToJSONKey, FromJSONKeyFunction [CoverageAnnotation]
FromJSONKeyFunction CoverageAnnotation
forall a.
FromJSONKeyFunction a -> FromJSONKeyFunction [a] -> FromJSONKey a
fromJSONKeyList :: FromJSONKeyFunction [CoverageAnnotation]
$cfromJSONKeyList :: FromJSONKeyFunction [CoverageAnnotation]
fromJSONKey :: FromJSONKeyFunction CoverageAnnotation
$cfromJSONKey :: FromJSONKeyFunction CoverageAnnotation
FromJSONKey)
instance Pretty CoverageAnnotation where
pretty :: forall ann. CoverageAnnotation -> Doc ann
pretty (CoverLocation CovLoc
loc) = forall a ann. Pretty a => a -> Doc ann
pretty CovLoc
loc
pretty (CoverBool CovLoc
loc Bool
b) = forall a ann. Pretty a => a -> Doc ann
pretty CovLoc
loc forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ann
"=" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty Bool
b
data Metadata = ApplicationHeadSymbol String
| IgnoredAnnotation
deriving stock (Eq Metadata
Metadata -> Metadata -> Bool
Metadata -> Metadata -> Ordering
Metadata -> Metadata -> Metadata
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 :: Metadata -> Metadata -> Metadata
$cmin :: Metadata -> Metadata -> Metadata
max :: Metadata -> Metadata -> Metadata
$cmax :: Metadata -> Metadata -> Metadata
>= :: Metadata -> Metadata -> Bool
$c>= :: Metadata -> Metadata -> Bool
> :: Metadata -> Metadata -> Bool
$c> :: Metadata -> Metadata -> Bool
<= :: Metadata -> Metadata -> Bool
$c<= :: Metadata -> Metadata -> Bool
< :: Metadata -> Metadata -> Bool
$c< :: Metadata -> Metadata -> Bool
compare :: Metadata -> Metadata -> Ordering
$ccompare :: Metadata -> Metadata -> Ordering
Ord, Metadata -> Metadata -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Metadata -> Metadata -> Bool
$c/= :: Metadata -> Metadata -> Bool
== :: Metadata -> Metadata -> Bool
$c== :: Metadata -> Metadata -> Bool
Eq, Int -> Metadata -> ShowS
[Metadata] -> ShowS
Metadata -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Metadata] -> ShowS
$cshowList :: [Metadata] -> ShowS
show :: Metadata -> String
$cshow :: Metadata -> String
showsPrec :: Int -> Metadata -> ShowS
$cshowsPrec :: Int -> Metadata -> ShowS
Show, forall x. Rep Metadata x -> Metadata
forall x. Metadata -> Rep Metadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Metadata x -> Metadata
$cfrom :: forall x. Metadata -> Rep Metadata x
Generic)
deriving anyclass ([Metadata] -> Encoding
Metadata -> Encoding
forall s. Decoder s [Metadata]
forall s. Decoder s Metadata
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: forall s. Decoder s [Metadata]
$cdecodeList :: forall s. Decoder s [Metadata]
encodeList :: [Metadata] -> Encoding
$cencodeList :: [Metadata] -> Encoding
decode :: forall s. Decoder s Metadata
$cdecode :: forall s. Decoder s Metadata
encode :: Metadata -> Encoding
$cencode :: Metadata -> Encoding
Serialise)
deriving Get Metadata
Metadata -> Encoding
Metadata -> Int -> Int
forall a. (a -> Encoding) -> Get a -> (a -> Int -> Int) -> Flat a
size :: Metadata -> Int -> Int
$csize :: Metadata -> Int -> Int
decode :: Get Metadata
$cdecode :: Get Metadata
encode :: Metadata -> Encoding
$cencode :: Metadata -> Encoding
Flat via (AsSerialize Metadata)
deriving anyclass (Metadata -> ()
forall a. (a -> ()) -> NFData a
rnf :: Metadata -> ()
$crnf :: Metadata -> ()
NFData, [Metadata] -> Encoding
[Metadata] -> Value
Metadata -> Encoding
Metadata -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [Metadata] -> Encoding
$ctoEncodingList :: [Metadata] -> Encoding
toJSONList :: [Metadata] -> Value
$ctoJSONList :: [Metadata] -> Value
toEncoding :: Metadata -> Encoding
$ctoEncoding :: Metadata -> Encoding
toJSON :: Metadata -> Value
$ctoJSON :: Metadata -> Value
ToJSON, Value -> Parser [Metadata]
Value -> Parser Metadata
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [Metadata]
$cparseJSONList :: Value -> Parser [Metadata]
parseJSON :: Value -> Parser Metadata
$cparseJSON :: Value -> Parser Metadata
FromJSON)
instance Pretty Metadata where
pretty :: forall ann. Metadata -> Doc ann
pretty = forall a ann. Show a => a -> Doc ann
viaShow
newtype CoverageMetadata = CoverageMetadata { CoverageMetadata -> Set Metadata
_metadataSet :: Set Metadata }
deriving stock (Eq CoverageMetadata
CoverageMetadata -> CoverageMetadata -> Bool
CoverageMetadata -> CoverageMetadata -> Ordering
CoverageMetadata -> CoverageMetadata -> CoverageMetadata
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 :: CoverageMetadata -> CoverageMetadata -> CoverageMetadata
$cmin :: CoverageMetadata -> CoverageMetadata -> CoverageMetadata
max :: CoverageMetadata -> CoverageMetadata -> CoverageMetadata
$cmax :: CoverageMetadata -> CoverageMetadata -> CoverageMetadata
>= :: CoverageMetadata -> CoverageMetadata -> Bool
$c>= :: CoverageMetadata -> CoverageMetadata -> Bool
> :: CoverageMetadata -> CoverageMetadata -> Bool
$c> :: CoverageMetadata -> CoverageMetadata -> Bool
<= :: CoverageMetadata -> CoverageMetadata -> Bool
$c<= :: CoverageMetadata -> CoverageMetadata -> Bool
< :: CoverageMetadata -> CoverageMetadata -> Bool
$c< :: CoverageMetadata -> CoverageMetadata -> Bool
compare :: CoverageMetadata -> CoverageMetadata -> Ordering
$ccompare :: CoverageMetadata -> CoverageMetadata -> Ordering
Ord, CoverageMetadata -> CoverageMetadata -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CoverageMetadata -> CoverageMetadata -> Bool
$c/= :: CoverageMetadata -> CoverageMetadata -> Bool
== :: CoverageMetadata -> CoverageMetadata -> Bool
$c== :: CoverageMetadata -> CoverageMetadata -> Bool
Eq, Int -> CoverageMetadata -> ShowS
[CoverageMetadata] -> ShowS
CoverageMetadata -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CoverageMetadata] -> ShowS
$cshowList :: [CoverageMetadata] -> ShowS
show :: CoverageMetadata -> String
$cshow :: CoverageMetadata -> String
showsPrec :: Int -> CoverageMetadata -> ShowS
$cshowsPrec :: Int -> CoverageMetadata -> ShowS
Show, forall x. Rep CoverageMetadata x -> CoverageMetadata
forall x. CoverageMetadata -> Rep CoverageMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CoverageMetadata x -> CoverageMetadata
$cfrom :: forall x. CoverageMetadata -> Rep CoverageMetadata x
Generic)
deriving anyclass ([CoverageMetadata] -> Encoding
CoverageMetadata -> Encoding
forall s. Decoder s [CoverageMetadata]
forall s. Decoder s CoverageMetadata
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: forall s. Decoder s [CoverageMetadata]
$cdecodeList :: forall s. Decoder s [CoverageMetadata]
encodeList :: [CoverageMetadata] -> Encoding
$cencodeList :: [CoverageMetadata] -> Encoding
decode :: forall s. Decoder s CoverageMetadata
$cdecode :: forall s. Decoder s CoverageMetadata
encode :: CoverageMetadata -> Encoding
$cencode :: CoverageMetadata -> Encoding
Serialise, CoverageMetadata -> ()
forall a. (a -> ()) -> NFData a
rnf :: CoverageMetadata -> ()
$crnf :: CoverageMetadata -> ()
NFData, [CoverageMetadata] -> Encoding
[CoverageMetadata] -> Value
CoverageMetadata -> Encoding
CoverageMetadata -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [CoverageMetadata] -> Encoding
$ctoEncodingList :: [CoverageMetadata] -> Encoding
toJSONList :: [CoverageMetadata] -> Value
$ctoJSONList :: [CoverageMetadata] -> Value
toEncoding :: CoverageMetadata -> Encoding
$ctoEncoding :: CoverageMetadata -> Encoding
toJSON :: CoverageMetadata -> Value
$ctoJSON :: CoverageMetadata -> Value
ToJSON, Value -> Parser [CoverageMetadata]
Value -> Parser CoverageMetadata
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [CoverageMetadata]
$cparseJSONList :: Value -> Parser [CoverageMetadata]
parseJSON :: Value -> Parser CoverageMetadata
$cparseJSON :: Value -> Parser CoverageMetadata
FromJSON)
deriving newtype (NonEmpty CoverageMetadata -> CoverageMetadata
CoverageMetadata -> CoverageMetadata -> CoverageMetadata
forall b. Integral b => b -> CoverageMetadata -> CoverageMetadata
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
stimes :: forall b. Integral b => b -> CoverageMetadata -> CoverageMetadata
$cstimes :: forall b. Integral b => b -> CoverageMetadata -> CoverageMetadata
sconcat :: NonEmpty CoverageMetadata -> CoverageMetadata
$csconcat :: NonEmpty CoverageMetadata -> CoverageMetadata
<> :: CoverageMetadata -> CoverageMetadata -> CoverageMetadata
$c<> :: CoverageMetadata -> CoverageMetadata -> CoverageMetadata
Semigroup, Semigroup CoverageMetadata
CoverageMetadata
[CoverageMetadata] -> CoverageMetadata
CoverageMetadata -> CoverageMetadata -> CoverageMetadata
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
mconcat :: [CoverageMetadata] -> CoverageMetadata
$cmconcat :: [CoverageMetadata] -> CoverageMetadata
mappend :: CoverageMetadata -> CoverageMetadata -> CoverageMetadata
$cmappend :: CoverageMetadata -> CoverageMetadata -> CoverageMetadata
mempty :: CoverageMetadata
$cmempty :: CoverageMetadata
Monoid)
deriving Get CoverageMetadata
CoverageMetadata -> Encoding
CoverageMetadata -> Int -> Int
forall a. (a -> Encoding) -> Get a -> (a -> Int -> Int) -> Flat a
size :: CoverageMetadata -> Int -> Int
$csize :: CoverageMetadata -> Int -> Int
decode :: Get CoverageMetadata
$cdecode :: Get CoverageMetadata
encode :: CoverageMetadata -> Encoding
$cencode :: CoverageMetadata -> Encoding
Flat via (AsSerialize CoverageMetadata)
makeLenses ''CoverageMetadata
instance Pretty CoverageMetadata where
pretty :: forall ann. CoverageMetadata -> Doc ann
pretty (CoverageMetadata Set Metadata
s) = forall ann. [Doc ann] -> Doc ann
vsep forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map forall a ann. Pretty a => a -> Doc ann
pretty forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Set a -> [a]
Set.toList forall a b. (a -> b) -> a -> b
$ Set Metadata
s
data CoverageIndex = CoverageIndex { CoverageIndex -> Map CoverageAnnotation CoverageMetadata
_coverageMetadata :: Map CoverageAnnotation CoverageMetadata }
deriving stock (Eq CoverageIndex
CoverageIndex -> CoverageIndex -> Bool
CoverageIndex -> CoverageIndex -> Ordering
CoverageIndex -> CoverageIndex -> CoverageIndex
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 :: CoverageIndex -> CoverageIndex -> CoverageIndex
$cmin :: CoverageIndex -> CoverageIndex -> CoverageIndex
max :: CoverageIndex -> CoverageIndex -> CoverageIndex
$cmax :: CoverageIndex -> CoverageIndex -> CoverageIndex
>= :: CoverageIndex -> CoverageIndex -> Bool
$c>= :: CoverageIndex -> CoverageIndex -> Bool
> :: CoverageIndex -> CoverageIndex -> Bool
$c> :: CoverageIndex -> CoverageIndex -> Bool
<= :: CoverageIndex -> CoverageIndex -> Bool
$c<= :: CoverageIndex -> CoverageIndex -> Bool
< :: CoverageIndex -> CoverageIndex -> Bool
$c< :: CoverageIndex -> CoverageIndex -> Bool
compare :: CoverageIndex -> CoverageIndex -> Ordering
$ccompare :: CoverageIndex -> CoverageIndex -> Ordering
Ord, CoverageIndex -> CoverageIndex -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CoverageIndex -> CoverageIndex -> Bool
$c/= :: CoverageIndex -> CoverageIndex -> Bool
== :: CoverageIndex -> CoverageIndex -> Bool
$c== :: CoverageIndex -> CoverageIndex -> Bool
Eq, Int -> CoverageIndex -> ShowS
[CoverageIndex] -> ShowS
CoverageIndex -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CoverageIndex] -> ShowS
$cshowList :: [CoverageIndex] -> ShowS
show :: CoverageIndex -> String
$cshow :: CoverageIndex -> String
showsPrec :: Int -> CoverageIndex -> ShowS
$cshowsPrec :: Int -> CoverageIndex -> ShowS
Show, forall x. Rep CoverageIndex x -> CoverageIndex
forall x. CoverageIndex -> Rep CoverageIndex x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CoverageIndex x -> CoverageIndex
$cfrom :: forall x. CoverageIndex -> Rep CoverageIndex x
Generic)
deriving anyclass ([CoverageIndex] -> Encoding
CoverageIndex -> Encoding
forall s. Decoder s [CoverageIndex]
forall s. Decoder s CoverageIndex
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: forall s. Decoder s [CoverageIndex]
$cdecodeList :: forall s. Decoder s [CoverageIndex]
encodeList :: [CoverageIndex] -> Encoding
$cencodeList :: [CoverageIndex] -> Encoding
decode :: forall s. Decoder s CoverageIndex
$cdecode :: forall s. Decoder s CoverageIndex
encode :: CoverageIndex -> Encoding
$cencode :: CoverageIndex -> Encoding
Serialise)
deriving Get CoverageIndex
CoverageIndex -> Encoding
CoverageIndex -> Int -> Int
forall a. (a -> Encoding) -> Get a -> (a -> Int -> Int) -> Flat a
size :: CoverageIndex -> Int -> Int
$csize :: CoverageIndex -> Int -> Int
decode :: Get CoverageIndex
$cdecode :: Get CoverageIndex
encode :: CoverageIndex -> Encoding
$cencode :: CoverageIndex -> Encoding
Flat via (AsSerialize CoverageIndex)
deriving anyclass (CoverageIndex -> ()
forall a. (a -> ()) -> NFData a
rnf :: CoverageIndex -> ()
$crnf :: CoverageIndex -> ()
NFData, [CoverageIndex] -> Encoding
[CoverageIndex] -> Value
CoverageIndex -> Encoding
CoverageIndex -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [CoverageIndex] -> Encoding
$ctoEncodingList :: [CoverageIndex] -> Encoding
toJSONList :: [CoverageIndex] -> Value
$ctoJSONList :: [CoverageIndex] -> Value
toEncoding :: CoverageIndex -> Encoding
$ctoEncoding :: CoverageIndex -> Encoding
toJSON :: CoverageIndex -> Value
$ctoJSON :: CoverageIndex -> Value
ToJSON, Value -> Parser [CoverageIndex]
Value -> Parser CoverageIndex
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [CoverageIndex]
$cparseJSONList :: Value -> Parser [CoverageIndex]
parseJSON :: Value -> Parser CoverageIndex
$cparseJSON :: Value -> Parser CoverageIndex
FromJSON)
makeLenses ''CoverageIndex
coverageAnnotations :: Getter CoverageIndex (Set CoverageAnnotation)
coverageAnnotations :: Getter CoverageIndex (Set CoverageAnnotation)
coverageAnnotations = Iso' CoverageIndex (Map CoverageAnnotation CoverageMetadata)
coverageMetadata forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to forall k a. Map k a -> Set k
Map.keysSet
ignoredAnnotations :: Getter CoverageIndex (Set CoverageAnnotation)
ignoredAnnotations :: Getter CoverageIndex (Set CoverageAnnotation)
ignoredAnnotations = Iso' CoverageIndex (Map CoverageAnnotation CoverageMetadata)
coverageMetadata
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to (forall k a. Map k a -> Set k
Map.keysSet forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a k. (a -> Bool) -> Map k a -> Map k a
Map.filter (forall a. Ord a => a -> Set a -> Bool
Set.member Metadata
IgnoredAnnotation forall b c a. (b -> c) -> (a -> b) -> a -> c
. CoverageMetadata -> Set Metadata
_metadataSet))
instance Semigroup CoverageIndex where
CoverageIndex
ci <> :: CoverageIndex -> CoverageIndex -> CoverageIndex
<> CoverageIndex
ci' = Map CoverageAnnotation CoverageMetadata -> CoverageIndex
CoverageIndex (forall k a. Ord k => (a -> a -> a) -> Map k a -> Map k a -> Map k a
Map.unionWith forall a. Semigroup a => a -> a -> a
(<>) (CoverageIndex -> Map CoverageAnnotation CoverageMetadata
_coverageMetadata CoverageIndex
ci) (CoverageIndex -> Map CoverageAnnotation CoverageMetadata
_coverageMetadata CoverageIndex
ci'))
instance Monoid CoverageIndex where
mempty :: CoverageIndex
mempty = Map CoverageAnnotation CoverageMetadata -> CoverageIndex
CoverageIndex forall k a. Map k a
Map.empty
addLocationToCoverageIndex :: MonadWriter CoverageIndex m => CovLoc -> m CoverageAnnotation
addLocationToCoverageIndex :: forall (m :: * -> *).
MonadWriter CoverageIndex m =>
CovLoc -> m CoverageAnnotation
addLocationToCoverageIndex CovLoc
src = do
let ann :: CoverageAnnotation
ann = CovLoc -> CoverageAnnotation
CoverLocation CovLoc
src
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell forall a b. (a -> b) -> a -> b
$ Map CoverageAnnotation CoverageMetadata -> CoverageIndex
CoverageIndex forall a b. (a -> b) -> a -> b
$ forall k a. k -> a -> Map k a
Map.singleton CoverageAnnotation
ann forall a. Monoid a => a
mempty
forall (f :: * -> *) a. Applicative f => a -> f a
pure CoverageAnnotation
ann
addBoolCaseToCoverageIndex :: MonadWriter CoverageIndex m => CovLoc -> Bool -> CoverageMetadata -> m CoverageAnnotation
addBoolCaseToCoverageIndex :: forall (m :: * -> *).
MonadWriter CoverageIndex m =>
CovLoc -> Bool -> CoverageMetadata -> m CoverageAnnotation
addBoolCaseToCoverageIndex CovLoc
src Bool
b CoverageMetadata
meta = do
let ann :: CoverageAnnotation
ann = CovLoc -> Bool -> CoverageAnnotation
boolCaseCoverageAnn CovLoc
src Bool
b
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell forall a b. (a -> b) -> a -> b
$ Map CoverageAnnotation CoverageMetadata -> CoverageIndex
CoverageIndex (forall k a. k -> a -> Map k a
Map.singleton CoverageAnnotation
ann CoverageMetadata
meta)
forall (f :: * -> *) a. Applicative f => a -> f a
pure CoverageAnnotation
ann
addCoverageMetadata :: CoverageAnnotation -> Metadata -> CoverageIndex -> CoverageIndex
addCoverageMetadata :: CoverageAnnotation -> Metadata -> CoverageIndex -> CoverageIndex
addCoverageMetadata CoverageAnnotation
ann Metadata
meta CoverageIndex
idx = CoverageIndex
idx forall a b. a -> (a -> b) -> b
& Iso' CoverageIndex (Map CoverageAnnotation CoverageMetadata)
coverageMetadata forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall m. At m => Index m -> Lens' m (Maybe (IxValue m))
at CoverageAnnotation
ann forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. Prism (Maybe a) (Maybe b) a b
_Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. Iso' CoverageMetadata (Set Metadata)
metadataSet forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ forall a. Ord a => a -> Set a -> Set a
Set.insert Metadata
meta
{-# INLINE boolCaseCoverageAnn #-}
boolCaseCoverageAnn :: CovLoc -> Bool -> CoverageAnnotation
boolCaseCoverageAnn :: CovLoc -> Bool -> CoverageAnnotation
boolCaseCoverageAnn CovLoc
src Bool
b = CovLoc -> Bool -> CoverageAnnotation
CoverBool CovLoc
src Bool
b
newtype CoverageData = CoverageData { CoverageData -> Set CoverageAnnotation
_coveredAnnotations :: Set CoverageAnnotation }
deriving stock (Eq CoverageData
CoverageData -> CoverageData -> Bool
CoverageData -> CoverageData -> Ordering
CoverageData -> CoverageData -> CoverageData
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 :: CoverageData -> CoverageData -> CoverageData
$cmin :: CoverageData -> CoverageData -> CoverageData
max :: CoverageData -> CoverageData -> CoverageData
$cmax :: CoverageData -> CoverageData -> CoverageData
>= :: CoverageData -> CoverageData -> Bool
$c>= :: CoverageData -> CoverageData -> Bool
> :: CoverageData -> CoverageData -> Bool
$c> :: CoverageData -> CoverageData -> Bool
<= :: CoverageData -> CoverageData -> Bool
$c<= :: CoverageData -> CoverageData -> Bool
< :: CoverageData -> CoverageData -> Bool
$c< :: CoverageData -> CoverageData -> Bool
compare :: CoverageData -> CoverageData -> Ordering
$ccompare :: CoverageData -> CoverageData -> Ordering
Ord, CoverageData -> CoverageData -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CoverageData -> CoverageData -> Bool
$c/= :: CoverageData -> CoverageData -> Bool
== :: CoverageData -> CoverageData -> Bool
$c== :: CoverageData -> CoverageData -> Bool
Eq, Int -> CoverageData -> ShowS
[CoverageData] -> ShowS
CoverageData -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CoverageData] -> ShowS
$cshowList :: [CoverageData] -> ShowS
show :: CoverageData -> String
$cshow :: CoverageData -> String
showsPrec :: Int -> CoverageData -> ShowS
$cshowsPrec :: Int -> CoverageData -> ShowS
Show, forall x. Rep CoverageData x -> CoverageData
forall x. CoverageData -> Rep CoverageData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CoverageData x -> CoverageData
$cfrom :: forall x. CoverageData -> Rep CoverageData x
Generic)
deriving newtype (NonEmpty CoverageData -> CoverageData
CoverageData -> CoverageData -> CoverageData
forall b. Integral b => b -> CoverageData -> CoverageData
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
stimes :: forall b. Integral b => b -> CoverageData -> CoverageData
$cstimes :: forall b. Integral b => b -> CoverageData -> CoverageData
sconcat :: NonEmpty CoverageData -> CoverageData
$csconcat :: NonEmpty CoverageData -> CoverageData
<> :: CoverageData -> CoverageData -> CoverageData
$c<> :: CoverageData -> CoverageData -> CoverageData
Semigroup, Semigroup CoverageData
CoverageData
[CoverageData] -> CoverageData
CoverageData -> CoverageData -> CoverageData
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
mconcat :: [CoverageData] -> CoverageData
$cmconcat :: [CoverageData] -> CoverageData
mappend :: CoverageData -> CoverageData -> CoverageData
$cmappend :: CoverageData -> CoverageData -> CoverageData
mempty :: CoverageData
$cmempty :: CoverageData
Monoid)
deriving anyclass (CoverageData -> ()
forall a. (a -> ()) -> NFData a
rnf :: CoverageData -> ()
$crnf :: CoverageData -> ()
NFData, [CoverageData] -> Encoding
[CoverageData] -> Value
CoverageData -> Encoding
CoverageData -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [CoverageData] -> Encoding
$ctoEncodingList :: [CoverageData] -> Encoding
toJSONList :: [CoverageData] -> Value
$ctoJSONList :: [CoverageData] -> Value
toEncoding :: CoverageData -> Encoding
$ctoEncoding :: CoverageData -> Encoding
toJSON :: CoverageData -> Value
$ctoJSON :: CoverageData -> Value
ToJSON, Value -> Parser [CoverageData]
Value -> Parser CoverageData
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [CoverageData]
$cparseJSONList :: Value -> Parser [CoverageData]
parseJSON :: Value -> Parser CoverageData
$cparseJSON :: Value -> Parser CoverageData
FromJSON)
makeLenses ''CoverageData
data CoverageReport = CoverageReport { CoverageReport -> CoverageIndex
_coverageIndex :: CoverageIndex
, CoverageReport -> CoverageData
_coverageData :: CoverageData }
deriving stock (Eq CoverageReport
CoverageReport -> CoverageReport -> Bool
CoverageReport -> CoverageReport -> Ordering
CoverageReport -> CoverageReport -> CoverageReport
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 :: CoverageReport -> CoverageReport -> CoverageReport
$cmin :: CoverageReport -> CoverageReport -> CoverageReport
max :: CoverageReport -> CoverageReport -> CoverageReport
$cmax :: CoverageReport -> CoverageReport -> CoverageReport
>= :: CoverageReport -> CoverageReport -> Bool
$c>= :: CoverageReport -> CoverageReport -> Bool
> :: CoverageReport -> CoverageReport -> Bool
$c> :: CoverageReport -> CoverageReport -> Bool
<= :: CoverageReport -> CoverageReport -> Bool
$c<= :: CoverageReport -> CoverageReport -> Bool
< :: CoverageReport -> CoverageReport -> Bool
$c< :: CoverageReport -> CoverageReport -> Bool
compare :: CoverageReport -> CoverageReport -> Ordering
$ccompare :: CoverageReport -> CoverageReport -> Ordering
Ord, CoverageReport -> CoverageReport -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CoverageReport -> CoverageReport -> Bool
$c/= :: CoverageReport -> CoverageReport -> Bool
== :: CoverageReport -> CoverageReport -> Bool
$c== :: CoverageReport -> CoverageReport -> Bool
Eq, Int -> CoverageReport -> ShowS
[CoverageReport] -> ShowS
CoverageReport -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CoverageReport] -> ShowS
$cshowList :: [CoverageReport] -> ShowS
show :: CoverageReport -> String
$cshow :: CoverageReport -> String
showsPrec :: Int -> CoverageReport -> ShowS
$cshowsPrec :: Int -> CoverageReport -> ShowS
Show, forall x. Rep CoverageReport x -> CoverageReport
forall x. CoverageReport -> Rep CoverageReport x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CoverageReport x -> CoverageReport
$cfrom :: forall x. CoverageReport -> Rep CoverageReport x
Generic)
deriving anyclass (CoverageReport -> ()
forall a. (a -> ()) -> NFData a
rnf :: CoverageReport -> ()
$crnf :: CoverageReport -> ()
NFData, [CoverageReport] -> Encoding
[CoverageReport] -> Value
CoverageReport -> Encoding
CoverageReport -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [CoverageReport] -> Encoding
$ctoEncodingList :: [CoverageReport] -> Encoding
toJSONList :: [CoverageReport] -> Value
$ctoJSONList :: [CoverageReport] -> Value
toEncoding :: CoverageReport -> Encoding
$ctoEncoding :: CoverageReport -> Encoding
toJSON :: CoverageReport -> Value
$ctoJSON :: CoverageReport -> Value
ToJSON, Value -> Parser [CoverageReport]
Value -> Parser CoverageReport
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [CoverageReport]
$cparseJSONList :: Value -> Parser [CoverageReport]
parseJSON :: Value -> Parser CoverageReport
$cparseJSON :: Value -> Parser CoverageReport
FromJSON)
makeLenses ''CoverageReport
instance Semigroup CoverageReport where
CoverageReport CoverageIndex
i1 CoverageData
d1 <> :: CoverageReport -> CoverageReport -> CoverageReport
<> CoverageReport CoverageIndex
i2 CoverageData
d2 = CoverageIndex -> CoverageData -> CoverageReport
CoverageReport (CoverageIndex
i1 forall a. Semigroup a => a -> a -> a
<> CoverageIndex
i2) (CoverageData
d1 forall a. Semigroup a => a -> a -> a
<> CoverageData
d2)
instance Monoid CoverageReport where
mempty :: CoverageReport
mempty = CoverageIndex -> CoverageData -> CoverageReport
CoverageReport forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty
mappend :: CoverageReport -> CoverageReport -> CoverageReport
mappend = forall a. Semigroup a => a -> a -> a
(<>)
coverageDataFromLogMsg :: String -> CoverageData
coverageDataFromLogMsg :: String -> CoverageData
coverageDataFromLogMsg = forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (Set CoverageAnnotation -> CoverageData
CoverageData forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> Set a
Set.singleton) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Read a => String -> Maybe a
readMaybe
instance Pretty CoverageReport where
pretty :: forall ann. CoverageReport -> Doc ann
pretty CoverageReport
report =
forall ann. [Doc ann] -> Doc ann
vsep forall a b. (a -> b) -> a -> b
$ [Doc ann
"=========[COVERED]=========="] forall a. [a] -> [a] -> [a]
++
[ forall ann. Int -> Doc ann -> Doc ann
nest Int
4 forall a b. (a -> b) -> a -> b
$ forall ann. [Doc ann] -> Doc ann
vsep (forall a ann. Pretty a => a -> Doc ann
pretty CoverageAnnotation
ann forall a. a -> [a] -> [a]
: (forall a b. (a -> b) -> [a] -> [b]
map forall a ann. Pretty a => a -> Doc ann
pretty forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Set a -> [a]
Set.toList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap CoverageMetadata -> Set Metadata
_metadataSet forall a b. (a -> b) -> a -> b
$ CoverageAnnotation -> Maybe CoverageMetadata
metadata CoverageAnnotation
ann))
| CoverageAnnotation
ann <- forall a. Set a -> [a]
Set.toList forall a b. (a -> b) -> a -> b
$ Set CoverageAnnotation
allAnns forall a. Ord a => Set a -> Set a -> Set a
`Set.intersection` Set CoverageAnnotation
coveredAnns ] forall a. [a] -> [a] -> [a]
++
[Doc ann
"========[UNCOVERED]========="] forall a. [a] -> [a] -> [a]
++
(forall a b. (a -> b) -> [a] -> [b]
map forall a ann. Pretty a => a -> Doc ann
pretty forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Set a -> [a]
Set.toList forall a b. (a -> b) -> a -> b
$ Set CoverageAnnotation
uncoveredAnns) forall a. [a] -> [a] -> [a]
++
[Doc ann
"=========[IGNORED]=========="] forall a. [a] -> [a] -> [a]
++
(forall a b. (a -> b) -> [a] -> [b]
map forall a ann. Pretty a => a -> Doc ann
pretty forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Set a -> [a]
Set.toList forall a b. (a -> b) -> a -> b
$ Set CoverageAnnotation
ignoredAnns forall a. Ord a => Set a -> Set a -> Set a
Set.\\ Set CoverageAnnotation
coveredAnns)
where
allAnns :: Set CoverageAnnotation
allAnns = CoverageReport
report forall s a. s -> Getting a s a -> a
^. Lens' CoverageReport CoverageIndex
coverageIndex forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getter CoverageIndex (Set CoverageAnnotation)
coverageAnnotations
coveredAnns :: Set CoverageAnnotation
coveredAnns = CoverageReport
report forall s a. s -> Getting a s a -> a
^. Lens' CoverageReport CoverageData
coverageData forall b c a. (b -> c) -> (a -> b) -> a -> c
. Iso' CoverageData (Set CoverageAnnotation)
coveredAnnotations
ignoredAnns :: Set CoverageAnnotation
ignoredAnns = CoverageReport
report forall s a. s -> Getting a s a -> a
^. Lens' CoverageReport CoverageIndex
coverageIndex forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getter CoverageIndex (Set CoverageAnnotation)
ignoredAnnotations
uncoveredAnns :: Set CoverageAnnotation
uncoveredAnns = Set CoverageAnnotation
allAnns forall a. Ord a => Set a -> Set a -> Set a
Set.\\ (Set CoverageAnnotation
coveredAnns forall a. Semigroup a => a -> a -> a
<> Set CoverageAnnotation
ignoredAnns)
metadata :: CoverageAnnotation -> Maybe CoverageMetadata
metadata CoverageAnnotation
ann = forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup CoverageAnnotation
ann (CoverageReport
report forall s a. s -> Getting a s a -> a
^. Lens' CoverageReport CoverageIndex
coverageIndex forall b c a. (b -> c) -> (a -> b) -> a -> c
. Iso' CoverageIndex (Map CoverageAnnotation CoverageMetadata)
coverageMetadata)