line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoX::CustomTemplateFileParser::Plugin::To::Test; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5313
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
5
|
1
|
|
|
1
|
|
15
|
use 5.10.1; |
|
1
|
|
|
|
|
3
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.1002'; # VERSION |
8
|
|
|
|
|
|
|
# ABSTRACT: Create tests |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use Moose::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub to_test { |
13
|
1
|
|
|
1
|
1
|
10675
|
my $self = shift; |
14
|
1
|
|
|
|
|
9
|
my $baseurl = $self->_get_baseurl; |
15
|
1
|
|
|
|
|
5
|
my $filename = $self->_get_filename; |
16
|
|
|
|
|
|
|
|
17
|
1
|
50
|
|
|
|
39
|
if(!scalar keys %{ $self->structure }) { |
|
1
|
|
|
|
|
48
|
|
18
|
0
|
|
|
|
|
0
|
$self->parse; |
19
|
|
|
|
|
|
|
} |
20
|
1
|
|
|
|
|
44
|
my $info = $self->structure; |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
3
|
my @parsed = join "\n" => @{ $info->{'head_lines'} }; |
|
1
|
|
|
|
|
5
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
TEST: |
25
|
1
|
|
|
|
|
3
|
foreach my $test (@{ $info->{'tests'} }) { |
|
1
|
|
|
|
|
4
|
|
26
|
3
|
50
|
|
|
|
5
|
next TEST if !scalar @{ $test->{'lines_template'} }; |
|
3
|
|
|
|
|
11
|
|
27
|
|
|
|
|
|
|
|
28
|
3
|
100
|
|
|
|
20
|
my $expected_var = sprintf '$expected_%s%s' => $test->{'test_name'}, ($test->{'loop_variable'} ? "_$test->{'loop_variable'}" : ''); |
29
|
|
|
|
|
|
|
|
30
|
3
|
100
|
|
|
|
17
|
push @parsed => "\n#** test from $filename, line $test->{'test_start_line'}" . ($test->{'loop_variable'} ? ", loop: $test->{'loop_variable'}" : ''); |
31
|
3
|
|
|
|
|
4
|
push @parsed => sprintf 'my %s = qq{%s};' => $expected_var, join "\n" => @{ $test->{'lines_expected'} }; |
|
3
|
|
|
|
|
33
|
|
32
|
|
|
|
|
|
|
|
33
|
3
|
|
|
|
|
10
|
push @parsed => sprintf q{get '/%s' => '%s';} => $test->{'test_name'}, $test->{'test_name'}; |
34
|
|
|
|
|
|
|
push @parsed => sprintf q{$test->get_ok('/%s')->status_is(200)->trimmed_content_is(%s, '%s');} |
35
|
|
|
|
|
|
|
=> $test->{'test_name'}, $expected_var, sprintf qq{Matched trimmed content in $filename, line $test->{'test_start_line'}%s} |
36
|
3
|
100
|
|
|
|
22
|
=> $test->{'loop_variable'} ? ", loop: $test->{'loop_variable'}" : ''; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
3
|
push @parsed => 'done_testing();'; |
40
|
1
|
|
|
|
|
2
|
push @parsed => '__DATA__'; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
2
|
foreach my $test (@{ $info->{'tests'} }) { |
|
1
|
|
|
|
|
2
|
|
44
|
3
|
50
|
|
|
|
4
|
next TEST if !scalar @{ $test->{'lines_template'} }; |
|
3
|
|
|
|
|
9
|
|
45
|
|
|
|
|
|
|
|
46
|
3
|
|
|
|
|
8
|
push @parsed => sprintf '@@ %s.html.ep' => $test->{'test_name'}; |
47
|
3
|
|
|
|
|
6
|
push @parsed => join "\n" => @{ $test->{'lines_template'} }; |
|
3
|
|
|
|
|
10
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
|
|
18
|
return join ("\n\n" => @parsed) . "\n"; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=pod |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=encoding UTF-8 |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 NAME |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
MojoX::CustomTemplateFileParser::Plugin::To::Test - Create tests |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 VERSION |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Version 0.1002, released 2015-11-26. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 SYNOPSIS |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
use MojoX::CustomTemplateFileParser; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $parser = MojoX::CustomTemplateFileParser->new(path => '/path/to/file.mojo', output => ['Test']); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
print $parser->to_test; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 DESCRIPTION |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
MojoX::CustomTemplateFileParser::Plugin::To::Test is an output plugin to L<MojoX::CustomTemplateFileParser>. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 to_test() |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This method is added to L<MojoX::CustomTemplateFileParser> objects created with C<output =E<gt> ['Test']>. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
It returns a string ready to be put in a L<Test::More> file. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 SEE ALSO |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=over 4 |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item * |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
L<Dist::Zilla::Plugin::Test::CreateFromMojoTemplates> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item * |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
L<MojoX::CustomTemplateFileParser::Plugin::To::Html> |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item * |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
L<MojoX::CustomTemplateFileParser::Plugin::To::Pod> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=back |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 SOURCE |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
L<https://github.com/Csson/p5-mojox-customtemplatefileparser> |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 HOMEPAGE |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
L<https://metacpan.org/release/MojoX-CustomTemplateFileParser> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 AUTHOR |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Erik Carlsson <info@code301.com> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Erik Carlsson. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
122
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |