Skip to content
This repository has been archived by the owner on Mar 30, 2018. It is now read-only.

Mutate only methods, no functions #201

Merged
merged 6 commits into from
May 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,9 @@ Humbug implements a basic suite of Mutators, which essentially tells us when a
particular PHP token can be mutated, and also apply that mutation to an array
of tokens.

Note: Source code held within functions (rather than class methods) is not mutated
at this time.

Binary Arithmetic:

| Original | Mutated | Original | Mutated |
Expand Down
2 changes: 1 addition & 1 deletion features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function iShouldSee(PyStringNode $string)
*/
public function iShouldSeeContaining(PyStringNode $string)
{
if (!preg_match('/' . preg_quote((string) $string) . '/', $this->appTester->getDisplay())) {
if (!preg_match('/' . preg_quote((string) $string, '/') . '/', $this->appTester->getDisplay())) {
throw new \RuntimeException(sprintf(
'Output did not match expected pattern:%s%s', PHP_EOL, $this->appTester->getDisplay()
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Feature: Use Humbug
$foo = new Foo;
$r = $foo->add(2, 1);
// emulate error
if ($r !== 3) $foo->bar();
if ($r !== 3) require __DIR__ . '/this.does.not.exist.xyz';
$this->assertEquals(3, $r);
}
}
Expand Down
2 changes: 1 addition & 1 deletion features/version.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Feature: Developer runs Humbug with --version option
Scenario: View Humbug version
Given I am in any directory
When I run humbug with "--version"
Then I should see:
Then I should see output containing:
"""
_ _ _
| || |_ _ _ __ | |__ _ _ __ _
Expand Down
2 changes: 1 addition & 1 deletion src/Mutable.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function generate()
}

//TODO: handle whitespace!
if (is_array($token) && $token[0] == T_FUNCTION) {
if (is_array($token) && $token[0] == T_FUNCTION && '???' !== $className) {
if (!isset($tokens[$index+2][1])) {
continue; // ignore closure
}
Expand Down