Created
November 29, 2011 17:52
-
-
Save rwstauner/1405707 to your computer and use it in GitHub Desktop.
Devel::Cover 0% branch coverage for externally defined methods
This file contains hidden or 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
package accessor_maker; | |
sub import { | |
no strict 'refs'; | |
*{ caller() . '::' . 'foo' } = sub { $_[0]->{ 'foo' } }; | |
} | |
1; |
This file contains hidden or 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
*$ perl -MDevel::Cover=-ignore,accessor_maker.pm whole.pl | |
Devel::Cover 0.79: Collecting coverage data for branch, condition, pod, statement, subroutine and time. | |
Selecting packages matching: | |
Ignoring packages matching: | |
accessor_maker.pm | |
Ignoring packages in: | |
. | |
/home/rando/perl5/perlbrew/perls/5.14.2-st/lib/5.14.2 | |
/home/rando/perl5/perlbrew/perls/5.14.2-st/lib/5.14.2/x86_64-linux-thread-multi | |
/home/rando/perl5/perlbrew/perls/5.14.2-st/lib/site_perl/5.14.2 | |
/home/rando/perl5/perlbrew/perls/5.14.2-st/lib/site_perl/5.14.2/x86_64-linux-thread-multi | |
/tmp/CPAN-Reporter-lib-d8a6 | |
undefined | |
undefined | |
defined | |
defined | |
Devel::Cover: Writing coverage database to /tmp/cover/cover_db/runs/1322588867.10128.41268 | |
---------------------------- ------ ------ ------ ------ ------ ------ ------ | |
File stmt bran cond sub pod time total | |
---------------------------- ------ ------ ------ ------ ------ ------ ------ | |
t/whole.pl 100.0 50.0 n/a 100.0 n/a 100.0 90.0 | |
Total 100.0 50.0 n/a 100.0 n/a 100.0 90.0 | |
---------------------------- ------ ------ ------ ------ ------ ------ ------ |
This file contains hidden or 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
package cm3; | |
sub new { bless $_[1], $_[0] } | |
# comment/uncomment one or the other: | |
use accessor_maker; | |
#sub foo { $_[0]->{ 'foo' } } | |
package main; | |
sub test { | |
my $self = shift; | |
print 'un' unless defined $self->foo; | |
print "defined\n"; | |
my $foo = $self->foo; | |
print 'un' unless defined $foo; | |
print "defined\n"; | |
} | |
test( cm3->new({}) ); | |
test( cm3->new({foo => 1}) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment