| blib/lib/Devel/Loading.pm | |||
|---|---|---|---|
| Criterion | Covered | Total | % |
| statement | 9 | 13 | 69.2 |
| branch | 1 | 2 | 50.0 |
| condition | n/a | ||
| subroutine | 2 | 3 | 66.6 |
| pod | n/a | ||
| total | 12 | 18 | 66.6 |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | package Devel::Loading; | ||||||
| 2 | our $VERSION = '0.01'; | ||||||
| 3 | |||||||
| 4 | |||||||
| 5 | sub import { | ||||||
| 6 | 1 | 1 | 9 | my $class = shift; | |||
| 7 | 1 | 2 | my $code = shift; | ||||
| 8 | |||||||
| 9 | 1 | 50 | 5 | if ($code) { | |||
| 10 | 1 | 2 | my $old_code = $code; | ||||
| 11 | $code = sub { | ||||||
| 12 | 9 | 9 | 149124 | local $_ = $_[1]; | |||
| 13 | 9 | 32 | $old_code->($_[1]); | ||||
| 14 | 9 | 22313 | return undef; | ||||
| 15 | 1 | 4 | }; | ||||
| 16 | } | ||||||
| 17 | else { | ||||||
| 18 | $code = sub { | ||||||
| 19 | 0 | 0 | 0 | my @caller = caller; | |||
| 20 | 0 | 0 | warn "Loading $_[1] at $caller[1] line $caller[2].\n"; | ||||
| 21 | 0 | 0 | return undef; | ||||
| 22 | 0 | 0 | }; | ||||
| 23 | } | ||||||
| 24 | |||||||
| 25 | 1 | 30 | unshift @INC, $code; | ||||
| 26 | } | ||||||
| 27 | |||||||
| 28 | 1; | ||||||
| 29 | |||||||
| 30 | __END__ |