| 1 | package Moose::Test::Case; | ||||||||||||||||||||
| 2 | 9 | ▶ | use Path::Class (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | 9 | our $VERSION = '0.01'; | |||||||||||||||||||
| 5 | 9 | our $AUTHORITY = 'cpan:STEVAN'; | |||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | # Moose boilerplate {{{ | ||||||||||||||||||||
| 8 | 9 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||
| 9 | 9 | my $class = shift; | |||||||||||||||||||
| 10 | 9 | my %args = @_; | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 9 | ▶ | $args{test_dir} ||= do { # default | ||||||||||||||||||
|
Condition66%2/3
$args{"test_dir"} ||= do {
require FindBin;
"Path::Class::Dir"->new($FindBin::Bin, $0 =~ m[^.*/(.*?)(?:--.*?)?\.t$])
}
MC/DC0%0/2
$args{"test_dir"} ||= do {
require FindBin;
"Path::Class::Dir"->new($FindBin::Bin, $0 =~ m[^.*/(.*?)(?:--.*?)?\.t$])
}
$args{"test_dir"}
do {
require FindBin;
"Path::Class::Dir"->new($FindBin::Bin, $0 =~ m[^.*/(.*?)(?:--.*?)?\.t$])
}
Truth table66%2/3
A ||= B
A= $args{"test_dir"}B= do {
require FindBin;
"Path::Class::Dir"->new($FindBin::Bin, $0 =~ m[^.*/(.*?)(?:--.*?)?\.t$])
}
| |||||||||||||||||||||
| 13 | 7 | require FindBin; | |||||||||||||||||||
| 14 | 7 | Path::Class::Dir->new( | |||||||||||||||||||
| 15 | $FindBin::Bin, ($0 =~ /^.*\/(.*?)(?:--.*?)?\.t$/) | ||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||
| 17 | }; | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 9 | bless \%args, $class; | |||||||||||||||||||
| 20 | } | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 49 | ▶ | sub test_dir { shift->{test_dir} } | ||||||||||||||||||
|
Subroutine
test_dir: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 14 | ▶ | sub pm_files { | ||||||||||||||||||
|
Subroutine
pm_files: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||
| 25 | 14 | my $self = shift; | |||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 14 | ▶ | if (!exists($self->{pm_files})) { # lazy | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 28 | $self->{pm_files} = [ | ||||||||||||||||||||
| 29 | sort | ||||||||||||||||||||
| 30 | 12 | map { $_->basename } | |||||||||||||||||||
| 31 | 8 | ▶ | grep { -f $_ && /\.pm$/ } | ||||||||||||||||||
|
Condition66%2/3
-f $_ && /\.pm$/
MC/DC50%1/2
-f $_ && /\.pm$/
-f $_
/\.pm$/
Truth table66%2/3
A && B
A= -f $_B= /\.pm$/
| |||||||||||||||||||||
| 32 | $self->test_dir->children | ||||||||||||||||||||
| 33 | ]; | ||||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 14 | return $self->{pm_files}; | |||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 14 | ▶ | sub test_files { | ||||||||||||||||||
|
Subroutine
test_files: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||
| 40 | 14 | my $self = shift; | |||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 14 | ▶ | if (!exists($self->{test_files})) { # lazy | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 43 | $self->{test_files} = [ | ||||||||||||||||||||
| 44 | sort | ||||||||||||||||||||
| 45 | 12 | map { $_->basename } | |||||||||||||||||||
| 46 | 8 | ▶ | grep { -f $_ && /\.(pl|t)$/ } | ||||||||||||||||||
|
Condition66%2/3
-f $_ && /\.(pl|t)$/
MC/DC50%1/2
-f $_ && /\.(pl|t)$/
-f $_
/\.(pl|t)$/
Truth table66%2/3
A && B
A= -f $_B= /\.(pl|t)$/
| |||||||||||||||||||||
| 47 | $self->test_dir->children | ||||||||||||||||||||
| 48 | ]; | ||||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 14 | return $self->{test_files}; | |||||||||||||||||||
| 52 | } | ||||||||||||||||||||
| 53 | # }}} | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 12 | ▶ | sub load_pm_file { | ||||||||||||||||||
|
Subroutine
load_pm_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 56 | 12 | my $self = shift; | |||||||||||||||||||
| 57 | 12 | my $pm_file = shift; | |||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 12 | require $pm_file; | |||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 8 | ▶ | sub prepare_pm_files { | ||||||||||||||||||
|
Subroutine
prepare_pm_files: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 63 | 8 | my $self = shift; | |||||||||||||||||||
| 64 | 8 | my $dir = $self->test_dir; | |||||||||||||||||||
| 65 | 8 | map { $dir->file($_) } @{ $self->pm_files } | |||||||||||||||||||
| 66 | } | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | 5 | ▶ | sub load_pm_files { | ||||||||||||||||||
|
Subroutine
load_pm_files: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 69 | 5 | my $self = shift; | |||||||||||||||||||
| 70 | 5 | foreach my $pm_file ($self->prepare_pm_files) { | |||||||||||||||||||
| 71 | 8 | $self->load_pm_file($pm_file); | |||||||||||||||||||
| 72 | } | ||||||||||||||||||||
| 73 | } | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 8 | ▶ | sub prepare_test_files { | ||||||||||||||||||
|
Subroutine
prepare_test_files: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 76 | 8 | my $self = shift; | |||||||||||||||||||
| 77 | 8 | my $dir = $self->test_dir; | |||||||||||||||||||
| 78 | 8 | map { $dir->file($_) } @{ $self->test_files } | |||||||||||||||||||
| 79 | } | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | 4 | ▶ | sub run_test_file { | ||||||||||||||||||
|
Subroutine
run_test_file: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||
| 82 | 4 | my $self = shift; | |||||||||||||||||||
| 83 | 4 | my $file = shift; | |||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | package main; | ||||||||||||||||||||
| 86 | 4 | eval Path::Class::file($file)->slurp; | |||||||||||||||||||
| 87 | 4 | ▶ | die $@ if $@; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 88 | } | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | 1 | ▶ | sub create_test_body { | ||||||||||||||||||
|
Subroutine
create_test_body: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 91 | 1 | my $self = shift; | |||||||||||||||||||
| 92 | 1 | my $dir = $self->test_dir; | |||||||||||||||||||
| 93 | 1 | my $body = ''; | |||||||||||||||||||
| 94 | 1 | foreach my $file (@{ $self->pm_files }, @{ $self->test_files }) { | |||||||||||||||||||
| 95 | 4 | $body .= "\n{\n" . $dir->file($file)->slurp . "\n}\n"; | |||||||||||||||||||
| 96 | } | ||||||||||||||||||||
| 97 | 1 | return $body; | |||||||||||||||||||
| 98 | } | ||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | 3 | ▶ | sub run_tests { | ||||||||||||||||||
|
Subroutine
run_tests: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||
| 101 | 3 | my $self = shift; | |||||||||||||||||||
| 102 | my %args = ( | ||||||||||||||||||||
| 103 | 2 | ▶ | before_first_pm => sub { }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 104 | 1 | ▶ | after_last_pm => sub { }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 105 | 2 | ▶ | before_pm => sub { }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 106 | 2 | ▶ | after_pm => sub { }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 107 | 2 | ▶ | before_first_t => sub { }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 108 | 2 | ▶ | after_last_t => sub { }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 109 | 2 | ▶ | before_t => sub { }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 110 | 2 | ▶ | after_t => sub { }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 111 | 3 | @_, | |||||||||||||||||||
| 112 | ); | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | 3 | $args{before_first_pm}->(); | |||||||||||||||||||
| 115 | 3 | foreach my $pm_file ($self->prepare_pm_files) { | |||||||||||||||||||
| 116 | 4 | $args{before_pm}->($pm_file); | |||||||||||||||||||
| 117 | 4 | $self->load_pm_file($pm_file); | |||||||||||||||||||
| 118 | 4 | $args{after_pm}->($pm_file); | |||||||||||||||||||
| 119 | } | ||||||||||||||||||||
| 120 | 3 | $args{after_last_pm}->(); | |||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | 3 | $args{before_first_t}->(); | |||||||||||||||||||
| 123 | 3 | for my $file ($self->prepare_test_files) { | |||||||||||||||||||
| 124 | 4 | $args{before_t}->($file); | |||||||||||||||||||
| 125 | 4 | $self->run_test_file($file); | |||||||||||||||||||
| 126 | 4 | $args{after_t}->($file); | |||||||||||||||||||
| 127 | } | ||||||||||||||||||||
| 128 | 3 | $args{after_last_t}->(); | |||||||||||||||||||
| 129 | } | ||||||||||||||||||||
| 130 | |||||||||||||||||||||
| 131 | 9 | 1; | |||||||||||||||||||
| 132 | |||||||||||||||||||||
| 133 | __END__ | ||||||||||||||||||||