File: 05a-stack-corruption.t

package info (click to toggle)
libhtml-mason-perl 1%3A1.58-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,796 kB
  • sloc: perl: 8,618; sh: 49; makefile: 2
file content (63 lines) | stat: -rw-r--r-- 1,485 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use strict;
use warnings;

use HTML::Mason::Tests;

my $tests = make_tests();
$tests->run;

sub make_tests
{
    my $group = HTML::Mason::Tests->tests_class->new( name => 'stack_corruption',
                                                      description => 'tests for stack corruption',
                                                    );


    # The key to this test is that it first calls a component that in
    # turn has a comp-with-content call. That comp-with-content call
    # then calls $m->content (this is important).
    #
    # After that, _further_ component calls reveal stack corruption.
    $group->add_support( path => '/support/comp',
                         component => <<'EOF',
<&| .subcomp1 &>
<& .subcomp2 &>
</&>

<%def .subcomp1>
% $m->content;
</%def>

<%def .subcomp2>
content
</%def>
EOF
                       );

    $group->add_support( path => '/support/comp2',
                         component => <<'EOF',

EOF
                       );

    $group->add_test( name => 'stack_corruption',
                      description => 'test for stack corruption with comp-with-content call',
                      component => <<'EOF',
<& support/comp &>

<& support/comp2 &>

<& .callers &>

<%def .callers>
Stack at this point:
% for my $f ( $m->callers ) {
<% defined $f ? $f->path : 'undef' %>
% }
</%def>
EOF
                      expect => qr{/stack_corruption/stack_corruption:.callers\n(?!undef)},
                    );

    return $group;
}