M4/Impl/Macro.pm

filter: Statementstmt 100% 177 / 177 Branchbran 52.6% 20 / 38 Conditioncond 77.7% 7 / 9 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 52 / 52 Podpod n/a totaltotal 92.1% 258 / 280 CC 23 SCAR 10.9
CC
23
Cov
91%
macro_paramCanBeMacro
10.5
macro_clone
6.2
macro_needParams
3.0
CRAP 3.0
« M4.pm ↑ Summary M4/Impl/Macros.pm »
1 4 ▶use Moops;
Subroutine __ANON__: called CC=1 SCAR=0.0
2  
3 # PODNAME: MarpaX::Languages::M4::Impl::Macro
4  
5 # ABSTRACT: M4 Macro generic implementation
6 4  
7 4 ▶class MarpaX::Languages::M4::Impl::Macro {
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 our $VERSION = '0.020'; # VERSION
10  
11 4 our $AUTHORITY = 'cpan:JDDPAUSE'; # AUTHORITY
12  
13 4 ▶ use MarpaX::Languages::M4::Role::Macro;
Subroutine __ANON__: called CC=1 SCAR=0.0
14 2 ▶ use MarpaX::Languages::M4::Type::Macro -all;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
15 3 ▶ use MooX::HandlesVia;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
16 3 ▶ use Types::Common::Numeric -all;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
17  
18 4 has name => (
19 is => 'rw',
20 isa => Str,
21 required => 1
22 );
23 4 has stub => (
24 is => 'rw',
25 isa => CodeRef,
26 required => 1,
27 handles_via => 'Code',
28 handles => { macro_execute => 'execute' }
29 );
30 4 has expansion => (
31 is => 'rw',
32 isa => Undef | Str,
33 required => 1
34 );
35 4 has needParams => (
36 is => 'rw',
37 isa => Bool,
38 default => false
39 );
40 has paramCanBeMacro => (
41 is => 'rw',
42 isa => HashRef [ PositiveOrZeroInt | Enum [qw/*/] ],
43 6843 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
44 6843 {};
45 },
46 4 handles_via => 'Hash',
47 handles => {
48 _paramCanBeMacro_get => 'get',
49 _paramCanBeMacro_exists => 'exists',
50 #
51 # We do not hold references in values, so shallow_clone
52 # is a real clone
53 #
54 _paramCanBeMacro_clone => 'shallow_clone'
55 }
56 );
57 has postMatchLength => (
58 is => 'rw',
59 isa => CodeRef,
60 6843 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
61 2310 ▶ sub { return 0; }
Subroutine __ANON__: called CC=1 SCAR=0.0
62 6843 },
63 4 handles_via => 'Code',
64 handles => { macro_postMatchLengthExecute => 'execute' }
65 );
66  
67 3 ▶ method macro_name (--> Str) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine macro_name: called CC=3 SCAR=11.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 2 branches
BranchTrueFalseTotal
@_ ? : 4 0 4
if @_ != 0 0 4 4
68 4 return $self->name;
69 }
70  
71 3 ▶ method macro_expansion (--> Undef | Str) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine macro_expansion: called CC=3 SCAR=11.1
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 2 branches
BranchTrueFalseTotal
@_ ? : 62 0 62
if @_ != 0 0 62 62
72 62 return $self->expansion;
73 }
74  
75 3 ▶ method macro_needParams (--> Bool ) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine macro_needParams: called CC=3 SCAR=11.1
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 2 branches
BranchTrueFalseTotal
@_ ? : 589 0 589
if @_ != 0 0 589 589
76 589 return $self->needParams;
77 }
78  
79 3 ▶ method macro_isBuiltin (--> Bool) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine macro_isBuiltin: called CC=3 SCAR=11.1
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 2 branches
BranchTrueFalseTotal
@_ ? : 81 0 81
if @_ != 0 0 81 81
80 81 return Undef->check( $self->expansion );
81 }
82  
83 3 ▶ method macro_paramCanBeMacro (PositiveOrZeroInt $paramPos --> Bool) {
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine macro_paramCanBeMacro: called CC=10 SCAR=23.5
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=1 SCAR=0.1
Branch: 5 branches
BranchTrueFalseTotal
@_ ? : 17 0 17
if @_ != 1 0 17 17
$#_ >= 0 ? : 17 0 17
if ($#_ >= 0) 17 0 17
Type::Tiny::XS::PositiveOrZeroInt($paramPos) or _failed_check(48, "PositiveOrZeroInt", $paramPos, "exception_class", "Error::TypeTiny::Assertion") 17 0 17
84 17 ▶ if (( $self->_paramCanBeMacro_exists($paramPos)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_paramCanBeMacro_exists($paramPos) and $self->_paramCanBeMacro_get($paramPos) or $self->_paramCanBeMacro_exists('*') and $self->_paramCanBeMacro_get('*')) { } 14 3 17
Condition77%7/9
$self->_paramCanBeMacro_exists($paramPos) and $self->_paramCanBeMacro_get($paramPos) or $self->_paramCanBeMacro_exists("*") and $self->_paramCanBeMacro_get("*")
l!l&&r!l&&!r
953
$self->_paramCanBeMacro_exists($paramPos) and $self->_paramCanBeMacro_get($paramPos)
!ll&&!rl&&r
809
$self->_paramCanBeMacro_exists("*") and $self->_paramCanBeMacro_get("*")
!ll&&!rl&&r
305
MC/DC50%2/4
$self->_paramCanBeMacro_exists($paramPos) and $self->_paramCanBeMacro_get($paramPos) or $self->_paramCanBeMacro_exists("*") and $self->_paramCanBeMacro_get("*")
$self->_paramCanBeMacro_exists($paramPos) $self->_paramCanBeMacro_get($paramPos) $self->_paramCanBeMacro_exists("*") $self->_paramCanBeMacro_get("*")
Truth table42%3/7
A and B or C and D
A= $self->_paramCanBeMacro_exists($paramPos)B= $self->_paramCanBeMacro_get($paramPos)C= $self->_paramCanBeMacro_exists("*")D= $self->_paramCanBeMacro_get("*")
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
85 && $self->_paramCanBeMacro_get($paramPos)
86 )
87 || ( $self->_paramCanBeMacro_exists('*')
88 && $self->_paramCanBeMacro_get('*') )
89 )
90 {
91 14 return true;
92 }
93 else {
94 3 return false;
95 }
96 }
97  
98 3 ▶ method macro_clone (Str $name --> M4Macro) {
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine macro_clone: called CC=6 SCAR=18.3
Branch: 5 branches
BranchTrueFalseTotal
@_ ? : 8 0 8
if @_ != 1 0 8 8
$#_ >= 0 ? : 8 0 8
if ($#_ >= 0) 8 0 8
Type::Tiny::XS::Str($name) or _failed_check(9, "Str", $name, "exception_class", "Error::TypeTiny::Assertion") 8 0 8
99 8 my $macro = __PACKAGE__->new(
100 name => $name,
101 stub => $self->stub,
102 needParams => $self->needParams,
103 #
104 # Cloning a builtin is a builtin
105 #
106 expansion => $self->expansion,
107 #
108 # No need of clone: the hash is ro once created
109 #
110 paramCanBeMacro => $self->_paramCanBeMacro_clone,
111 postMatchLength => $self->postMatchLength
112 );
113  
114 8 return $macro;
115 }
116  
117 4 with 'MarpaX::Languages::M4::Role::Macro';
118 }
119  
120 4 1;
121  
122 __END__
« M4.pm ↑ Summary M4/Impl/Macros.pm »