advance()) { $this->assertSame(\array_shift($expected), $iterator->getCurrent()); } }); } /** * @depends testConcat */ public function testConcatWithFailedIterator() { Loop::run(function () { $exception = new TestException; $expected = \range(1, 6); $producer = new Producer(function (callable $emit) use ($exception) { yield $emit(6); // Emit once before failing. throw $exception; }); $iterator = Iterator\concat([Iterator\fromIterable(\range(1, 5)), $producer, Iterator\fromIterable(\range(7, 10))]); try { while (yield $iterator->advance()) { $this->assertSame(\array_shift($expected), $iterator->getCurrent()); } $this->fail("The exception used to fail the iterator should be thrown from advance()"); } catch (TestException $reason) { $this->assertSame($exception, $reason); } $this->assertEmpty($expected); }); } /** * @expectedException \TypeError */ public function testNonIterator() { Iterator\concat([1]); } }