Any/Context/JE.pm

filter: Statementstmt 81.0% 47 / 58 Branchbran 56.2% 9 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 91.6% 11 / 12 Podpod 0.0% 0 / 4 totaltotal 74.4% 67 / 90 SCAR 23.2
CC
9
Cov
76%
define
14.8
max_ops
2.0
BEGIN
1.0
CRAP 10.2
« Any/Context.pm ↑ Summary Any.pm »
1 1 ▶use 5.008003;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package JavaScript::Any::Context::JE;
6  
7 1 our $AUTHORITY = 'cpan:TOBYINK';
8 1 our $VERSION = '0.001';
9  
10 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Class::Tiny qw( _engine );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Role::Tiny::With;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 with qw( JavaScript::Any::Context );
14  
15 1 use Ref::Util qw(
16 is_plain_arrayref is_plain_hashref is_ref
17 is_blessed_ref is_plain_coderef
18 1 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use JE qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 sub BUILD {
22 2 ▶ my $self = shift;
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
23 2 my ($args) = @_;
24  
25 $self->_engine("JE"->new(
26 max_ops => $args->{max_ops},
27 2 ));
28
29 2 return;
30 }
31  
32 # delegated methods
33 2 ▶sub eval { shift->_engine->eval(@_) }
Subroutine eval: called CC=1 SCAR=0.0
Pod undocumented
34 0 ▶sub max_ops { shift->_engine->max_ops(@_) }
Subroutine max_ops: not called CC=1 SCAR=6.9
Pod undocumented
35  
36 sub define {
37 2 ▶ my $self = shift;
Subroutine define: called CC=9 SCAR=26.9
Pod undocumented
38 2 my ($name, $value) = @_;
39
40 2 $self->_throw_if_bad_name($name);
41
42 # XXX
43 # need to install a wrapper
44 # to process params and return values
45
46 2 ▶ if (is_plain_coderef($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (Ref::Util::XS::is_plain_coderef($value)) 1 1 2
47 1 $self->_engine->new_function($name, $value);
48 1 return;
49 }
50
51 1 ▶ if (is_plain_hashref($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (Ref::Util::XS::is_plain_hashref($value)) 0 1 1
52 0 ...;
53 }
54
55 1 ▶ if (is_plain_arrayref($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (Ref::Util::XS::is_plain_arrayref($value)) 0 1 1
56 0 ...;
57 }
58
59 1 ▶ if (is_blessed_ref($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (Ref::Util::XS::is_blessed_ref($value)) 0 1 1
60 0 ...;
61 }
62
63 1 ▶ if ($self->is_true($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_true($value)) 0 1 1
64 0 $self->_engine->prop({ name => $name, value => $self->_engine->true });
65 0 return;
66 }
67
68 1 ▶ if ($self->is_false($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_false($value)) 0 1 1
69 0 $self->_engine->prop({ name => $name, value => $self->_engine->false });
70 0 return;
71 }
72
73 1 ▶ if ($self->is_null($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_null($value)) 0 1 1
74 0 $self->_engine->prop({ name => $name, value => $self->_engine->null });
75 0 return;
76 }
77
78 1 ▶ if (not is_ref($value)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (Ref::Util::XS::is_ref($value)) 1 0 1
79 1 $self->_engine->prop({ name => $name, value => $self->_engine->upgrade($value) });
80 1 return;
81 }
82
83 0 $self->_throw_because_bad_value($value);
84 }
85  
86 1 1;
87  
« Any/Context.pm ↑ Summary Any.pm »