line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mason::t::Errors; |
2
|
|
|
|
|
|
|
$Mason::t::Errors::VERSION = '2.24'; |
3
|
1
|
|
|
1
|
|
734
|
use Test::Class::Most parent => 'Mason::Test::Class'; |
|
1
|
|
|
|
|
26386
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub test_comp_errors : Tests { |
6
|
1
|
|
|
1
|
0
|
744
|
my $self = shift; |
7
|
|
|
|
|
|
|
my $try = sub { |
8
|
33
|
|
|
33
|
|
74
|
my ( $src, $expect_error, %extra ) = @_; |
9
|
33
|
|
|
|
|
207
|
$self->test_comp( |
10
|
|
|
|
|
|
|
src => $src, |
11
|
|
|
|
|
|
|
expect_error => $expect_error, |
12
|
|
|
|
|
|
|
desc => $expect_error, |
13
|
|
|
|
|
|
|
%extra |
14
|
|
|
|
|
|
|
); |
15
|
1
|
|
|
|
|
4
|
}; |
16
|
1
|
|
|
|
|
8
|
my $root = $self->interp->comp_root->[0]; |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
|
|
25
|
$try->( |
19
|
|
|
|
|
|
|
'<& /does/not/exist &>', |
20
|
|
|
|
|
|
|
qr/could not find component for path '\/does\/not\/exist' - component root is \Q[$root]\E/, |
21
|
|
|
|
|
|
|
); |
22
|
1
|
|
|
|
|
7
|
$try->( '<%method>', qr/<%method> block requires a name/ ); |
23
|
1
|
|
|
|
|
7
|
$try->( '<%before>', qr/<%before> block requires a name/ ); |
24
|
1
|
|
|
|
|
7
|
$try->( '<%init>', qr/<%init> without matching <\/%init>/ ); |
25
|
1
|
|
|
|
|
7
|
$try->( '<%attr>', qr/unknown block '<%attr>'/ ); |
26
|
1
|
|
|
|
|
6
|
$try->( '<%blah>', qr/unknown block '<%blah>'/ ); |
27
|
1
|
|
|
|
|
6
|
$try->( '<%init foo>', qr/<%init> block does not take a name/ ); |
28
|
1
|
|
|
|
|
5
|
$try->( '<%', qr/'<%' without matching '%>'/ ); |
29
|
1
|
|
|
|
|
6
|
$try->( 'foo %>', qr/'%>' without matching '<%'/ ); |
30
|
1
|
|
|
|
|
6
|
$try->( '<& foo', qr/'<&' without matching '&>'/ ); |
31
|
1
|
|
|
|
|
6
|
$try->( 'foo &>', qr/'&>' without matching '<&'/ ); |
32
|
1
|
|
|
|
|
6
|
$try->( '%my $i = 1;', qr/% must be followed by whitespace/ ); |
33
|
1
|
|
|
|
|
6
|
$try->( "<%5\n\n%>", qr/whitespace required after '<%' at .* line 1/ ); |
34
|
1
|
|
|
|
|
6
|
$try->( "<%\n\n5%>", qr/whitespace required before '%>' at .* line 3/ ); |
35
|
1
|
|
|
|
|
6
|
$try->( "<%%>", qr/found empty '<% %>' tag/ ); |
36
|
1
|
|
|
|
|
6
|
$try->( "<% %>", qr/found empty '<% %>' tag/ ); |
37
|
1
|
|
|
|
|
6
|
$try->( "<% %>", qr/found empty '<% %>' tag/ ); |
38
|
1
|
|
|
|
|
6
|
$try->( "% \$.Upper {{\nHi", qr/'\{\{' without matching '}}'/ ); |
39
|
1
|
|
|
|
|
6
|
$try->( "Hi\n% }}", qr/'}}' without matching '\{\{'/ ); |
40
|
1
|
|
|
|
|
6
|
$try->( '<%method 1a>Hi</%method>', qr/Invalid method name '1a'/ ); |
41
|
1
|
|
|
|
|
6
|
$try->( '<%method cmeta>Hi</%method>', qr/'cmeta' is reserved.*method name/ ); |
42
|
1
|
|
|
|
|
6
|
$try->( |
43
|
|
|
|
|
|
|
"<%method a>Hi</%method>\n<%method a>Bye</%method>", |
44
|
|
|
|
|
|
|
qr/Duplicate definition of method 'a'/ |
45
|
|
|
|
|
|
|
); |
46
|
1
|
|
|
|
|
6
|
$try->( "<%before 1a>Hi</%before>", qr/Invalid method modifier name '1a'/ ); |
47
|
1
|
|
|
|
|
6
|
$try->( |
48
|
|
|
|
|
|
|
"<%before a>Hi</%before>\n<%before a>Bye</%before>", |
49
|
|
|
|
|
|
|
qr/Duplicate definition of method modifier 'before a'/ |
50
|
|
|
|
|
|
|
); |
51
|
1
|
|
|
|
|
6
|
$try->( |
52
|
|
|
|
|
|
|
'<%method b><%after main>Hi</%after></%method>', |
53
|
|
|
|
|
|
|
qr/Cannot nest <%after> block inside <%method> block/ |
54
|
|
|
|
|
|
|
); |
55
|
1
|
|
|
|
|
6
|
$try->( "% 'foobar' {{\nHi\n% }}\n", qr/'foobar' is neither a code ref/ ); |
56
|
1
|
|
|
|
|
7
|
$try->( "<%flags>\nfoo => 1\n</%flags>", qr/Invalid flag 'foo'/ ); |
57
|
1
|
|
|
|
|
8
|
$try->( "<%flags>\nextends => 'blah'\n</%flags>", |
58
|
|
|
|
|
|
|
qr/could not load '\/blah' for extends flag/ ); |
59
|
1
|
|
|
|
|
7
|
$try->( "<%flags>\nextends => %foo\n</%flags>", qr/Global symbol/ ); |
60
|
1
|
|
|
|
|
8
|
$try->( '<% $foo %>', qr/Global symbol "\$foo" requires explicit package name/ ); |
61
|
1
|
|
|
|
|
8
|
$try->( 'die "blargh";', qr/blargh/, path => '/blargh.mp' ); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# Error line numbers |
64
|
|
|
|
|
|
|
# |
65
|
1
|
|
|
|
|
12
|
$try->( "%\nb\n% die;", qr/Died at .* line 3/ ); |
66
|
1
|
|
|
|
|
9
|
$try->( "<%method foo>\n1\n2\n3\n</%method>\n% die;", qr/Died at .* line 6/ ); |
67
|
1
|
|
|
1
|
|
648
|
} |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub test_bad_allow_globals : Tests { |
70
|
1
|
|
|
1
|
0
|
729
|
my $self = shift; |
71
|
1
|
|
|
1
|
|
11
|
throws_ok { $self->create_interp( allow_globals => ['@p'] ) } qr/only scalar globals supported/; |
|
1
|
|
|
|
|
73
|
|
72
|
1
|
|
|
1
|
|
776
|
throws_ok { $self->create_interp( allow_globals => ['i-'] ) } qr/not a valid/; |
|
1
|
|
|
|
|
57
|
|
73
|
1
|
|
|
1
|
|
331
|
} |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub test_non_comp_errors : Tests { |
76
|
1
|
|
|
1
|
0
|
298
|
my $self = shift; |
77
|
1
|
|
|
1
|
|
51
|
throws_ok { $self->interp->_make_request()->current_comp_class } |
78
|
1
|
|
|
|
|
14
|
qr/cannot determine current_comp_class/; |
79
|
1
|
|
|
1
|
|
433
|
throws_ok { Mason->new() } qr/Attribute \(comp_root\) is required/; |
|
1
|
|
|
|
|
44
|
|
80
|
1
|
|
|
1
|
|
265
|
} |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |