-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix missing coverage with Moose accessors.
Moose accessors on the LHS of logops were missing coverage. This was due to the artificial Moose generated filename not matching the filenames for which coverage should be collected. When this occurred on the LHS of a logop the flag showing whether we were collecting coverage was still false and so covlerage of the logop was missed. The solution is to look inside the artificially generated filename for the real filename. Note that this solution is specific to Moose. Add a test for this too.
- Loading branch information
Showing
6 changed files
with
297 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
Reading database from ... | ||
|
||
|
||
------------------------------------------ ------ ------ ------ ------ ------ | ||
File stmt bran cond sub total | ||
------------------------------------------ ------ ------ ------ ------ ------ | ||
tests/moose_cond 100.0 n/a 75.0 100.0 96.2 | ||
Total 100.0 n/a 75.0 100.0 96.2 | ||
------------------------------------------ ------ ------ ------ ------ ------ | ||
|
||
|
||
Run: ... | ||
Perl version: ... | ||
OS: ... | ||
Start: ... | ||
Finish: ... | ||
|
||
tests/moose_cond | ||
|
||
line err stmt bran cond sub code | ||
1 #!/usr/bin/perl | ||
2 | ||
3 # Copyright 2011-2012, Paul Johnson (paul@pjcj.net) | ||
4 | ||
5 # This software is free. It is licensed under the same terms as Perl itself. | ||
6 | ||
7 # The latest version of this software should be available from my homepage: | ||
8 # http://www.pjcj.net | ||
9 | ||
10 # __COVER__ skip_test $] < 5.010 || !(eval "use Moose; 23") | ||
11 # __COVER__ skip_reason Moose not available or unreliable with Devel::Cover | ||
12 | ||
13 1 1 use strict; | ||
1 | ||
1 | ||
14 1 1 use warnings; | ||
1 | ||
1 | ||
15 | ||
16 package Cover_branch_bug; | ||
17 | ||
18 1 1 use Moose; | ||
1 | ||
1 | ||
19 1 has meep => ( isa => 'HashRef', is => 'rw' ); | ||
20 | ||
21 1 my $self = __PACKAGE__->new; | ||
22 | ||
23 1 $self->meep( { marp => 0 } ); | ||
24 1 print "meep contains " . $self->wagh . "\n"; | ||
25 | ||
26 1 $self->meep( { marp => 1 } ); | ||
27 1 print "meep contains " . $self->wagh . "\n"; | ||
28 | ||
29 sub wagh { | ||
30 2 2 my ( $self ) = @_; | ||
31 *** 2 50 my $x = $self || 0; | ||
32 2 100 return $self->meep->{marp} || 0; | ||
33 # return $self || 0; | ||
34 } | ||
|
||
|
||
Conditions | ||
---------- | ||
|
||
or 2 conditions | ||
|
||
line err % l !l expr | ||
----- --- ------ ------ ------ ---- | ||
31 *** 50 2 0 $self || 0 | ||
32 100 1 1 $self->meep->{'marp'} || 0 | ||
|
||
|
||
Covered Subroutines | ||
------------------- | ||
|
||
Subroutine Count Location | ||
---------- ----- ------------------- | ||
BEGIN 1 tests/moose_cond:13 | ||
BEGIN 1 tests/moose_cond:14 | ||
BEGIN 1 tests/moose_cond:18 | ||
wagh 2 tests/moose_cond:30 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
Devel::Cover: Can't find digest for accessor meep defined at /home/pjcj/g/perl/Devel--Cover/tests/moose_cond | ||
Reading database from ... | ||
|
||
|
||
------------------------------------------ ------ ------ ------ ------ ------ | ||
File stmt bran cond sub total | ||
------------------------------------------ ------ ------ ------ ------ ------ | ||
tests/moose_cond 100.0 n/a 75.0 100.0 96.2 | ||
Total 100.0 n/a 75.0 100.0 96.2 | ||
------------------------------------------ ------ ------ ------ ------ ------ | ||
|
||
|
||
Run: ... | ||
Perl version: ... | ||
OS: ... | ||
Start: ... | ||
Finish: ... | ||
|
||
tests/moose_cond | ||
|
||
line err stmt bran cond sub code | ||
1 #!/usr/bin/perl | ||
2 | ||
3 # Copyright 2011-2012, Paul Johnson (paul@pjcj.net) | ||
4 | ||
5 # This software is free. It is licensed under the same terms as Perl itself. | ||
6 | ||
7 # The latest version of this software should be available from my homepage: | ||
8 # http://www.pjcj.net | ||
9 | ||
10 # __COVER__ skip_test $] < 5.010 || !(eval "use Moose; 23") | ||
11 # __COVER__ skip_reason Moose not available or unreliable with Devel::Cover | ||
12 | ||
13 1 1 use strict; | ||
1 | ||
1 | ||
14 1 1 use warnings; | ||
1 | ||
1 | ||
15 | ||
16 package Cover_branch_bug; | ||
17 | ||
18 1 1 use Moose; | ||
1 | ||
1 | ||
19 1 has meep => ( isa => 'HashRef', is => 'rw' ); | ||
20 | ||
21 1 my $self = __PACKAGE__->new; | ||
22 | ||
23 1 $self->meep( { marp => 0 } ); | ||
24 1 print "meep contains " . $self->wagh . "\n"; | ||
25 | ||
26 1 $self->meep( { marp => 1 } ); | ||
27 1 print "meep contains " . $self->wagh . "\n"; | ||
28 | ||
29 sub wagh { | ||
30 2 2 my ( $self ) = @_; | ||
31 *** 2 50 my $x = $self || 0; | ||
32 2 100 return $self->meep->{marp} || 0; | ||
33 # return $self || 0; | ||
34 } | ||
|
||
|
||
Conditions | ||
---------- | ||
|
||
or 2 conditions | ||
|
||
line err % l !l expr | ||
----- --- ------ ------ ------ ---- | ||
31 *** 50 2 0 $self || 0 | ||
32 100 1 1 $self->meep->{'marp'} || 0 | ||
|
||
|
||
Covered Subroutines | ||
------------------- | ||
|
||
Subroutine Count Location | ||
---------- ----- ------------------- | ||
BEGIN 1 tests/moose_cond:13 | ||
BEGIN 1 tests/moose_cond:14 | ||
BEGIN 1 tests/moose_cond:18 | ||
wagh 2 tests/moose_cond:30 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
Reading database from ... | ||
|
||
|
||
------------------------------------------ ------ ------ ------ ------ ------ | ||
File stmt bran cond sub total | ||
------------------------------------------ ------ ------ ------ ------ ------ | ||
tests/moose_cond 100.0 n/a 75.0 100.0 96.2 | ||
Total 100.0 n/a 75.0 100.0 96.2 | ||
------------------------------------------ ------ ------ ------ ------ ------ | ||
|
||
|
||
Run: ... | ||
Perl version: ... | ||
OS: ... | ||
Start: ... | ||
Finish: ... | ||
|
||
tests/moose_cond | ||
|
||
line err stmt bran cond sub code | ||
1 #!/usr/bin/perl | ||
2 | ||
3 # Copyright 2011-2012, Paul Johnson (paul@pjcj.net) | ||
4 | ||
5 # This software is free. It is licensed under the same terms as Perl itself. | ||
6 | ||
7 # The latest version of this software should be available from my homepage: | ||
8 # http://www.pjcj.net | ||
9 | ||
10 # __COVER__ skip_test $] < 5.010 || !(eval "use Moose; 23") | ||
11 # __COVER__ skip_reason Moose not available or unreliable with Devel::Cover | ||
12 | ||
13 1 1 use strict; | ||
1 | ||
1 | ||
14 1 1 use warnings; | ||
1 | ||
1 | ||
15 | ||
16 package Cover_branch_bug; | ||
17 | ||
18 1 1 use Moose; | ||
1 | ||
1 | ||
19 1 has meep => ( isa => 'HashRef', is => 'rw' ); | ||
20 | ||
21 1 my $self = __PACKAGE__->new; | ||
22 | ||
23 1 $self->meep( { marp => 0 } ); | ||
24 1 print "meep contains " . $self->wagh . "\n"; | ||
25 | ||
26 1 $self->meep( { marp => 1 } ); | ||
27 1 print "meep contains " . $self->wagh . "\n"; | ||
28 | ||
29 sub wagh { | ||
30 2 2 my ( $self ) = @_; | ||
31 *** 2 50 my $x = $self || 0; | ||
32 2 100 return $self->meep->{marp} || 0; | ||
33 # return $self || 0; | ||
34 } | ||
|
||
|
||
Conditions | ||
---------- | ||
|
||
or 2 conditions | ||
|
||
line err % l !l expr | ||
----- --- ------ ------ ------ ---- | ||
31 *** 50 2 0 $self || 0 | ||
32 100 1 1 $self->meep->{'marp'} || 0 | ||
|
||
|
||
Covered Subroutines | ||
------------------- | ||
|
||
Subroutine Count Location | ||
---------- ----- ------------------- | ||
BEGIN 1 tests/moose_cond:13 | ||
BEGIN 1 tests/moose_cond:14 | ||
BEGIN 1 tests/moose_cond:18 | ||
wagh 2 tests/moose_cond:30 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/perl | ||
|
||
# Copyright 2011-2012, Paul Johnson (paul@pjcj.net) | ||
|
||
# This software is free. It is licensed under the same terms as Perl itself. | ||
|
||
# The latest version of this software should be available from my homepage: | ||
# http://www.pjcj.net | ||
|
||
# __COVER__ skip_test $] < 5.010 || !(eval "use Moose; 23") | ||
# __COVER__ skip_reason Moose not available or unreliable with Devel::Cover | ||
|
||
use strict; | ||
use warnings; | ||
|
||
package Cover_branch_bug; | ||
|
||
use Moose; | ||
has meep => ( isa => 'HashRef', is => 'rw' ); | ||
|
||
my $self = __PACKAGE__->new; | ||
|
||
$self->meep( { marp => 0 } ); | ||
print "meep contains " . $self->wagh . "\n"; | ||
|
||
$self->meep( { marp => 1 } ); | ||
print "meep contains " . $self->wagh . "\n"; | ||
|
||
sub wagh { | ||
my ( $self ) = @_; | ||
my $x = $self || 0; | ||
return $self->meep->{marp} || 0; | ||
# return $self || 0; | ||
} |