Skip to content

Commit

Permalink
more test coverage
Browse files Browse the repository at this point in the history
git-svn-id: file:///Volumes/JJT 4GB/Apps/svn_repo/Algorithm-TravelingSalesman-BitonicTour/trunk@106 5bda1b4c-df04-11dc-9541-bd5b2d3e4f05
  • Loading branch information
johnt committed Apr 18, 2008
1 parent c576131 commit e5a9aee
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/Algorithm/TravelingSalesman/BitonicTour.pm
Expand Up @@ -281,7 +281,7 @@ sub solve {
croak "FAIL: you need to add some points!";
}
elsif ($self->N == 1) {
$length = 0;
($length, @points) = (0, 0);
}
else {
($length, @points) = $self->optimal_full_tour;
Expand Down Expand Up @@ -448,9 +448,12 @@ sub tour_cost {
unless $_[0] > 0;
$self->tour($i,$j)->{cost} = $_[0];
}
croak "Don't know the cost of tour($i,$j)"
unless exists $self->tour($i,$j)->{cost};
return $self->tour($i,$j)->{cost};
if (exists $self->tour($i,$j)->{cost}) {
return $self->tour($i,$j)->{cost};
}
else {
croak "Don't know the cost of tour($i,$j)";
}
}

=head2 $b->tour_points($i,$j, [@points])
Expand All @@ -470,9 +473,12 @@ sub tour_points {
unless $j == $_[-1];
$self->tour($i,$j)->{points} = [ @_ ];
}
croak "Don't know the points for tour($i,$j)"
unless exists $self->tour($i,$j)->{points};
return @{ $self->tour($i,$j)->{points} };
if (exists $self->tour($i,$j)->{points}) {
return @{ $self->tour($i,$j)->{points} };
}
else {
croak "Don't know the points for tour($i,$j)";
}
}

=head2 $b->delta($n1,$n2);
Expand Down

0 comments on commit e5a9aee

Please sign in to comment.