Skip to content

Commit

Permalink
Merge pull request #46
Browse files Browse the repository at this point in the history
Add tests for resolve callables
  • Loading branch information
kelunik committed May 11, 2016
2 parents 452c9b7 + 6f4433d commit bb85e40
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/FunctionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,35 @@ public function testCoroutineFauxReturnValue() {
$this->assertSame(1, $invoked);
}

public function testResolveAcceptsGeneratorCallable() {
\Amp\run(function() {
$result = (yield \Amp\resolve(function () {
yield new CoroutineResult(42);
}));
$this->assertSame(42, $result);
});
}

/**
* @expectedException \LogicException
*/
public function testResolveNonGeneratorCallableThrows() {
\Amp\run(function() {
yield \Amp\resolve(function () {
return 42;
});
});
}

/**
* @expectedException \InvalidArgumentException
*/
public function testResolveInvalidArgumentThrows() {
\Amp\run(function() {
yield \Amp\resolve(42);
});
}

public function testResolutionFailuresAreThrownIntoGeneratorCoroutine() {
$invoked = 0;
\Amp\run(function () use (&$invoked) {
Expand Down

0 comments on commit bb85e40

Please sign in to comment.