Run/Base/Struct.pm

filter: Statementstmt 100% 27 / 27 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 100% 3 / 3 totaltotal 100% 41 / 41 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Run.pm ↑ Summary Run/Core_GplArt.pm »
1 package Test::Run::Base::Struct;
2  
3 19 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 19 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 Test::Run::Base::Struct - base class for Test::Run's "structs", that are
9 simple classes that hold several values.
10  
11 =head1 DESCRIPTION
12  
13 Inherits from L<Test::Run::Base>.
14  
15 =cut
16  
17 19 ▶use MRO::Compat;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 19 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 # We need to put it here before the use MooseX::StrictConstructor due
21 # to a Moose mis-feature. Thanks to doy.
22 BEGIN
23 19 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
24 19 extends('Test::Run::Base');
25 }
26  
27 19 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29  
30 sub _pre_init
31 286 ▶{
Subroutine _pre_init: called CC=1 SCAR=0.0
32 }
33  
34 19 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 =head2 BUILD
37  
38 For Moose.
39  
40 =cut
41  
42 sub BUILD
43 538 ▶{
Subroutine BUILD: called CC=1 SCAR=0.0
Pod documented
44 538 my $self = shift;
45  
46 =begin debugging_code
47  
48 Carp::confess '$args not a hash' if (ref($args) ne "HASH");
49  
50 =end debugging_code
51  
52 =cut
53  
54 538 $self->_pre_init();
55  
56 538 return;
57 }
58  
59 =head1 METHODS
60  
61 =head2 $struct->inc_field($field_name)
62  
63 Increment the slot $field_name by 1.
64  
65 =cut
66  
67 sub inc_field
68 519 ▶{
Subroutine inc_field: called CC=1 SCAR=0.0
Pod documented
69 519 my ($self, $field) = @_;
70 519 return $self->add_to_field($field, 1);
71 }
72  
73 =head2 $struct->add_to_field($field_name, $difference)
74  
75 Add $difference to the slot $field_name.
76  
77 =cut
78  
79 sub add_to_field
80 521 ▶{
Subroutine add_to_field: called CC=1 SCAR=0.0
Pod documented
81 521 my ($self, $field, $diff) = @_;
82 521 $self->$field($self->$field()+$diff);
83 }
84  
85 19 1;
86  
87 __END__
« Run.pm ↑ Summary Run/Core_GplArt.pm »