From: Matt S Trout Date: Sun, 9 Feb 2014 19:20:55 +0000 (+0000) Subject: factor action execution out into solver method X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e7117efc279502d901d5058abd17110ffb1554b7;p=scpubgit%2FDKit.git factor action execution out into solver method --- diff --git a/lib/DX/Solver.pm b/lib/DX/Solver.pm index e94e050..2042a10 100644 --- a/lib/DX/Solver.pm +++ b/lib/DX/Solver.pm @@ -36,4 +36,12 @@ sub query { ); } +sub run_action { + my ($self, $action) = @_; + my @invalidate = $action->run; + while (my ($type, $value) = splice @invalidate, 0, 2) { + $self->facts->{$type}->remove_value($value); + } +} + 1; diff --git a/t/dot_ssh.t b/t/dot_ssh.t index 1c752a7..2e37b31 100644 --- a/t/dot_ssh.t +++ b/t/dot_ssh.t @@ -262,9 +262,7 @@ is( scalar(my ($action) = $res[0]->actions), 1 ); -my ($type, $value) = $action->run; - -$solver->facts->{$type}->remove_value($value); +$solver->run_action($action); ok(!$path_status{'.ssh'}, 'Empty retracted'); @@ -343,9 +341,7 @@ is(scalar(my @act = $res[0]->actions), 2, 'Two actions'); is(scalar(my ($poss) = grep !@{$_->dependencies}, @act), 1, 'One possible'); -($type, $value) = $poss->run; - -$solver->facts->{$type}->remove_value($value); +$solver->run_action($poss); @res = keys_file()->results; @@ -356,9 +352,7 @@ is( 'One possible' ); -($type, $value) = $poss->run; - -$solver->facts->{$type}->remove_value($value); +$solver->run_action($poss); @res = keys_file()->results;