Commit f0d6900e authored by Matthieu Muffato's avatar Matthieu Muffato
Browse files

Use "eq" to compare elements in Collection

parent 0f8f0a8a
......@@ -63,7 +63,7 @@ sub present {
my $candidate = shift @_;
foreach my $element (@{ $self->listref }) {
return 1 if($element == $candidate);
return 1 if($element eq $candidate);
}
return 0;
}
......@@ -93,7 +93,7 @@ sub forget {
my $listref = $self->listref;
for(my $i=scalar(@$listref)-1;$i>=0;$i--) {
if($listref->[$i] == $candidate) {
if($listref->[$i] eq $candidate) {
splice @$listref, $i, 1;
}
}
......
......@@ -43,6 +43,15 @@ foreach my $member(qw{quick brown fox}) {
is(@ref, 1, 'no addition as it was a copy');
}
ok($collection->present('fox'), 'present() - There is a fox');
ok(!$collection->present('chickens'), '!present() - The fox is unlucky');
$collection->add_once('fox');
is(@$ref, $i, 'Same size - there can be only 1 fox');
$collection->forget('fox');
is(@$ref, --$i, 'one less element - the fox is gone: we\'re safe !');
$collection = Bio::EnsEMBL::Hive::Utils::Collection->new([{ foo => undef}]);
$collection->add({ foo => undef });
$collection->add({ bar => 'foobar' });
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment