Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added mutation list todo
Streamlined mutation generation to occur JIT instead of all up front
  • Loading branch information
padraic committed Jul 30, 2011
1 parent 0ec5fee commit 1702907
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 6 deletions.
58 changes: 58 additions & 0 deletions SupportedMutations
@@ -0,0 +1,58 @@
Supported Mutations
-------------------

TODO - RENAMES

1. BooleanAnd - replaces && with ||
2. BooleanOr - replaces || with &&
3. BooleanFalse - replaces FALSE with TRUE
4. BooleanTrue - replaces TRUE with FALSE
5. OperatorAddition - replaces + with -
6. OperatorSubtraction - replaces - with +
7. OperatorDecrement - replaces -- with ++
8. OperatorIncrement - replaces ++ with --

TODO - OPERATORS

9. OperatorArithmeticDivision - replaces / with *
10. OperatorArithmeticModulus - replaces % with *
11. OperatorArithmeticMultiplication - replaces * with /
12. OperatorNegation - replaces - with <blank>
13. OperatorAssignmentPlusEqual - replaces += with -=
14. OperatorAssignmentMinusEqual - replaces -= with +=
15. OperatorBitwiseAnd - replaces & with |
16. OperatorBitwiseOr - replaces | with &
17. OperatorBitwiseXor - replaces ^ with |
18. OperatorBitwiseNot - replaces ~ with <blank>
19. OperatorBitwiseShiftLeft - replaces << with >>
20. OperatorBitwiseShiftRight - replaces >> with <<
21. OperatorComparisonEqual - replaces == with !=
22. OperatorComparisonIdentical - replaces === with !==
23. OperatorComparisonNotEqual - replaces != with ==
24. OperatorComparisonNotEqualAngular - replaces <> with ==
25. OperatorComparisonNotIdentical - replaces !== with ===
26. OperatorComparisonLessThan - replaces < with >
27. OperatorComparisonGreaterThan - replaces > with <
28. OperatorComparisonLessThenOrEqualTo - replaces <= with >
29. OperatorComparisonGreaterThanOrEqualTo - replaces >= with <
30. OperatorLogicalAnd - replaces AND with Or
31. OperatorLogicalOr - replaces OR with AND
32. OperatorLogicalXor - replaces XOR with AND
33. OperatorLogicalNot - replaces ! with <blank>
*34. OperatorLogicalAndSym - replaces && with || <replaces 1>
*35. OperatorLogicalOrSym - replaces || with && <replaces 2>
36. OperatorTypeInstanceof - replaces instanceof with !instanceof
*37. OperatorTypeNotInstanceOf - <covered by OperatorLogicalNot>

TODO - SCALARS

38. ScalarString - replaces a literal string with random string
39. ScalarRegex - replaces a regex with random regex
40. ScalarInteger - replace an integer with random integer
41. ScalarFloat - replace a float with random float
42. ScalarNumeric - replace a string if numeric with a random numeric string

TODO - LOGICAL

43. LogicalIf - replaces positive IF condition with a negative one
*44. LogicalIfNegative - <covered by OperatorLogicalNot>
1 change: 0 additions & 1 deletion library/Mutagenesis/Generator.php
Expand Up @@ -64,7 +64,6 @@ public function generate($mutableObject = null)
$mutable = new $mutableObject; $mutable = new $mutableObject;
$mutable->setFilename($file); $mutable->setFilename($file);
} }
$mutable->generate();
$this->_mutables[] = $mutable; $this->_mutables[] = $mutable;
} }
} }
Expand Down
10 changes: 10 additions & 0 deletions library/Mutagenesis/Mutable.php
Expand Up @@ -64,6 +64,15 @@ public function generate()
{ {
$this->_mutables = $this->_parseMutables(); $this->_mutables = $this->_parseMutables();
$this->_parseTokensToMutations($this->_mutables); $this->_parseTokensToMutations($this->_mutables);
return $this;
}

/**
* Cleanup routines for memory management
*/
public function cleanup()
{
unset($this->_mutations, $this->_mutables);
} }


/** /**
Expand Down Expand Up @@ -121,6 +130,7 @@ public function getMutables()
public function hasMutation($type) public function hasMutation($type)
{ {
$typeClass = '\\Mutagenesis\\Mutation\\' . $type; $typeClass = '\\Mutagenesis\\Mutation\\' . $type;
// I know, wtf?!
$mutations = array_values(array_values(array_values($this->getMutations()))); $mutations = array_values(array_values(array_values($this->getMutations())));
foreach ($mutations as $mutation) { foreach ($mutations as $mutation) {
if ($mutation instanceof $typeClass) { if ($mutation instanceof $typeClass) {
Expand Down
4 changes: 2 additions & 2 deletions library/Mutagenesis/Renderer/Text.php
Expand Up @@ -31,7 +31,7 @@ class Text implements RendererInterface
*/ */
public function renderOpening() public function renderOpening()
{ {
$out = 'Mutagenesis 0.5: Mutation Testing for PHP' $out = 'Mutagenesis: Mutation Testing for PHP'
. PHP_EOL . PHP_EOL; . PHP_EOL . PHP_EOL;
return $out; return $out;
} }
Expand Down Expand Up @@ -143,7 +143,7 @@ public function renderReport($total, $killed, $escaped, array $mutations, array
. PHP_EOL . $this->_indentTestOutput($mutant[1]) . PHP_EOL . PHP_EOL; . PHP_EOL . $this->_indentTestOutput($mutant[1]) . PHP_EOL . PHP_EOL;
$i++; $i++;
} }
$out .= "Check above these capture details to see if any mutants" $out .= "Check above for the capture details to see if any mutants"
. ' escaped.'; . ' escaped.';
} }
return $out; return $out;
Expand Down
6 changes: 4 additions & 2 deletions library/Mutagenesis/Runner/Base.php
Expand Up @@ -69,8 +69,8 @@ public function execute()
* to dynamically alter included (in-memory) classes on the fly. * to dynamically alter included (in-memory) classes on the fly.
*/ */


foreach ($mutables as $mutable) { foreach ($mutables as $i=>$mutable) {
$mutations = $mutable->getMutations(); $mutations = $mutable->generate()->getMutations();
foreach ($mutations as $mutation) { foreach ($mutations as $mutation) {
$output = \Mutagenesis\Utility\Process::run( $output = \Mutagenesis\Utility\Process::run(
$job->generate($mutation), $this->getTimeout() $job->generate($mutation), $this->getTimeout()
Expand All @@ -97,6 +97,8 @@ public function execute()
} }
echo $renderer->renderProgressMark($result); echo $renderer->renderProgressMark($result);
} }
$mutable->cleanup();
unset($this->_mutables[$i]);
} }


/** /**
Expand Down
2 changes: 1 addition & 1 deletion tests/Mutagenesis/Renderer/TextTest.php
Expand Up @@ -40,7 +40,7 @@ public function setUp()
public function testRendersOpeningMessage() public function testRendersOpeningMessage()
{ {
$this->assertEquals( $this->assertEquals(
'Mutagenesis 0.5: Mutation Testing for PHP' . PHP_EOL . PHP_EOL, 'Mutagenesis: Mutation Testing for PHP' . PHP_EOL . PHP_EOL,
$this->_renderer->renderOpening() $this->_renderer->renderOpening()
); );
} }
Expand Down

0 comments on commit 1702907

Please sign in to comment.