コード例 #1
0
ファイル: NodeTest.php プロジェクト: mossadal/math-parser
 public function testCanCompareFunctionNodes()
 {
     $node = new FunctionNode('sin', new VariableNode('x'));
     $other = new NumberNode(1);
     $this->assertFalse($node->compareTo(null));
     $this->assertFalse($node->compareTo($other));
     $this->assertTrue($node->compareTo($node));
     $this->assertFalse($node->compareTo(new FunctionNode('cos', new VariableNode('x'))));
 }
コード例 #2
0
ファイル: NodeTest.php プロジェクト: mossadal/math-parser
 public function testCanCompareUnaryMinus()
 {
     $node = new FunctionNode('sin', new ExpressionNode(new VariableNode('x'), '-', null));
     $other = new FunctionNode('sin', new ExpressionNode(new VariableNode('a'), '-', null));
     $this->assertTrue($node->compareTo($node));
     $this->assertTrue($other->compareTo($other));
     $this->assertFalse($node->compareTo($other));
     $this->assertFalse($other->compareTo($node));
 }