Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Devel-Cover CPAN distribution.

Report information
The Basics
Id: 4342
Status: resolved
Priority: 0/
Queue: Devel-Cover

People
Owner: Nobody in particular
Requestors: sjs [...] khadrin.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.26
Fixed in: 0.29



Subject: "return" in a branch messes up branch coverage sometimes
Download (untitled) / with headers
text/plain 1.8k
I am using Devel-Cover 0.26. A program that demonstrates the issue follows: [sjs@cobra foo]$ cat foo.pl #!/usr/bin/perl use strict; use warnings; is_3digits1(1234); is_3digits1(123); is_3digits2(1234); is_3digits2(123); is_3digits3(1234); is_3digits3(123); exit; sub is_3digits1 { my $val = shift; if ($val =~ /^\d{3}$/) { return 1; } else { return; } } sub is_3digits2 { my $val = shift; my $retval = undef; $retval=1 if $val =~ /^\d{3}$/; return $retval; } sub is_3digits3 { my $val = shift; return 1 if $val =~ /^\d{3}$/; return; } [sjs@cobra foo]$ Run the program under Devel::Cover with "perl -MDevel::Cover foo.pl". The relevant results from the coverage report are: Branches -------- line err % true false branch ----- --- ------ ------ ------ ------ 19 100 1 1 if ($val =~ /^\d{3}$/) { } 30 100 1 1 if $val =~ /^\d{3}$/ 36 *** 50 1 0 if $val =~ /^\d{3}$/ I expected 100% coverage in all three subroutines.
From: Earle Martin <EMARTIN [...] cpan.org>
I can confirm that this bug still exists in 0.28; I get 100% and 50% respectively for the two following nearly-identical bits of code. From Locale::Object::Country: sub languages { my $self = shift; # No name, no languages. return unless $self->{_name}; # Check for countries attribute. Set it if we don't have it. _set_languages($self) unless $self->{_languages}; # Give an array if requested in array context, otherwise a reference. if (wantarray) { return @{$self->{_languages}}; } else { return $self->{_languages}; } } From Locale::Object::Continent: sub countries { my $self = shift; # No name, no countries. return unless $self->{_name}; # Check for countries attribute. Set it if we don't have it. _set_countries($self) unless $self->{_countries}; # Give an array if requested in array context, otherwise a reference. if (wantarray) { return @{$self->{_countries}}; } else { return $self->{_countries}; } }


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.