Any.pm

filter: Statementstmt 93.7% 30 / 32 Branchbran 83.3% 5 / 6 Conditioncond 50.0% 4 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 100% 8 / 8 Podpod 50.0% 1 / 2 totaltotal 78.6% 48 / 61 SCAR 21.1
CC
8
Cov
85%
implementation
4.4
new_context
4.2
__ANON__
2.0
CRAP 8.2
« Any/Context/JE.pm ↑ Summary Any/Context/Duktape.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;
6  
7 1 our $AUTHORITY = 'cpan:TOBYINK';
8 1 our $VERSION = '0.001';
9  
10 1 ▶use Exporter::Shiny qw( jseval );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub _generate_jseval {
13 1 ▶ my $me = shift;
Subroutine _generate_jseval: called CC=1 SCAR=0.0
14 1 my ($name, $args) = @_;
15 return sub {
16 1 ▶ my $code = shift;
Subroutine __ANON__: called CC=2 SCAR=7.1
17 1 ▶ my $ctx = $me->new_context($args or {});
Condition50%1/2
$args || {}
l!l
01
MC/DC0%0/1
$args || {}
$args
Truth table50%1/2
A
A= $args
Aresult
11
00
18 1 $ctx->eval($code);
19 1 };
20 }
21  
22 1 my $IMPLEMENTATION;
23 1 my @IMPLEMENTATIONS = qw(
24 JavaScript::Any::Context::V8
25 JavaScript::Any::Context::Duktape
26 JavaScript::Any::Context::JE
27 );
28  
29 sub new_context {
30 2 ▶ my $me = shift;
Subroutine new_context: called CC=4 SCAR=14.5
Pod documented
31 2 ▶ my $args = ref($_[0]) eq 'HASH' ? $_[0] : +{ @_ };
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 1 1 2
32
33 my $impl = delete($args->{implementation})
34 2 ▶ || ($IMPLEMENTATION ||= $me->implementation);
Condition50%3/6
delete $args->{'implementation'} || ($IMPLEMENTATION ||= $me->implementation)
l!l&&r!l&&!r
020
$IMPLEMENTATION ||= $me->implementation
l!l&&r!l&&!r
110
MC/DC0%0/2
delete $args->{'implementation'} || ($IMPLEMENTATION ||= $me->implementation)
delete $args->{'implementation'} ($IMPLEMENTATION ||= $me->implementation)
MC/DC0%0/2
$IMPLEMENTATION ||= $me->implementation
$IMPLEMENTATION $me->implementation
Truth table33%1/3
A || B
A= delete $args->{'implementation'}B= ($IMPLEMENTATION ||= $me->implementation)
ABresult
1X1
011
000
Truth table66%2/3
A ||= B
A= $IMPLEMENTATIONB= $me->implementation
ABresult
1X1
011
000
35
36 # ehhh, should probably load $impl.
37
38 2 $impl->new($args);
39 }
40  
41 sub implementation {
42 1 ▶ return $IMPLEMENTATION if defined $IMPLEMENTATION;
Subroutine implementation: called CC=4 SCAR=14.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if defined $IMPLEMENTATION 0 1 1
43
44 1 for my $try (@IMPLEMENTATIONS) {
45 3 ▶ eval "require $try" or next;
Branch: 1 branch
BranchTrueFalseTotal
eval "require $try" or next 2 1 3
46 1 return $try;
47 }
48
49 0 require Carp;
50 0 Carp::croak("No Javascript implementation available. Please install JavaScript::Duktape or JE");
51 }
52  
53 1 1;
54  
55 __END__
« Any/Context/JE.pm ↑ Summary Any/Context/Duktape.pm »