From c8b5c8a9e092658d756bea32a716dc59abda1ded Mon Sep 17 00:00:00 2001 From: Christopher Pitt Date: Fri, 27 Oct 2017 19:12:27 -0400 Subject: [PATCH] Refactor for new plugin --- composer.json | 21 ++++++++-------- phpunit.xml | 2 +- {src => source}/macros.yay | 0 tests/MacroTest.php | 44 +++++++++++++++++++++++++++++++++ tests/SpecTest.php | 13 ---------- tests/bootstrap.php | 7 ------ tests/specs/async.spec | 50 ++++++++++++++++++++------------------ 7 files changed, 82 insertions(+), 55 deletions(-) rename {src => source}/macros.yay (100%) create mode 100644 tests/MacroTest.php delete mode 100644 tests/SpecTest.php delete mode 100644 tests/bootstrap.php diff --git a/composer.json b/composer.json index 8fcd8ef..d3b4088 100644 --- a/composer.json +++ b/composer.json @@ -2,20 +2,21 @@ "type": "pre-macro", "name": "pre/async", "license": "MIT", + "repositories": [ + { + "type": "path", + "url": "../pre-plugin" + } + ], "require": { - "pre/plugin": "^0.7.3" + "pre/plugin": "*" }, "require-dev": { "phpunit/phpunit": "^5.0|^6.0" }, - "autoload-dev": { - "psr-4": { - "Pre\\Async\\": "tests" - } - }, "extra": { - "macros": [ - "src/macros.yay" - ] - } + "macros": ["source/macros.yay"] + }, + "minimum-stability": "dev", + "prefer-stable": true } diff --git a/phpunit.xml b/phpunit.xml index bd5ed4c..eb6713c 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -2,7 +2,7 @@ format($from))); + $this->assertEquals($this->format($expected), $actual); + } + + private function format($code) + { + return "something(); - yield $thing; -}; - -$third = async () => { - yield $thing; -}; - ---EXPECT-- - -interface AsyncInterface -{ - public function run(): \Amp\Promise; -} +~~~ class AsyncClass { @@ -72,6 +57,23 @@ class AsyncClass } } +--- + +$first = async function() { + yield "here"; +}; + +$second = async function() { + $this->something(); + yield $thing; +}; + +$third = async () => { + yield $thing; +}; + +~~~ + $first = function (): \Amp\Promise { return \Amp\call(function () { yield "here";