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