-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from preprocess/refactor-for-new-plugin
Refactor for new plugin
- Loading branch information
Showing
8 changed files
with
46 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ macro { | |
} | ||
} | ||
|
||
macro { | ||
macro ·unsafe { | ||
function __call(···parameters) { | ||
immutability; | ||
···body | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,43 @@ | ||
<?php | ||
|
||
namespace Pre\ImmutableClasses; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
use Pre\Plugin\Testing\Runner; | ||
|
||
class MacroTest extends Runner | ||
class MacroTest extends TestCase | ||
{ | ||
protected function path(): string | ||
/** | ||
* @test | ||
* @dataProvider specs | ||
*/ | ||
public function can_transform_code($from, $expected) | ||
{ | ||
Pre\Plugin\addMacro(__DIR__ . "/../source/macros.yay"); | ||
|
||
$actual = Pre\plugin\format(Pre\Plugin\parse($this->format($from))); | ||
$this->assertEquals($this->format($expected), $actual); | ||
} | ||
|
||
private function format($code) | ||
{ | ||
return __DIR__ . "/specs"; | ||
return "<?php\n\n" . trim($code) . "\n"; | ||
} | ||
|
||
public static function specs() | ||
{ | ||
$specs = []; | ||
|
||
$files = [ | ||
__DIR__ . "/specs/fallbacks.spec", | ||
__DIR__ . "/specs/immutability.spec", | ||
]; | ||
|
||
foreach ($files as $file) { | ||
$contents = file_get_contents($file); | ||
|
||
foreach (explode("---", $contents) as $spec) { | ||
array_push($specs, explode("~~~", $spec)); | ||
} | ||
} | ||
|
||
return $specs; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters