line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mason::t::Reload; |
2
|
|
|
|
|
|
|
$Mason::t::Reload::VERSION = '2.23'; |
3
|
1
|
|
|
1
|
|
768
|
use Test::Class::Most parent => 'Mason::Test::Class'; |
|
1
|
|
|
|
|
28435
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub test_reload : Tests { |
6
|
1
|
|
|
1
|
0
|
1043
|
my $self = shift; |
7
|
1
|
|
|
|
|
4
|
my $class; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
|
|
9
|
$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
|
|
|
|
|
7
|
is( $self->interp->run("/reload")->output, "Foo\n", "before reload" ); |
20
|
1
|
|
|
|
|
634
|
$class = $self->interp->load("/reload.mc"); |
21
|
1
|
|
|
|
|
10
|
is( $class->foo(), 'foo', "method foo" ); |
22
|
1
|
|
|
|
|
356
|
is( $class->baz(), 'baz1', "method baz" ); |
23
|
1
|
|
|
|
|
518
|
ok( $class->can('foo'), "can call foo before reload" ); |
24
|
1
|
|
|
|
|
359
|
ok( !$class->can('bar'), "cannot call bar before reload" ); |
25
|
1
|
|
|
|
|
355
|
ok( $class->can('baz'), "can call baz before reload" ); |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
1000515
|
sleep(1); # so timestamp will be different |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
29
|
$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
|
|
|
|
|
10
|
is( $self->interp->run("/reload")->output, "Bar\n", "after reload" ); |
40
|
1
|
|
|
|
|
674
|
is( $class->bar(), 'bar', "method bar" ); |
41
|
1
|
|
|
|
|
344
|
is( $class->baz(), 'baz2', "method baz" ); |
42
|
1
|
|
|
|
|
456
|
ok( $class->can('bar'), "can call bar after reload" ); |
43
|
1
|
|
|
|
|
355
|
ok( !$class->can('foo'), "cannot call foo after reload" ); |
44
|
1
|
|
|
|
|
342
|
ok( $class->can('baz'), "can call baz after reload" ); |
45
|
1
|
|
|
1
|
|
268
|
} |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub test_reload_parent : Tests { |
48
|
1
|
|
|
1
|
0
|
670
|
my $self = shift; |
49
|
1
|
|
|
|
|
9
|
my $interp = $self->interp; |
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
6
|
$self->add_comp( path => '/foo/bar/baz.mc', src => '<% $.num1 %> <% $.num2 %>' ); |
52
|
1
|
|
|
|
|
5
|
$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
|
|
|
|
|
11
|
$self->test_existing_comp( path => '/foo/bar/baz.mc', expect => '5 6' ); |
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
6
|
$self->interp->_flush_load_cache(); |
58
|
1
|
|
|
|
|
1000127
|
sleep(1); |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
16
|
$self->add_comp( path => '/foo/Base.mc', src => "<%class>method num1 { 7 }</%class>" ); |
61
|
1
|
|
|
|
|
9
|
$self->add_comp( path => '/Base.mc', src => "<%class>method num2 { 8 }</%class>" ); |
62
|
1
|
|
|
|
|
8
|
$self->test_existing_comp( path => '/foo/bar/baz.mc', expect => '7 8' ); |
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
7
|
$self->interp->_flush_load_cache(); |
65
|
1
|
|
|
|
|
1000137
|
sleep(1); |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
|
|
18
|
$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
|
|
|
|
|
7
|
$self->interp->_flush_load_cache(); |
74
|
1
|
|
|
|
|
1000139
|
sleep(1); |
75
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
31
|
$self->remove_comp( path => '/foo/Base.mc' ); |
77
|
1
|
|
|
|
|
6
|
$self->test_existing_comp( path => '/foo/bar/baz.mc', expect => '10 11' ); |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
8
|
$self->interp->_flush_load_cache(); |
80
|
1
|
|
|
|
|
1000172
|
sleep(1); |
81
|
|
|
|
|
|
|
|
82
|
1
|
|
|
|
|
19
|
$self->remove_comp( path => '/foo/Base.mc' ); |
83
|
1
|
|
|
|
|
6
|
$self->add_comp( path => '/foo/bar/baz.mc', src => 'hi' ); |
84
|
1
|
|
|
|
|
5
|
$self->add_comp( path => '/Base.mp', src => 'method wrap { print "wrap1" }' ); |
85
|
1
|
|
|
|
|
6
|
$self->test_existing_comp( path => '/foo/bar/baz.mc', expect => 'wrap1' ); |
86
|
|
|
|
|
|
|
|
87
|
1
|
|
|
|
|
8
|
$self->interp->_flush_load_cache(); |
88
|
1
|
|
|
|
|
1000353
|
sleep(1); |
89
|
|
|
|
|
|
|
|
90
|
1
|
|
|
|
|
20
|
$self->add_comp( path => '/Base.mp', src => 'method wrap { print "wrap2" }' ); |
91
|
1
|
|
|
|
|
7
|
$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
|
778
|
my $self = shift; |
96
|
1
|
|
|
|
|
8
|
my $interp = $self->interp; |
97
|
|
|
|
|
|
|
|
98
|
1
|
|
|
|
|
7
|
$self->add_comp( path => '/foo.mc', src => ' ' ); |
99
|
1
|
|
|
|
|
35
|
my $id1 = $interp->load('/foo.mc')->cmeta->id; |
100
|
1
|
|
|
|
|
7
|
$self->interp->_flush_load_cache(); |
101
|
1
|
|
|
|
|
48
|
my $id2 = $interp->load('/foo.mc')->cmeta->id; |
102
|
1
|
|
|
|
|
6
|
ok( $id1 == $id2 ); |
103
|
1
|
|
|
1
|
|
264
|
} |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |