示例#1
0
 /**
  * @covers ::process
  * @covers ::addRule
  */
 public function testOperation()
 {
     $graph = new DirectedAdjacencyList();
     $func = new Function_([], new Type(0), $graph);
     $graph->ensureVertex($func);
     $state = new GraphState($func);
     $resolver = new Optimizer();
     $resolver->addRule($r = $this->getMock(OptimizerRule::class));
     $r->expects($this->once())->method('process')->with($this->identicalTo($func))->will($this->returnValue(false));
     $resolver->process($state);
 }
示例#2
0
 /**
  * @covers ::isLiveVar
  */
 public function testIsLiveVarWithCycleAndLaterValue()
 {
     $graph = new DirectedAdjacencyList();
     $var = new Variable();
     $vertex = $this->getMock(Vertex::class);
     $graph->ensureVertex($vertex);
     $vertex->expects($this->once())->method('getVariables')->will($this->returnValue([]));
     $v1 = $this->getMock(Vertex::class);
     $v1->expects($this->once())->method('getVariables')->will($this->returnValue([$var]));
     $graph->ensureArc($vertex, $v1);
     $this->assertTrue(Helper::isLiveVar($var, $vertex, $graph));
 }