fitspec-0.4.4: refining property sets for testing Haskell programs

Copyright(c) 2015-2017 Rudy Matela
License3-Clause BSD (see the file LICENSE)
MaintainerRudy Matela <rudy@matela.com.br>
Safe HaskellNone
LanguageHaskell2010

Test.FitSpec.ShowMutable

Description

Exports a typeclass to show mutant variations.

Synopsis

Documentation

class ShowMutable a where #

Types that can have their mutation shown. Has only one function mutantS that returns a simple AST (MutantS) representing the mutant. A standard implementation of mutantS for Eq types is given by mutantSEq.

Minimal complete definition

mutantS

Methods

mutantS :: a -> a -> MutantS #

Instances

ShowMutable Bool # 

Methods

mutantS :: Bool -> Bool -> MutantS #

ShowMutable Char # 

Methods

mutantS :: Char -> Char -> MutantS #

ShowMutable Double # 

Methods

mutantS :: Double -> Double -> MutantS #

ShowMutable Float # 

Methods

mutantS :: Float -> Float -> MutantS #

ShowMutable Int # 

Methods

mutantS :: Int -> Int -> MutantS #

ShowMutable Integer # 

Methods

mutantS :: Integer -> Integer -> MutantS #

ShowMutable Ordering # 
ShowMutable Word # 

Methods

mutantS :: Word -> Word -> MutantS #

ShowMutable () # 

Methods

mutantS :: () -> () -> MutantS #

(Eq a, Show a) => ShowMutable [a] # 

Methods

mutantS :: [a] -> [a] -> MutantS #

(Eq a, Show a) => ShowMutable (Maybe a) # 

Methods

mutantS :: Maybe a -> Maybe a -> MutantS #

(Eq a, Show a, Integral a) => ShowMutable (Ratio a) # 

Methods

mutantS :: Ratio a -> Ratio a -> MutantS #

(Listable a, Show a, ShowMutable b) => ShowMutable (a -> b) # 

Methods

mutantS :: (a -> b) -> (a -> b) -> MutantS #

(Eq a, Show a, Eq b, Show b) => ShowMutable (Either a b) # 

Methods

mutantS :: Either a b -> Either a b -> MutantS #

(ShowMutable a, ShowMutable b) => ShowMutable (a, b) # 

Methods

mutantS :: (a, b) -> (a, b) -> MutantS #

(ShowMutable a, ShowMutable b, ShowMutable c) => ShowMutable (a, b, c) # 

Methods

mutantS :: (a, b, c) -> (a, b, c) -> MutantS #

(ShowMutable a, ShowMutable b, ShowMutable c, ShowMutable d) => ShowMutable (a, b, c, d) # 

Methods

mutantS :: (a, b, c, d) -> (a, b, c, d) -> MutantS #

(ShowMutable a, ShowMutable b, ShowMutable c, ShowMutable d, ShowMutable e) => ShowMutable (a, b, c, d, e) # 

Methods

mutantS :: (a, b, c, d, e) -> (a, b, c, d, e) -> MutantS #

(ShowMutable a, ShowMutable b, ShowMutable c, ShowMutable d, ShowMutable e, ShowMutable f) => ShowMutable (a, b, c, d, e, f) # 

Methods

mutantS :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> MutantS #

mutantSEq :: (Eq a, Show a) => a -> a -> MutantS #

For a given type Type instance of Eq and Show, define the ShowMutable instance as:

instance ShowMutable Type
  where mutantS = mutantSEq

showMutantAsTuple :: ShowMutable a => [String] -> a -> a -> String #

Show a Mutant as a tuple of lambdas.

> putStrLn $ showMutantAsTuple ["p && q","not p"] ((&&),not) ((||),id)
( \p q -> case (p,q) of
           (False,False) -> True
           _ -> p && q
, \p -> case p of
          False -> False
          True -> True
          _ -> not p )

Can be easily copy pasted into an interactive session for manipulation. On GHCi, use :{ and :} to allow multi-line expressions and definitions.

showMutantNested :: ShowMutable a => [String] -> a -> a -> String #

Show a Mutant as a tuple of nested lambdas. Very similar to showMutantAsTuple, but the underlying data structure is not flatten: so the output is as close as possible to the underlying representation.

showMutantDefinition :: ShowMutable a => [String] -> a -> a -> String #

Show a Mutant as a new complete top-level definition, with a prime appended to the name of the mutant.

> putStrLn $ showMutantDefinition ["p && q","not p"] ((&&),not) ((==),id)
False &&- False = True
p     &&- q     = p && q
not' False = False
not' True  = True
not' p     = not p

showMutantBindings :: ShowMutable a => [String] -> a -> a -> String #

Show a Mutant as the list of bindings that differ from the original function(s).

> putStrLn $ showMutantBindings ["p && q","not p"] ((&&),not) ((==),id)
False && False = True
not False = False
not True  = True

Can possibly be copied into the source of the original function for manipulation.

data MutantS #

(Show) Structure of a mutant. This format is intended for processing then pretty-printing.

Instances