line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mason::t::Reload; |
2
|
|
|
|
|
|
|
$Mason::t::Reload::VERSION = '2.24'; |
3
|
1
|
|
|
1
|
|
762
|
use Test::Class::Most parent => 'Mason::Test::Class'; |
|
1
|
|
|
|
|
28974
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub test_reload : Tests { |
6
|
1
|
|
|
1
|
0
|
865
|
my $self = shift; |
7
|
1
|
|
|
|
|
1
|
my $class; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
|
|
8
|
$self->add_comp( |
10
|
|
|
|
|
|
|
path => "/reload.mc", |
11
|
|
|
|
|
|
|
src => <<'EOF', |
12
|
|
|
|
|
|
|
<%class> |
13
|
|
|
|
|
|
|
sub foo { 'foo' } |
14
|
|
|
|
|
|
|
sub baz { 'baz1' } |
15
|
|
|
|
|
|
|
</%class> |
16
|
|
|
|
|
|
|
Foo |
17
|
|
|
|
|
|
|
EOF |
18
|
|
|
|
|
|
|
); |
19
|
1
|
|
|
|
|
8
|
is( $self->interp->run("/reload")->output, "Foo\n", "before reload" ); |
20
|
1
|
|
|
|
|
583
|
$class = $self->interp->load("/reload.mc"); |
21
|
1
|
|
|
|
|
12
|
is( $class->foo(), 'foo', "method foo" ); |
22
|
1
|
|
|
|
|
404
|
is( $class->baz(), 'baz1', "method baz" ); |
23
|
1
|
|
|
|
|
350
|
ok( $class->can('foo'), "can call foo before reload" ); |
24
|
1
|
|
|
|
|
355
|
ok( !$class->can('bar'), "cannot call bar before reload" ); |
25
|
1
|
|
|
|
|
351
|
ok( $class->can('baz'), "can call baz before reload" ); |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
1000535
|
sleep(1); # so timestamp will be different |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
22
|
$self->add_comp( |
30
|
|
|
|
|
|
|
path => "/reload.mc", |
31
|
|
|
|
|
|
|
src => <<'EOF', |
32
|
|
|
|
|
|
|
<%class> |
33
|
|
|
|
|
|
|
sub bar { 'bar' } |
34
|
|
|
|
|
|
|
sub baz { 'baz2' } |
35
|
|
|
|
|
|
|
</%class> |
36
|
|
|
|
|
|
|
Bar |
37
|
|
|
|
|
|
|
EOF |
38
|
|
|
|
|
|
|
); |
39
|
1
|
|
|
|
|
8
|
is( $self->interp->run("/reload")->output, "Bar\n", "after reload" ); |
40
|
1
|
|
|
|
|
568
|
is( $class->bar(), 'bar', "method bar" ); |
41
|
1
|
|
|
|
|
384
|
is( $class->baz(), 'baz2', "method baz" ); |
42
|
1
|
|
|
|
|
340
|
ok( $class->can('bar'), "can call bar after reload" ); |
43
|
1
|
|
|
|
|
348
|
ok( !$class->can('foo'), "cannot call foo after reload" ); |
44
|
1
|
|
|
|
|
385
|
ok( $class->can('baz'), "can call baz after reload" ); |
45
|
1
|
|
|
1
|
|
266
|
} |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub test_reload_parent : Tests { |
48
|
1
|
|
|
1
|
0
|
826
|
my $self = shift; |
49
|
1
|
|
|
|
|
8
|
my $interp = $self->interp; |
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
6
|
$self->add_comp( path => '/foo/bar/baz.mc', src => '<% $.num1 %> <% $.num2 %>' ); |
52
|
1
|
|
|
|
|
6
|
$self->add_comp( path => '/foo/Base.mc', src => '<%class>method num1 { 5 }</%class>' ); |
53
|
1
|
|
|
|
|
5
|
$self->add_comp( path => '/Base.mc', src => '<%class>method num2 { 6 }</%class>' ); |
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
|
|
10
|
$self->test_existing_comp( path => '/foo/bar/baz.mc', expect => '5 6' ); |
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
5
|
$self->interp->_flush_load_cache(); |
58
|
1
|
|
|
|
|
1000227
|
sleep(1); |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
22
|
$self->add_comp( path => '/foo/Base.mc', src => "<%class>method num1 { 7 }</%class>" ); |
61
|
1
|
|
|
|
|
6
|
$self->add_comp( path => '/Base.mc', src => "<%class>method num2 { 8 }</%class>" ); |
62
|
1
|
|
|
|
|
6
|
$self->test_existing_comp( path => '/foo/bar/baz.mc', expect => '7 8' ); |
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
5
|
$self->interp->_flush_load_cache(); |
65
|
1
|
|
|
|
|
1000219
|
sleep(1); |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
|
|
57
|
$self->add_comp( |
68
|
|
|
|
|
|
|
path => '/Base.mc', |
69
|
|
|
|
|
|
|
src => "<%class>method num1 { 10 }\nmethod num2 { 11 }\n</%class>" |
70
|
|
|
|
|
|
|
); |
71
|
1
|
|
|
|
|
6
|
$self->test_existing_comp( path => '/foo/bar/baz.mc', expect => '7 11' ); |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
5
|
$self->interp->_flush_load_cache(); |
74
|
1
|
|
|
|
|
1000192
|
sleep(1); |
75
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
44
|
$self->remove_comp( path => '/foo/Base.mc' ); |
77
|
1
|
|
|
|
|
19
|
$self->test_existing_comp( path => '/foo/bar/baz.mc', expect => '10 11' ); |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
8
|
$self->interp->_flush_load_cache(); |
80
|
1
|
|
|
|
|
1000170
|
sleep(1); |
81
|
|
|
|
|
|
|
|
82
|
1
|
|
|
|
|
22
|
$self->remove_comp( path => '/foo/Base.mc' ); |
83
|
1
|
|
|
|
|
6
|
$self->add_comp( path => '/foo/bar/baz.mc', src => 'hi' ); |
84
|
1
|
|
|
|
|
4
|
$self->add_comp( path => '/Base.mp', src => 'method wrap { print "wrap1" }' ); |
85
|
1
|
|
|
|
|
5
|
$self->test_existing_comp( path => '/foo/bar/baz.mc', expect => 'wrap1' ); |
86
|
|
|
|
|
|
|
|
87
|
1
|
|
|
|
|
6
|
$self->interp->_flush_load_cache(); |
88
|
1
|
|
|
|
|
1000202
|
sleep(1); |
89
|
|
|
|
|
|
|
|
90
|
1
|
|
|
|
|
21
|
$self->add_comp( path => '/Base.mp', src => 'method wrap { print "wrap2" }' ); |
91
|
1
|
|
|
|
|
8
|
$self->test_existing_comp( path => '/foo/bar/baz.mc', expect => 'wrap2' ); |
92
|
1
|
|
|
1
|
|
403
|
} |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub test_no_unnecessary_reload : Tests { |
95
|
1
|
|
|
1
|
0
|
783
|
my $self = shift; |
96
|
1
|
|
|
|
|
6
|
my $interp = $self->interp; |
97
|
|
|
|
|
|
|
|
98
|
1
|
|
|
|
|
7
|
$self->add_comp( path => '/foo.mc', src => ' ' ); |
99
|
1
|
|
|
|
|
29
|
my $id1 = $interp->load('/foo.mc')->cmeta->id; |
100
|
1
|
|
|
|
|
6
|
$self->interp->_flush_load_cache(); |
101
|
1
|
|
|
|
|
47
|
my $id2 = $interp->load('/foo.mc')->cmeta->id; |
102
|
1
|
|
|
|
|
6
|
ok( $id1 == $id2 ); |
103
|
1
|
|
|
1
|
|
260
|
} |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |