File Coverage

File:local/lib/perl5/Test/Deep/MM.pm
Coverage:89.1%

linestmtbrancondsubtimecode
1
6
6
6
13
4
83
use strict;
2
6
6
6
12
1
292
use warnings;
3
4package Test::Deep::MM;
5
6sub import
7{
8
6
4
        my $self = shift;
9
10
6
10
        my ($pkg) = caller();
11
6
9
        my $mpkg = $pkg."::Methods";
12
6
7
        foreach my $attr (@_)
13        {
14
24
38
                if ($attr =~ /^[a-z]/)
15                {
16
6
6
6
13
10
372
                        no strict 'refs';
17
12
12
12
9
37
13
                        *{$mpkg."::$attr"} = \&{$attr};
18                }
19                else
20                {
21
12
12
                        my $get_name = $mpkg."::get$attr";
22
12
11
                        my $set_name = $mpkg."::set$attr";
23                        my $get_sub = sub {
24
428
544
                                return $_[0]->{$attr};
25
12
19
                        };
26                        my $set_sub = sub {
27
54
77
                                return $_[0]->{$attr} = $_[1];
28
12
12
                        };
29
30                        {
31
6
6
6
12
13
3
527
8
                                no strict 'refs';
32
12
23
                                *$get_name = $get_sub;
33
12
19
                                *$set_name = $set_sub;
34
12
12
6
944
                                push(@{$pkg."::ISA"}, $mpkg);
35                        }
36                }
37        }
38}
39
40sub new
41{
42
54
37
        my $pkg = shift;
43
44
54
91
        my $self = bless {}, $pkg;
45
46
54
88
        $self->init(@_);
47
48
54
62
        return $self;
49}
50
51sub init
52{
53
54
194
        my $self = shift;
54
55
54
137
        while (@_)
56        {
57
0
                my $name = shift || confess("No name");
58
59
0
                my $method = "set$name";
60
0
                $self->$method(shift);
61        }
62}
63
641;