1
0
Fork 0

Merge branch '1.8'

* 1.8:
  Follow up to #7946 test: add solver flag to assert path execution
pull/7977/head
Nils Adermann 2019-02-10 20:28:05 +01:00
commit 0619fbed58
2 changed files with 13 additions and 0 deletions

View File

@ -57,6 +57,9 @@ class Solver
/** @var array */ /** @var array */
protected $learnedWhy = array(); protected $learnedWhy = array();
/** @var bool */
public $testFlagLearnedPositiveLiteral = false;
/** @var IOInterface */ /** @var IOInterface */
protected $io; protected $io;
@ -470,6 +473,9 @@ class Solver
unset($seen[abs($literal)]); unset($seen[abs($literal)]);
if ($num && 0 === --$num) { if ($num && 0 === --$num) {
if ($literal < 0) {
$this->testFlagLearnedPositiveLiteral = true;
}
$learnedLiterals[0] = -$literal; $learnedLiterals[0] = -$literal;
if (!$l1num) { if (!$l1num) {

View File

@ -891,6 +891,9 @@ class SolverTest extends TestCase
$this->request->install('A'); $this->request->install('A');
// check correct setup for assertion later
$this->assertFalse($this->solver->testFlagLearnedPositiveLiteral);
$this->checkSolverResult(array( $this->checkSolverResult(array(
array('job' => 'install', 'package' => $packageF1), array('job' => 'install', 'package' => $packageF1),
array('job' => 'install', 'package' => $packageD), array('job' => 'install', 'package' => $packageD),
@ -900,6 +903,10 @@ class SolverTest extends TestCase
array('job' => 'install', 'package' => $packageB), array('job' => 'install', 'package' => $packageB),
array('job' => 'install', 'package' => $packageA), array('job' => 'install', 'package' => $packageA),
)); ));
// verify that the code path leading to a negative literal resulting in a positive learned literal is actually
// executed
$this->assertTrue($this->solver->testFlagLearnedPositiveLiteral);
} }
protected function reposComplete() protected function reposComplete()