blib/lib/Mason/t/Syntax.pm

filter: Statementstmt 100% 62 / 62 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 27 / 27 Podpod 0.0% 0 / 13 totaltotal 87.2% 89 / 102 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
test_replace
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Mason/Component/ClassMeta.pm ↑ Summary blib/lib/Mason/t/Filters.pm »
1 package Mason::t::Syntax;
2 1 $Mason::t::Syntax::VERSION = '2.24';
3 1 ▶use Test::Class::Most parent => 'Mason::Test::Class';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶sub test_replace : Tests {
Subroutine test_replace: called CC=1 SCAR=0.0
Pod undocumented
6 shift->test_comp(
7 1 src => <<'EOF',
8 <BODY>
9 <% "Hello World!" %>
10 </BODY>
11 EOF
12 expect => <<'EOF',
13 <BODY>
14 Hello World!
15 </BODY>
16 EOF
17 );
18 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶sub test_percent : Tests {
Subroutine test_percent: called CC=1 SCAR=0.0
Pod undocumented
21 shift->test_comp(
22 1 src => <<'EOF',
23 <BODY>
24 % my $message = "Hello World!";
25 <% $message %>
26 </BODY>
27 EOF
28 expect => <<'EOF',
29 <BODY>
30 Hello World!
31 </BODY>
32 EOF
33 );
34 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 1 ▶sub test_fake_percent : Tests {
Subroutine test_fake_percent: called CC=1 SCAR=0.0
Pod undocumented
37 shift->test_comp(
38 1 src => <<'EOF',
39 some text, a %, and some text
40 EOF
41 expect => <<'EOF',
42 some text, a %, and some text
43 EOF
44 );
45 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
46  
47 1 ▶sub test_empty_percents : Tests {
Subroutine test_empty_percents: called CC=1 SCAR=0.0
Pod undocumented
48 shift->test_comp(
49 1 src => <<'EOF',
50 some text,
51 %
52 and some more
53 EOF
54 expect => <<'EOF',
55 some text,
56 and some more
57 EOF
58 );
59 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
60  
61 1 ▶sub test_empty_percents2 : Tests {
Subroutine test_empty_percents2: called CC=1 SCAR=0.0
Pod undocumented
62 shift->test_comp(
63 1 src => <<'EOF',
64 some text,
65 %
66 % $m->print('foo, ');
67 % $m->print(undef);
68 and some more
69 EOF
70 expect => <<'EOF',
71 some text,
72 foo, and some more
73 EOF
74 );
75 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
76  
77 # Deprecated syntax
78 #
79 1 ▶sub test_double_percent : Tests {
Subroutine test_double_percent: called CC=1 SCAR=0.0
Pod undocumented
80 shift->test_comp(
81 1 src => <<'EOF',
82 <%class>
83 my $i = 5;
84 </%class>
85  
86 %% my $j = 0;
87 %% if ($i == 5) {
88 %% $j = $i+1;
89 %% }
90 <% $.bar %>
91  
92 <%method bar>
93 j = <% $j %>
94 </%method>
95  
96 EOF
97 expect => <<'EOF',
98 j = 6
99 EOF
100 );
101 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
102  
103 1 ▶sub test_pure_perl : Tests {
Subroutine test_pure_perl: called CC=1 SCAR=0.0
Pod undocumented
104 shift->test_comp(
105 1 path => '/pureperl.mp',
106 src => 'sub main { print "hello from main" }',
107 expect => 'hello from main',
108 );
109 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
110  
111 # Deprecated syntax
112 #
113 1 ▶sub test_args : Tests {
Subroutine test_args: called CC=1 SCAR=0.0
Pod undocumented
114 1 my $self = shift;
115 1 $self->add_comp(
116 path => '/args.mc',
117 src => '
118 <%args>
119 a
120 b # comment
121  
122 # comment
123 c=>5
124 d => 6
125 e => "foo" # comment
126  
127 f => (isa => "Num", default => 7)
128 g => (isa => "Num", default => 8) # comment
129 </%args>
130  
131 a = <% $.a %>
132 b = <% $.b %>
133 c = <% $.c %>
134 d = <% $.d %>
135 e = <% $.e %>
136 f = <% $.f %>
137 g = <% $.g %>
138 ',
139 );
140 1 $self->test_comp(
141 src => '<& /args.mc, a => 3, b => 4 &>',
142 expect => '
143 a = 3
144 b = 4
145 c = 5
146 d = 6
147 e = foo
148 f = 7
149 g = 8
150 '
151 );
152 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
153  
154 1 ▶sub test_multiline_comment : Tests {
Subroutine test_multiline_comment: called CC=1 SCAR=0.0
Pod undocumented
155 1 my $self = shift;
156  
157 1 $self->test_comp(
158 src => '
159 hi<%
160 # comment
161  
162 # another comment
163  
164 %>bye
165 ',
166 expect => 'hibye',
167 );
168 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
169  
170 # Deprecated syntax
171 #
172 1 ▶sub test_shared : Tests {
Subroutine test_shared: called CC=1 SCAR=0.0
Pod undocumented
173 shift->test_parse(
174 1 src => '
175 <%shared>
176 $.foo # a comment
177 $.bar => "something"
178 $.baz => ( isa => "Num", default => 5 )
179 # another comment
180 </%shared>
181 ',
182 expect => [
183 q/has 'foo' => (init_arg => undef/,
184 q/has 'bar' => (init_arg => undef, default => "something"/,
185 q/has 'baz' => (init_arg => undef, isa => "Num", default => 5/
186 ],
187 );
188 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
189  
190 1 ▶sub test_dollar_dot : Tests {
Subroutine test_dollar_dot: called CC=1 SCAR=0.0
Pod undocumented
191 shift->test_comp(
192 1 src => '
193 <%class>
194 has "bar" => (default => 4);
195 has "foo" => (default => 3);
196  
197 </%class>
198  
199 <% $self->show %>
200  
201 <%method show>
202 foo = <% $.foo %>
203 bar = <% $.bar %>
204 </%method>
205  
206 <%init>
207 $self->foo(5);
208 $self->bar(6);
209 </%init>
210 ',
211 expect => '
212 foo = 5
213 bar = 6
214 '
215 );
216 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
217  
218 1 ▶sub test_dollar_m : Tests {
Subroutine test_dollar_m: called CC=1 SCAR=0.0
Pod undocumented
219 1 my $self = shift;
220 1 $self->test_comp(
221 src => '
222 <%class>
223 method foo () { $m->print("foo\n") }
224 </%class>
225 <%method bar><%perl>$m->print("bar\n");</%perl></%method>
226 <% $.foo %>
227 <% $.bar %>
228 % $m->print("baz\n");
229 ',
230 expect => '
231 foo
232  
233 bar
234  
235 baz
236 ',
237 );
238 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
239  
240 1 ▶sub test_class_global : Tests {
Subroutine test_class_global: called CC=1 SCAR=0.0
Pod undocumented
241 1 my $self = shift;
242  
243 1 $self->test_comp(
244 src => '<% ref($self) eq CLASS ? 1 : 0 %> <% ref($self) eq $CLASS ? 1 : 0 %>',
245 expect => qr/1 1/,
246 );
247 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
248  
249 1 1;
« blib/lib/Mason/Component/ClassMeta.pm ↑ Summary blib/lib/Mason/t/Filters.pm »