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