示例#1
0
 /**
  * @covers ::isPhiVar
  */
 public function testisPhiVarNonValue()
 {
     $this->graph->ensureArc($this->v[5], $p = new Phi(new Variable()));
     $p->addValue(new Variable());
     $this->assertFalse(Helper::isPhiVar(new Variable(), $this->graph));
 }
示例#2
0
 /**
  * @covers ::process
  */
 public function testRemoveCountedPhi()
 {
     $rule = new Phi();
     $vertex = new JitPhi($r = new Variable(new Type(Type::TYPE_DOUBLE)));
     $vertex->addValue($v = new Variable(new Type(Type::TYPE_DOUBLE)));
     $v2 = $this->getMock(Vertex\Assign::class, [], [], '', false);
     $v2->expects($this->once())->method('getResult')->will($this->returnValue($r));
     $v2->expects($this->once())->method('setResult')->with($this->identicalTo($v));
     $graph = $this->getMock(DirectedAdjacencyList::class);
     $graph->expects($this->exactly(1))->method('vertices')->will($this->returnValue(call_user_func(function () use($vertex, $v2) {
         (yield $vertex);
         (yield $v2);
     })));
     $transposed = $this->getMock(DirectedAdjacencyList::class);
     $transposed->expects($this->once())->method('successorsOf')->with($this->identicalTo($vertex))->will($this->returnValue([]));
     $graph->expects($this->once())->method('transpose')->will($this->returnValue($transposed));
     $this->assertTrue($rule->process($vertex, $graph));
 }
示例#3
0
 /**
  * @covers ::replaceVariable
  */
 public function testReplaceVariablesNeither()
 {
     $phi = new Phi($r = new Variable());
     $phi->addValue($a = new Variable());
     $phi->addValue($b = new Variable());
     $phi->replaceVariable(new Variable(), new Variable());
     $this->assertSame([$r, $a, $b], $phi->getVariables());
 }