Example #1
0
 /**
  * Test the `addOperator` and `getOperatorTable` accessors.
  */
 public function testOperatorTableAccessors()
 {
     $operator = new BinaryOperator(1, 1, BinaryOperator::LEFT, function () {
     });
     $token = new Token($operator->getCode(), 1, 1);
     $grammar = new Grammar();
     $grammar->addOperator($operator);
     $this->assertSame($operator, $grammar->getOperatorTable()->getBinaryOperator($token));
 }
Example #2
0
 /**
  * Test if the `isTernary` method returns false if the given token is not the `if` or an `else` token
  * of a ternary operator.
  */
 public function testIsTernaryReturnsFalse()
 {
     $operator = new BinaryOperator(1, 10, BinaryOperator::LEFT, function () {
     });
     $token = new Token($operator->getCode(), '+', 1);
     $table = new OperatorTable();
     $table->addOperator($operator);
     $this->assertFalse($table->isTernary($token));
 }
Example #3
0
 /**
  * Test if the method `isRightAssociative` returns false if the operator isn't right associative.
  */
 public function testIsRightAssociativeReturnsFalse()
 {
     $operator = new BinaryOperator(1, 10, BinaryOperator::LEFT, function () {
     });
     $this->assertFalse($operator->isRightAssociative());
 }