1
0
mirror of https://github.com/danog/amp.git synced 2024-11-27 04:24:42 +01:00

Add missing coroutine tests

This commit is contained in:
Niklas Keller 2017-03-14 22:32:14 +01:00
parent 179eb3d6f8
commit dfab1d885f

View File

@ -96,6 +96,40 @@ class CoroutineTest extends TestCase {
});
}
public function testYieldPromiseArrayAfterPendingPromise() {
Loop::run(function () {
$value = 1;
$generator = function () use (&$yielded, $value) {
yield new Pause(10);
list($yielded) = yield [
new Success($value)
];
};
yield new Coroutine($generator());
$this->assertSame($value, $yielded);
});
}
public function testYieldNonPromiseArrayAfterPendingPromise() {
$this->expectException(InvalidYieldError::class);
Loop::run(function () {
$value = 1;
$generator = function () use (&$yielded, $value) {
yield new Pause(10);
list($yielded) = yield [
$value
];
};
yield new Coroutine($generator());
});
}
/**
* @depends testYieldFailedPromise
*/