continue()) { $this->assertSame(\array_shift($expected), $value); } } /** * @depends testConcat */ public function testConcatWithFailedStream() { $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; }); $stream = Stream\concat([ Stream\fromIterable(\range(1, 5)), $generator, Stream\fromIterable(\range(7, 10)), ]); try { while (list($value) = yield $stream->continue()) { $this->assertSame(\array_shift($expected), $value); } $this->fail("The exception used to fail the stream should be thrown from continue()"); } catch (TestException $reason) { $this->assertSame($exception, $reason); } $this->assertEmpty($expected); } public function testNonStream() { $this->expectException(\TypeError::class); /** @noinspection PhpParamsInspection */ Stream\concat([1]); } }