/** * 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)); }
/** * 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)); }
/** * 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()); }