| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::Inline::Content::Legacy; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Test::Inline::Content::Legacy - Test::Inline 2 Content Handler for legacy functions |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Custom script content generation using Test::Inline 2.000+ with a |
|
12
|
|
|
|
|
|
|
custom generator functions |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $header = "...."; |
|
15
|
|
|
|
|
|
|
my $function = sub { |
|
16
|
|
|
|
|
|
|
my $Object = shift; |
|
17
|
|
|
|
|
|
|
my $Script = shift; |
|
18
|
|
|
|
|
|
|
return $header . $Script->merged_content; |
|
19
|
|
|
|
|
|
|
}; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $Inline = Test::Inline->new( |
|
22
|
|
|
|
|
|
|
... |
|
23
|
|
|
|
|
|
|
file_content => $function, |
|
24
|
|
|
|
|
|
|
); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Migrating this same code to Test::Inline 2.100+ ContentHandler objects |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $header = "...."; |
|
29
|
|
|
|
|
|
|
my $function = sub { |
|
30
|
|
|
|
|
|
|
my $Object = shift; |
|
31
|
|
|
|
|
|
|
my $Script = shift; |
|
32
|
|
|
|
|
|
|
return $header . $Script->merged_content; |
|
33
|
|
|
|
|
|
|
}; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $ContentHandler = Test::Inline::Content::Legacy->new( $function ); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $Inline = Test::Inline->new( |
|
38
|
|
|
|
|
|
|
... |
|
39
|
|
|
|
|
|
|
ContentHandler => $ContentHandler, |
|
40
|
|
|
|
|
|
|
); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
This class exists to provide a migration path for anyone using the custom |
|
45
|
|
|
|
|
|
|
script generators in Test::Inline via the C param. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
The synopsis above pretty much says all you need to know. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 METHODS |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
|
52
|
|
|
|
|
|
|
|
|
53
|
12
|
|
|
12
|
|
1482
|
use strict; |
|
|
12
|
|
|
|
|
23
|
|
|
|
12
|
|
|
|
|
469
|
|
|
54
|
12
|
|
|
12
|
|
66
|
use Params::Util qw{_CODE _INSTANCE}; |
|
|
12
|
|
|
|
|
22
|
|
|
|
12
|
|
|
|
|
603
|
|
|
55
|
12
|
|
|
12
|
|
69
|
use Test::Inline::Content (); |
|
|
12
|
|
|
|
|
22
|
|
|
|
12
|
|
|
|
|
249
|
|
|
56
|
|
|
|
|
|
|
|
|
57
|
12
|
|
|
12
|
|
63
|
use vars qw{$VERSION @ISA}; |
|
|
12
|
|
|
|
|
25
|
|
|
|
12
|
|
|
|
|
738
|
|
|
58
|
|
|
|
|
|
|
BEGIN { |
|
59
|
12
|
|
|
12
|
|
26
|
$VERSION = '2.213'; |
|
60
|
12
|
|
|
|
|
2490
|
@ISA = 'Test::Inline::Content'; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=pod |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 new $CODE_ref |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
The C constructor for C takes a single |
|
68
|
|
|
|
|
|
|
parameter of a C reference, as you would have previously provided |
|
69
|
|
|
|
|
|
|
directly to C. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Returns a new C object, or C if not |
|
72
|
|
|
|
|
|
|
passed a C reference. |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub new { |
|
77
|
5
|
50
|
|
5
|
1
|
1036
|
my $class = ref $_[0] ? ref shift : shift; |
|
78
|
5
|
|
|
|
|
33
|
my $self = $class->SUPER::new(@_); |
|
79
|
5
|
100
|
|
|
|
48
|
$self->{coderef} = _CODE(shift) or return undef; |
|
80
|
1
|
|
|
|
|
12
|
$self; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=pod |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 coderef |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
The C accessor returns the C reference for the object |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
|
90
|
|
|
|
|
|
|
|
|
91
|
2
|
|
|
2
|
1
|
14
|
sub coderef { $_[0]->{coderef} } |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=pod |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 process $Inline $Script |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
The C method works with the legacy function by passing the |
|
98
|
|
|
|
|
|
|
L and L arguments straight through |
|
99
|
|
|
|
|
|
|
to the legacy function, and returning it's result as the return value. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub process { |
|
104
|
1
|
|
|
1
|
1
|
4
|
my $self = shift; |
|
105
|
1
|
50
|
|
|
|
13
|
my $Inline = _INSTANCE(shift, 'Test::Inline') or return undef; |
|
106
|
1
|
50
|
|
|
|
14
|
my $Script = _INSTANCE(shift, 'Test::Inline::Script') or return undef; |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# Pass through the params, pass back the result |
|
109
|
1
|
|
|
|
|
115
|
$self->coderef->( $Inline, $Script ); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=pod |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 SUPPORT |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
See the main L section. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 AUTHOR |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Adam Kennedy Eadamk@cpan.orgE, L |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Copyright 2004 - 2013 Adam Kennedy. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This program is free software; you can redistribute |
|
129
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
The full text of the license can be found in the |
|
132
|
|
|
|
|
|
|
LICENSE file included with this module. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |