blib/lib/Mason/t/Errors.pm

filter: Statementstmt 100% 62 / 62 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 0.0% 0 / 3 totaltotal 96.1% 74 / 77 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
test_comp_errors
1.0
__ANON__
1.0
CRAP 1.0
« blib/lib/Mason/t/Compilation.pm ↑ Summary blib/lib/Mason/t/Reload.pm »
1 package Mason::t::Errors;
2 1 $Mason::t::Errors::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_comp_errors : Tests {
Subroutine test_comp_errors: called CC=1 SCAR=0.0
Pod undocumented
6 1 my $self = shift;
7 33 ▶ my $try = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
8 33 my ( $src, $expect_error, %extra ) = @_;
9 33 $self->test_comp(
10 src => $src,
11 expect_error => $expect_error,
12 desc => $expect_error,
13 %extra
14 );
15 1 };
16 1 my $root = $self->interp->comp_root->[0];
17  
18 1 $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 $try->( '<%method>', qr/<%method> block requires a name/ );
23 1 $try->( '<%before>', qr/<%before> block requires a name/ );
24 1 $try->( '<%init>', qr/<%init> without matching <\/%init>/ );
25 1 $try->( '<%attr>', qr/unknown block '<%attr>'/ );
26 1 $try->( '<%blah>', qr/unknown block '<%blah>'/ );
27 1 $try->( '<%init foo>', qr/<%init> block does not take a name/ );
28 1 $try->( '<%', qr/'<%' without matching '%>'/ );
29 1 $try->( 'foo %>', qr/'%>' without matching '<%'/ );
30 1 $try->( '<& foo', qr/'<&' without matching '&>'/ );
31 1 $try->( 'foo &>', qr/'&>' without matching '<&'/ );
32 1 $try->( '%my $i = 1;', qr/% must be followed by whitespace/ );
33 1 $try->( "<%5\n\n%>", qr/whitespace required after '<%' at .* line 1/ );
34 1 $try->( "<%\n\n5%>", qr/whitespace required before '%>' at .* line 3/ );
35 1 $try->( "<%%>", qr/found empty '<% %>' tag/ );
36 1 $try->( "<% %>", qr/found empty '<% %>' tag/ );
37 1 $try->( "<% %>", qr/found empty '<% %>' tag/ );
38 1 $try->( "% \$.Upper {{\nHi", qr/'\{\{' without matching '}}'/ );
39 1 $try->( "Hi\n% }}", qr/'}}' without matching '\{\{'/ );
40 1 $try->( '<%method 1a>Hi</%method>', qr/Invalid method name '1a'/ );
41 1 $try->( '<%method cmeta>Hi</%method>', qr/'cmeta' is reserved.*method name/ );
42 1 $try->(
43 "<%method a>Hi</%method>\n<%method a>Bye</%method>",
44 qr/Duplicate definition of method 'a'/
45 );
46 1 $try->( "<%before 1a>Hi</%before>", qr/Invalid method modifier name '1a'/ );
47 1 $try->(
48 "<%before a>Hi</%before>\n<%before a>Bye</%before>",
49 qr/Duplicate definition of method modifier 'before a'/
50 );
51 1 $try->(
52 '<%method b><%after main>Hi</%after></%method>',
53 qr/Cannot nest <%after> block inside <%method> block/
54 );
55 1 $try->( "% 'foobar' {{\nHi\n% }}\n", qr/'foobar' is neither a code ref/ );
56 1 $try->( "<%flags>\nfoo => 1\n</%flags>", qr/Invalid flag 'foo'/ );
57 1 $try->( "<%flags>\nextends => 'blah'\n</%flags>",
58 qr/could not load '\/blah' for extends flag/ );
59 1 $try->( "<%flags>\nextends => %foo\n</%flags>", qr/Global symbol/ );
60 1 $try->( '<% $foo %>', qr/Global symbol "\$foo" requires explicit package name/ );
61 1 $try->( 'die "blargh";', qr/blargh/, path => '/blargh.mp' );
62  
63 # Error line numbers
64 #
65 1 $try->( "%\nb\n% die;", qr/Died at .* line 3/ );
66 1 $try->( "<%method foo>\n1\n2\n3\n</%method>\n% die;", qr/Died at .* line 6/ );
67 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
68  
69 1 ▶sub test_bad_allow_globals : Tests {
Subroutine test_bad_allow_globals: called CC=1 SCAR=0.0
Pod undocumented
70 1 my $self = shift;
71 1 ▶ throws_ok { $self->create_interp( allow_globals => ['@p'] ) } qr/only scalar globals supported/;
Subroutine __ANON__: called CC=1 SCAR=0.0
72 1 ▶ throws_ok { $self->create_interp( allow_globals => ['i-'] ) } qr/not a valid/;
Subroutine __ANON__: called CC=1 SCAR=0.0
73 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
74  
75 1 ▶sub test_non_comp_errors : Tests {
Subroutine test_non_comp_errors: called CC=1 SCAR=0.0
Pod undocumented
76 1 my $self = shift;
77 1 ▶ throws_ok { $self->interp->_make_request()->current_comp_class }
Subroutine __ANON__: called CC=1 SCAR=0.0
78 1 qr/cannot determine current_comp_class/;
79 1 ▶ throws_ok { Mason->new() } qr/Attribute \(comp_root\) is required/;
Subroutine __ANON__: called CC=1 SCAR=0.0
80 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
81  
82 1 1;
« blib/lib/Mason/t/Compilation.pm ↑ Summary blib/lib/Mason/t/Reload.pm »