Safe Haskell | None |
---|---|
Language | Haskell2010 |
Mutation happens here.
- genMutants :: String -> FilePath -> IO [Mutant]
- genMutantsWith :: Config -> String -> FilePath -> IO [Mutant]
- sampler :: RandomGen g => Config -> g -> MuVars -> [t] -> [t]
- genMutantsForSrc :: Config -> String -> String -> (MuVars -> [MuOp] -> [MuOp]) -> [Mutant]
- replaceDef :: Decl -> Decl -> Module -> [Decl]
- getFunc :: String -> Module -> Decl
- mutates :: [MuOp] -> Decl -> [Decl]
- mutatesN :: [MuOp] -> Decl -> Int -> [Decl]
- mutate :: MuOp -> Decl -> [Decl]
- isFunctionD :: String -> Decl -> Bool
- permMatches :: Decl -> [MuOp]
- removeOnePMatch :: Decl -> [MuOp]
- removeOneElem :: Eq t => [t] -> [[t]]
- getASTFromStr :: String -> Module
- putDecls :: Module -> [Decl] -> Module
- selectValOps :: (Typeable b, Mutable b) => (b -> Bool) -> (b -> [b]) -> Decl -> [MuOp]
- selectLitOps :: Decl -> [MuOp]
- selectBLitOps :: Decl -> [MuOp]
- selectIfElseBoolNegOps :: Decl -> [MuOp]
- selectGuardedBoolNegOps :: Decl -> [MuOp]
Documentation
genMutants :: String -> FilePath -> IO [Mutant] Source
The genMutants
function is a wrapper to genMutantsWith with standard
configuraton
genMutantsWith :: Config -> String -> FilePath -> IO [Mutant] Source
The genMutantsWith
function takes configuration function to mutate,
filename the function is defined in, and produces mutants in the same
directory as the filename, and returns the number of mutants produced.
sampler :: RandomGen g => Config -> g -> MuVars -> [t] -> [t] Source
Wrapper around sampleF that returns correct sampling ratios according to configuration passed.
genMutantsForSrc :: Config -> String -> String -> (MuVars -> [MuOp] -> [MuOp]) -> [Mutant] Source
The genMutantsForSrc
takes the function name to mutate, source where it
is defined, and a sampling function, and returns the mutated sources selected
using sampling function.
replaceDef :: Decl -> Decl -> Module -> [Decl] Source
Replace old function definition with a new one in the AST
mutates :: [MuOp] -> Decl -> [Decl] Source
Higher order mutation of a function's code using a bunch of mutation operators (In all the three mutate functions, we assume working with functions declaration.)
mutatesN :: [MuOp] -> Decl -> Int -> [Decl] Source
First and higher order mutation. The third argument specifies whether it's first order or higher order
mutate :: MuOp -> Decl -> [Decl] Source
Given a function, generate all mutants after applying applying op once (op might be applied at different places). E.g.: if the operator is (op = "== ">") and there are two instances of "<" in the AST, then it will return two AST with each replaced.
isFunctionD :: String -> Decl -> Bool Source
is the parsed expression the function we are looking for?
permMatches :: Decl -> [MuOp] Source
Generate all operators for permutating pattern matches in a function. We don't deal with permutating guards and case for now.
removeOnePMatch :: Decl -> [MuOp] Source
Generates transformations that removes one pattern match from a function definition.
removeOneElem :: Eq t => [t] -> [[t]] Source
Generate sub-arrays with one less element
getASTFromStr :: String -> Module Source
Returns the AST from the file
selectValOps :: (Typeable b, Mutable b) => (b -> Bool) -> (b -> [b]) -> Decl -> [MuOp] Source
For valops, unlike functions, we specify how any given literal value might change. So we take a predicate specifying how to recognize the literal value, a list of mappings specifying how the literal can change, and the AST, and recurse over the AST looking for literals that match our predicate. When we find any, we apply the given list of mappings to them, and produce a MuOp mapping between the original value and transformed value. This list of MuOp mappings are then returned.
selectLitOps :: Decl -> [MuOp] Source
Look for literal values in AST, and return applicable MuOp transforms. Unfortunately booleans are not handled here.
selectBLitOps :: Decl -> [MuOp] Source
Convert Boolean Literals
selectIfElseBoolNegOps :: Decl -> [MuOp] Source
Negating boolean in if/else statements
selectGuardedBoolNegOps :: Decl -> [MuOp] Source
Negating boolean in Guards