mirror of
https://github.com/danog/amp.git
synced 2024-11-30 04:29:08 +01:00
Add missing coroutine tests
This commit is contained in:
parent
179eb3d6f8
commit
dfab1d885f
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user