Moose Can't get a break

Its start the long releases cycle here at the Moose-Pen

Today I am going to examine some of the results I got from my 'Devel::Cover' run.


ffile stmt bran cond sub pod time total
lib/Database/Accessor.pm 94.4 80.0 88.8 93.7 0.0 23.5 91.7

To start I can basically ignore the 'stmt' section as it is very rare to get 100% in there as I am running at '94.4' I will move onto something else.

The next col branch has 80% and following that link I get


line % coverage branch
94 50 T F if $self->gather
110 0 T F unless (defined $_->name)
494 0 T F if $self->dynamic_gather
615 50 T F if $self->no_create
626 50 T F if $self->no_update
640 50 T F if $self->no_retrieve

After I remove the ones that are getting 100% coverage. Now what branch is doing here is looking to see how far down the tree so you have all the If else parts of a statement covered;

The first fail is


sub gather_count{
my $self = shift;
return 1
if $self->gather();

}

and it is failing because there is no fall though; I think that this;

sub gather_count{
my $self = shift;
if ($self->gather()){
return 1;
}
else {
return 0;
}
}

Might do the trick. Though I am surprised that it doesn't like the first way I do the 'if' as it is a perfectly cromulent code. I will try that first and see what I get;

After the next run I still get only 50%


line % coverage branch
94 50 T F if $self->gather

Not 100% sure why that is?? Looking at some of the ones that pass I think I will try this

sub gather_count{
my $self = shift;
if ($self->gather()){
return 1;
}
elsif (!$self->gather()){
return 0;
}
}

somehow that made it worse

line % coverage branch
94 50 T F if ($self->gather) { }
50 T F elsif (not $self->gather) { }

Now this is odd because later on in my code this block;

push(@items,(@{ $self->gather->conditions }, @{ $self->gather->elements }))
if ( $self->gather());

gets 100%. Perhaps it is the way I am doing the return;

sub gather_count{
my $self = shift;
my $ return = 0;
if ($self->gather()){
$ return = 1;
}
return $return;
}

and that just got me back to 50% so I must be missing something here??

Maybe it wants something like this


sub gather_count{
my $self = shift;
return 1
if (ref($self->gather()) eq 'Database::Accessor::Gather');

}

again the same??

Ok how about one more try tonight


sub gather_count{
my $self = shift;

if (ref($self->gather()) eq 'Database::Accessor::Gather'){

return 1;
}
else {

return 0;
}
}

Same again. I guess I will have to do some more reading before I go any further.
maxresdefault2.jpg

Leave a comment

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations