blib/lib/Mason/t/Sections.pm

filter: Statementstmt 100% 3 / 3 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 1 / 1 Podpod n/a totaltotal 100% 4 / 4 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
CRAP 1.0
« blib/lib/Mason/t/Sanity.pm ↑ Summary blib/lib/Mason/t/StaticSource.pm »
1 package Mason::t::Sections;
2 $Mason::t::Sections::VERSION = '2.23';
3 1 ▶use Test::Class::Most parent => 'Mason::Test::Class';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 sub test_sections : Tests {
6 my $self = shift;
7 $self->test_comp(
8 src => <<'EOF',
9 <%doc>
10 This should not get printed.
11 </%doc>
12  
13 <%init>
14 my $init_message = $self->init_message();
15 </%init>
16  
17 <%class>
18 my $class_message = "class message";
19 method init_message () { "init message" }
20 </%class>
21  
22 <BODY>
23 <% $class_message %>
24 % $self->method_call();
25 <% $self->method_call_with_arglist(3, 4) %>
26 <%perl>
27 print "$init_message\n";
28 </%perl>
29 </BODY>
30  
31 <%method method_call>
32 <% $message %>
33  
34 <%init>
35 my $message = "message";
36 </%init>
37 </%method>
38  
39 <%before method_call>
40 before method call
41 </%before>
42  
43 <%after method_call>
44 after method call
45 </%after>
46  
47 <%override render>
48 start override
49 <% super() %>
50 end override
51 </%override>
52  
53 <%method method_call_with_arglist ($foo, $bar)>
54 <% $foo %> - <% $bar %>
55 </%method>
56  
57 EOF
58 expect => <<'EOF',
59 start override
60 <BODY>
61 class message
62  
63 before method call
64  
65 message
66  
67 after method call
68  
69 3 - 4
70 init message
71 </BODY>
72  
73 end override
74 EOF
75 );
76 }
77  
78 sub test_perl_section_newlines : Tests {
79 my $self = shift;
80 $self->test_comp(
81 src => <<'EOF',
82 1<%perl>print "2\n";</%perl>
83 <%perl>
84 print "3\n";
85 </%perl>
86  
87 4
88  
89 <%perl>
90 print "5\n";
91 </%perl>
92  
93  
94 6
95  
96  
97 <%perl>
98 print "7\n";
99 </%perl>
100 EOF
101 expect => <<'EOF',
102 12
103 3
104 4
105 5
106  
107 6
108  
109 7
110 EOF
111 );
112 }
113  
114 sub test_text_section : Tests {
115 my $self = shift;
116 $self->test_comp(
117 src => <<'EOF',
118 <%text>
119 %
120 <%init>
121 <%doc>
122 <% $x %>
123 </%text>
124 EOF
125 expect => <<'EOF',
126  
127 %
128 <%init>
129 <%doc>
130 <% $x %>
131 EOF
132 );
133 }
134  
135 sub test_empty_sections : Tests {
136 my $self = shift;
137 $self->test_comp(
138 src => '
139 hi
140 <%after foo></%after>
141 <%around foo></%around>
142 <%before foo></%before>
143 <%method foo></%method>
144 <%filter bar></%filter>
145 <%override allow_path_info></%override>
146 <%class></%class>
147 <%doc></%doc>
148 <%flags></%flags>
149 <%init></%init>
150 <%perl></%perl>
151 <%text></%text>
152 bye
153 ',
154 expect => "hibye",
155 );
156 }
157  
158 1;
« blib/lib/Mason/t/Sanity.pm ↑ Summary blib/lib/Mason/t/StaticSource.pm »