continue()) { $this->assertSame(\array_shift($expected), $value); } } /** * @depends testConcat */ public function testConcatWithFailedPipeline() { $exception = new TestException; $expected = \range(1, 6); $generator = new AsyncGenerator(static function (callable $yield) use ($exception) { yield $yield(6); // Emit once before failing. throw $exception; }); $pipeline = Pipeline\concat([ Pipeline\fromIterable(\range(1, 5)), $generator, Pipeline\fromIterable(\range(7, 10)), ]); try { while (null !== $value = yield $pipeline->continue()) { $this->assertSame(\array_shift($expected), $value); } $this->fail("The exception used to fail the pipeline should be thrown from continue()"); } catch (TestException $reason) { $this->assertSame($exception, $reason); } $this->assertEmpty($expected); } public function testNonPipeline() { $this->expectException(\TypeError::class); /** @noinspection PhpParamsInspection */ Pipeline\concat([1]); } }