continue()) { $this->assertSame(\array_shift($expected), $value); } } /** * @depends testConcat */ public function testConcatWithFailedPipeline(): void { $exception = new TestException; $expected = \range(1, 6); $generator = new AsyncGenerator(static function () use ($exception) { 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 = $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(): void { $this->expectException(\TypeError::class); /** @noinspection PhpParamsInspection */ Pipeline\concat([1]); } }