File Coverage

blib/lib/Test/Inline/Content/Default.pm
Criterion Covered Total %
statement 18 18 100.0
branch 5 8 62.5
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 28 31 90.3


line stmt bran cond sub pod time code
1             package Test::Inline::Content::Default;
2             # ABSTRACT: est::Inline 2 fallback/default Content Handler
3              
4             #pod =pod
5             #pod
6             #pod =head1 DESCRIPTION
7             #pod
8             #pod This class implements the default generator for script content. It generates
9             #pod test script content inteded for use in a standard CPAN dist.
10             #pod
11             #pod This module contains no user servicable parts.
12             #pod
13             #pod =cut
14              
15 12     12   1034 use strict;
  12         24  
  12         414  
16 12     12   63 use Params::Util qw{_INSTANCE};
  12         24  
  12         484  
17 12     12   69 use Test::Inline::Content ();
  12         21  
  12         2203  
18              
19             our $VERSION = '2.214';
20             our @ISA = 'Test::Inline::Content';
21              
22             sub process {
23 16     16 1 519 my $self = shift;
24 16 50       123 my $Inline = _INSTANCE(shift, 'Test::Inline') or return undef;
25 16 50       115 my $Script = _INSTANCE(shift, 'Test::Inline::Script') or return undef;
26              
27             # Get the merged content
28 16         59 my $content = $Script->merged_content;
29 16 50       47 return undef unless defined $content;
30              
31             # Determine a plan
32 16         44 my $tests = $Script->tests;
33 16 100       64 my $plan = defined $tests
34             ? "tests => $tests"
35             : "'no_plan'";
36              
37             # Wrap the merged contents with the rest of the test
38             # file infrastructure.
39 16         48 my $file = <<"END_TEST";
40             #!/usr/bin/perl -w
41              
42             use strict;
43             use Test::More $plan;
44             \$| = 1;
45              
46              
47              
48             $content
49              
50              
51              
52             1;
53             END_TEST
54              
55 16         42 $file;
56             }
57              
58             1;
59              
60             __END__