| 1 | <?php |
||
| 15 | class ParserSpec extends ObjectBehavior |
||
| 16 | { |
||
| 17 | function let(Grammar $grammar, Processor $processor) |
||
| 18 | { |
||
| 19 | $this->beConstructedWith($grammar, $processor); |
||
| 20 | } |
||
| 21 | |||
| 22 | function it_is_initializable() |
||
| 23 | { |
||
| 24 | $this->shouldHaveType(Parser::CLASS); |
||
| 25 | } |
||
| 26 | |||
| 27 | function it_throws_exception_if_parser_fails($grammar) |
||
| 28 | { |
||
| 29 | $grammar->parse('')->willThrow(new \Exception); |
||
| 30 | $this->shouldThrow(ParserException::CLASS)->duringParse(''); |
||
| 31 | } |
||
| 32 | |||
| 33 | function it_throws_exception_if_processor_fails($grammar, $processor, Node $node) |
||
| 34 | { |
||
| 35 | $grammar->parse('')->willReturn($node); |
||
| 36 | $node->accept($processor)->shouldBeCalled(); |
||
| 37 | $processor->hasErrors()->willReturn(true)->shouldBeCalled(); |
||
| 38 | $processor->getErrors()->willReturn(['error'])->shouldBeCalled(); |
||
| 39 | $this->shouldThrow(ParserException::CLASS)->duringParse(''); |
||
| 40 | } |
||
| 41 | } |
||
| 42 |