コード例 #1
0
 /**
  * @test
  */
 public function it_creates_a_sequence_with_any_expectation()
 {
     $sequence = SequenceBuilder::create()->expect()->quantity()->any()->token(T_WHITESPACE, "\n")->end()->end()->build();
     $expectedSequence = new ForwardSequence();
     $expectedSequence->addExpectation(new Quantity(new ExactMatch(T_WHITESPACE, "\n"), null, null));
     $this->assertEquals($expectedSequence, $sequence);
 }
コード例 #2
0
 /**
  * @test
  * @dataProvider tokensProvider
  */
 public function it_walks_forward_over_an_array_of_tokens($tokens, $tokenIndex, $expectedTokens)
 {
     $forwardSequence = new ForwardSequence();
     $expectationSpy = new Spy();
     $forwardSequence->addExpectation($expectationSpy);
     $forwardSequence->matches($tokens, $tokenIndex);
     $this->assertEquals($expectedTokens, $expectationSpy->getTokens());
 }
コード例 #3
0
 /**
  * @test
  * @dataProvider tokensProvider
  */
 public function it_matches_a_number_of_tokens(ExpectationInterface $innerExpectation, $minimum, $maximum, array $tokens, $tokenIndex, $expectedToMatch)
 {
     $sequence = new ForwardSequence();
     $sequence->addExpectation(new Quantity($innerExpectation, $minimum, $maximum));
     $this->assertSame($expectedToMatch, $sequence->matches($tokens, $tokenIndex));
 }
コード例 #4
0
 /**
  * @test
  * @dataProvider tokensProvider
  */
 public function it_matches_exactly_one_token($tokens, $tokenIndex, $expectedToMatch)
 {
     $sequence = new ForwardSequence();
     $sequence->addExpectation(new ExactMatch(T_WHITESPACE));
     $this->assertSame($expectedToMatch, $sequence->matches($tokens, $tokenIndex));
 }