File: 06b-compiler-named-subs.t

package info (click to toggle)
libhtml-mason-perl 1%3A1.39-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,072 kB
  • ctags: 1,535
  • sloc: perl: 17,624; sh: 187; makefile: 12
file content (91 lines) | stat: -rw-r--r-- 2,240 bytes parent folder | download | duplicates (3)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/perl -w

use strict;

use HTML::Mason::Tests;


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

sub make_tests {
    my $group =
        HTML::Mason::Tests->tests_class->new
            ( name => 'compiler_named_subs',
              description => 'compiler with named subs in components' );

#------------------------------------------------------------

    $group->add_test( name => 'basic',
                      description => 'Make sure that named_component_subs_works',
                      interp_params => { named_component_subs => 1 },
                      component => <<'EOF',
This is a test
EOF
                      expect => <<'EOF',
This is a test
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'subcomps',
                      description => 'Make sure that named_component_subs_works with subcomps',
                      interp_params => { named_component_subs => 1 },
                      component => <<'EOF',
<& .subcomp &>
<%def .subcomp>
This is a subcomp
</%def>
EOF
                      expect => <<'EOF',

This is a subcomp
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'methods',
                      description => 'Make sure that named_component_subs_works with methods',
                      interp_params => { named_component_subs => 1 },
                      component => <<'EOF',
<& SELF:method &>
<%method method>
This is a method
</%method>
EOF
                      expect => <<'EOF',

This is a method
EOF
                    );

#------------------------------------------------------------

    $group->add_test( name => 'shared',
                      description => 'Make sure that named_component_subs_works with shared block',
                      interp_params => { named_component_subs => 1 },
                      component => <<'EOF',
<%shared>
my $x = 42;
</%shared>

1: x is <% $x %>
<& SELF:method &>
<%method method>
2: x is <% $x %>
</%method>
EOF
                      expect => <<'EOF',

1: x is 42

2: x is 42
EOF
                    );

#------------------------------------------------------------

    return $group;
}