/** * Test all getters for the values set with the constructor. */ public function testConstructorAccessors() { $code = mt_rand(1, 100); $precedence = mt_rand(1, 100); $closure = function () { }; $operator = new UnaryOperator($code, $precedence, $closure); $this->assertSame($code, $operator->getCode()); $this->assertSame($precedence, $operator->getPrecedence()); $this->assertSame($closure, $operator->getNode()); }
/** * Test if the `isUnary` method returns true if the given token is an unary operator. */ public function testIsUnaryReturnsTrue() { $operator = new UnaryOperator(1, 10, function () { }); $token = new Token($operator->getCode(), '+', 1); $table = new OperatorTable(); $table->addOperator($operator); $this->assertTrue($table->isUnary($token)); }