1
0
Fork 0

Correct handling of rules with more than 2 literals.

pull/9/head
Nils Adermann 2011-08-21 06:30:06 -04:00
parent db18e1b560
commit 69ebbf0eac
2 changed files with 26 additions and 7 deletions

View File

@ -1270,16 +1270,16 @@ class Solver
if (sizeof($ruleLiterals) > 2) {
foreach ($ruleLiterals as $ruleLiteral) {
if (!$otherWatch->equals($ruleLiteral) &&
if ($otherWatch !== $ruleLiteral->getId() &&
!$this->decisionsConflict($ruleLiteral)) {
if ($literal->equals($rule->getWatch1())) {
$rule->setWatch1($ruleLiteral);
$rule->setNext1($rule);
if ($literal->getId() === $rule->watch1) {
$rule->watch1 = $ruleLiteral->getId();
$rule->next1 = (isset($this->watches[$ruleLiteral->getId()])) ? $this->watches[$ruleLiteral->getId()] : null ;
} else {
$rule->setWatch2($ruleLiteral);
$rule->setNext2($rule);
$rule->watch2 = $ruleLiteral->getId();
$rule->next2 = (isset($this->watches[$ruleLiteral->getId()])) ? $this->watches[$ruleLiteral->getId()] : null ;
}
$this->watches[$ruleLiteral->getId()] = $rule;

View File

@ -139,7 +139,7 @@ class SolverTest extends \PHPUnit_Framework_TestCase
$this->checkSolverResult(array());
}
public function testSolverFull()
public function testSolverAllJobs()
{
$this->repoInstalled->addPackage($packageD = new MemoryPackage('D', '1.0'));
$this->repoInstalled->addPackage($oldPackageC = new MemoryPackage('C', '1.0'));
@ -165,6 +165,25 @@ class SolverTest extends \PHPUnit_Framework_TestCase
));
}
public function testSolverThreeAlternativeRequireAndConflict()
{
$this->repo->addPackage($packageA = new MemoryPackage('A', '2.0'));
$this->repo->addPackage($middlePackageB = new MemoryPackage('B', '1.0'));
$this->repo->addPackage($newPackageB = new MemoryPackage('B', '1.1'));
$this->repo->addPackage($oldPackageB = new MemoryPackage('B', '0.9'));
$packageA->setRequires(array(new Link('A', 'B', new VersionConstraint('<', '1.1'), 'requires')));
$packageA->setConflicts(array(new Link('A', 'B', new VersionConstraint('<', '1.0'), 'conflicts')));
$this->reposComplete();
$this->request->install('A');
$this->checkSolverResult(array(
array('job' => 'install', 'package' => $middlePackageB),
array('job' => 'install', 'package' => $packageA),
));
}
public function testInstallOneOfTwoAlternatives()
{
$this->repo->addPackage($packageA = new MemoryPackage('A', '1.0'));