blib/lib/Dallycot/Value.pm

filter: Statementstmt 71.1% 37 / 52 Branchbran n/a Conditioncond 16.6% 2 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 61.9% 13 / 21 Podpod 0.0% 0 / 14 totaltotal 48.6% 52 / 107 CC 5 SCAR 8.1
CC
5
Cov
61%
to_json
6.0
to_string
6.0
types
2.5
CRAP 2.2
« blib/lib/Dallycot/AST/Defined.pm ↑ Summary blib/lib/Dallycot/Processor/PP.pm »
1 package Dallycot::Value;
2 30 our $AUTHORITY = 'cpan:JSMITH';
3  
4 # ABSTRACT: Abstract type representing a value
5  
6 30 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 30 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 30 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 30 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 use Module::Pluggable
13 30 require => 1,
14 sub_name => '_types',
15 30 ▶ search_path => 'Dallycot::Value';
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 30 ▶use Promises qw(deferred);
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 30 our @TYPES;
20  
21 sub types {
22 30 ▶ return @TYPES = @TYPES || shift->_types;
Subroutine types: called CC=2 SCAR=9.2
Pod undocumented
Condition33%1/3
@Dallycot::Value::TYPES || (shift())->_types
l!l&&r!l&&!r
0300
MC/DC0%0/2
@Dallycot::Value::TYPES || (shift())->_types
@Dallycot::Value::TYPES (shift())->_types
Truth table33%1/3
A || B
A= @Dallycot::Value::TYPESB= (shift())->_types
ABresult
1X1
011
000
23 }
24  
25 30 __PACKAGE__->types;
26  
27 53 ▶sub is_lambda {return}
Subroutine is_lambda: called CC=1 SCAR=0.0
Pod undocumented
28  
29 0 ▶sub is_defined {return}
Subroutine is_defined: not called CC=1 SCAR=6.9
Pod undocumented
30  
31 0 ▶sub is_empty { return 1 }
Subroutine is_empty: not called CC=1 SCAR=6.9
Pod undocumented
32  
33 sub check_for_common_mistakes {
34 0 ▶ return ();
Subroutine check_for_common_mistakes: not called CC=1 SCAR=6.9
Pod undocumented
35 }
36  
37 sub as_text {
38 0 ▶ my ($self) = @_;
Subroutine as_text: not called CC=1 SCAR=6.9
Pod undocumented
39 0 return $self->to_string;
40 }
41  
42 sub type {
43 171 ▶ my ($self) = @_;
Subroutine type: called CC=1 SCAR=0.0
Pod undocumented
44  
45 171 return Dallycot::Value::Set->new(
46 Dallycot::Value::URI->new( 'http://www.dallycot.net/ns/types/1.0/' . $self->_type ) );
47 }
48  
49 sub _type {
50 171 ▶ my ($class) = @_;
Subroutine _type: called CC=2 SCAR=7.2
51  
52 171 ▶ $class = ref $class || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
17100
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
53  
54 171 my $type = substr( $class, CORE::length(__PACKAGE__) + 2 );
55 171 $type =~ s/::/-/;
56 171 return $type;
57 }
58  
59 sub simplify {
60 0 ▶ my ($self) = @_;
Subroutine simplify: not called CC=1 SCAR=6.9
Pod undocumented
61  
62 0 return $self;
63 }
64  
65 sub to_json {
66 0 ▶ my ($self) = @_;
Subroutine to_json: not called CC=2 SCAR=17.9
Pod undocumented
67  
68 0 ▶ croak "to_json not defined for " . ( blessed($self) || $self );
Condition0%0/3
blessed($self) || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
blessed($self) || $self
blessed($self) $self
Truth table0%0/3
A || B
A= blessed($self)B= $self
ABresult
1X1
011
000
69 }
70  
71 sub to_string {
72 0 ▶ my ($self) = @_;
Subroutine to_string: not called CC=2 SCAR=17.9
Pod undocumented
73  
74 0 ▶ croak "to_string not defined for " . ( blessed($self) || $self );
Condition0%0/3
blessed($self) || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
blessed($self) || $self
blessed($self) $self
Truth table0%0/3
A || B
A= blessed($self)B= $self
ABresult
1X1
011
000
75 }
76  
77 55 ▶sub child_nodes { return () }
Subroutine child_nodes: called CC=1 SCAR=0.0
Pod undocumented
78  
79 55 ▶sub identifiers { return () }
Subroutine identifiers: called CC=1 SCAR=0.0
Pod undocumented
80  
81 sub calculate_length {
82 0 ▶ my ( $self, $engine ) = @_;
Subroutine calculate_length: not called CC=1 SCAR=6.9
Pod undocumented
83  
84 0 my $d = deferred;
85  
86 0 $d->resolve( $engine->ZERO );
87  
88 0 return $d->promise;
89 }
90  
91 sub execute {
92 893 ▶ my ( $self, $engine ) = @_;
Subroutine execute: called CC=1 SCAR=0.0
Pod undocumented
93  
94 893 my $d = deferred;
95  
96 893 $d->resolve($self);
97  
98 893 return $d->promise;
99 }
100  
101 30 1;
« blib/lib/Dallycot/AST/Defined.pm ↑ Summary blib/lib/Dallycot/Processor/PP.pm »