line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::AbstractMethod; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
31724
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
95
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use base qw(Test::Builder::Module); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
142
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
13
|
use vars qw(@EXPORT $VERSION); |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
1010
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$VERSION = 0.01; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
@EXPORT = qw(call_abstract_function_ok call_abstract_method_ok call_abstract_class_method_ok); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub call_abstract_function_ok($$;$) { |
14
|
2
|
|
|
2
|
1
|
1266
|
my ($pkg, $method, $description) = @_; |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
|
|
8
|
my $builder = Test::AbstractMethod->builder(); |
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
|
|
14
|
eval { |
19
|
2
|
|
|
|
|
13
|
$pkg->can($method)->(0); |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
|
22
|
2
|
|
66
|
|
|
29
|
my $threw_exception = $@ && $@ =~ qr/$method\(\) should not be called as a function/; |
23
|
2
|
|
|
|
|
7
|
my $ok = $builder->ok( $threw_exception, $description ); |
24
|
|
|
|
|
|
|
|
25
|
2
|
|
|
|
|
733
|
return $ok; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _call_abstract_method_ok($$$;$) { |
29
|
4
|
|
|
4
|
|
7
|
my ($pkg, $method, $callee, $description) = @_; |
30
|
|
|
|
|
|
|
|
31
|
4
|
|
|
|
|
25
|
my $builder = Test::AbstractMethod->builder(); |
32
|
4
|
|
|
|
|
34
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
33
|
|
|
|
|
|
|
|
34
|
4
|
|
|
|
|
26
|
my $cv = $pkg->can($method); |
35
|
4
|
|
|
|
|
7
|
eval { |
36
|
4
|
|
|
|
|
11
|
$cv->($callee); |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
|
39
|
4
|
|
66
|
|
|
96
|
my $threw_exception = $@ && $@ =~ qr/Class '$pkg' does not override ${method}()/; |
40
|
4
|
|
|
|
|
14
|
my $ok = $builder->ok( $threw_exception, $description ); |
41
|
|
|
|
|
|
|
|
42
|
4
|
|
|
|
|
1606
|
return $ok; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub call_abstract_method_ok($$;$) { |
46
|
2
|
|
|
2
|
1
|
6529
|
my ($pkg, $method, $description) = @_; |
47
|
|
|
|
|
|
|
|
48
|
2
|
|
|
|
|
3
|
my $callee = bless do { my $sv; \$sv; }, $pkg; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
7
|
|
49
|
2
|
|
|
|
|
7
|
return _call_abstract_method_ok($pkg, $method, $callee, $description); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub call_abstract_class_method_ok($$;$) { |
53
|
2
|
|
|
2
|
1
|
1402
|
my ($pkg, $method, $description) = @_; |
54
|
|
|
|
|
|
|
|
55
|
2
|
|
|
|
|
6
|
return _call_abstract_method_ok($pkg, $method, $pkg, $description); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
__END__ |