assertSame($expected[$i++], $value); }); }); } /** * @depends testMerge */ public function testMergeWithFailedStream() { $exception = new \Exception; Loop::run(function () use (&$reason, $exception) { $producer = new Producer(function (callable $emit) use ($exception) { yield $emit(1); // Emit once before failing. throw $exception; }); $stream = Amp\merge([$producer, Amp\stream(\range(1, 5))]); $callback = function ($exception, $value) use (&$reason) { $reason = $exception; }; $stream->when($callback); }); $this->assertSame($exception, $reason); } /** * @expectedException \Error * @expectedExceptionMessage Non-stream provided */ public function testNonStream() { Amp\merge([1]); } }