C/Constant.pm

filter: Statementstmt 100% 29 / 29 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 95.4% 42 / 44 CC 5 SCAR 6.6
CC
5
Cov
95%
__ANON__
3.0
__ANON__
2.1
__ANON__
2.0
CRAP 1.9
« C.pm ↑ Summary
1 package Const::Introspect::C::Constant;
2  
3 2 ▶use 5.020;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use experimental qw( signatures );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # ABSTRACT: Class representing a C/C++ constant
8 2 our $VERSION = '0.01'; # VERSION
9  
10  
11 2 has c => (
12 is => 'ro',
13 required => 1,
14 );
15  
16  
17 2 has name => (
18 is => 'ro',
19 required => 1,
20 );
21  
22  
23 2 has raw_value => (
24 is => 'ro',
25 );
26  
27  
28 has value => (
29 is => 'ro',
30 lazy => 1,
31 9 ▶ default => sub ($self) {
Subroutine __ANON__: called CC=3 SCAR=11.0
32 9 my $type = $self->type;
33 $type eq 'other'
34 ? undef
35 9 ▶ : do {
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'other' ? : 2 7 9
36 7 local $@ = '';
37 7 my $value = eval { $self->c->compute_expression_value($type, $self->name) };
38 # TODO: diagnostic on `fail`
39 7 ▶ $@ ? undef : $value;
Branch: 1 branch
BranchTrueFalseTotal
$@ ? : 0 7 7
40 };
41 },
42 2 );
43  
44  
45 has type => (
46 is => 'ro',
47 16 ▶ isa => sub {
Subroutine __ANON__: called CC=2 SCAR=7.6
48 16 ▶ die "type should be one of: string, int, long, pointer, float, double or other"
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0] =~ /^(string|int|long|pointer|float|double|other)$/u 0 16 16
49 unless $_[0] =~ /^(string|int|long|pointer|float|double|other)$/;
50 },
51 lazy => 1,
52 9 ▶ default => sub ($self) {
Subroutine __ANON__: called CC=2 SCAR=6.9
53 9 local $@ = '';
54 9 my $type = eval { $self->c->compute_expression_type($self->name) };
55 # TODO: diagnostic on `other`
56 9 ▶ $@ ? 'other' : $type;
Branch: 1 branch
BranchTrueFalseTotal
$@ ? : 2 7 9
57 },
58 2 );
59  
60 2 ▶no Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
61  
62 2 1;
63  
64 __END__
« C.pm ↑ Summary