Promise.pm

filter: Statementstmt 88.8% 40 / 45 Branchbran 50.0% 8 / 16 Conditioncond 26.6% 4 / 15 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 87.5% 7 / 8 Podpod n/a totaltotal 64.1% 59 / 92 CC 15 SCAR 24.5
CC
15
Cov
68%
import
19.1
__ANON__
7.7
BEGIN
1.0
CRAP 11.6
↑ Summary Scalar.pm »
1 ##----------------------------------------------------------------------------
2 ## Class Generic - ~/lib/Class/Promise.pm
3 ## Version v0.1.0
4 ## Copyright(c) 2022 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2022/03/08
7 ## Modified 2022/03/08
8 ## All rights reserved
9 ##
10 ## This program is free software; you can redistribute it and/or modify it
11 ## under the same terms as Perl itself.
12 ##----------------------------------------------------------------------------
13 package Class::Promise;
14 BEGIN
15 6 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
16 6 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 6 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 6 ▶ use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 6 ▶ use parent qw( Promise::Me );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 6 our @EXPORT_OK = @Promise::Me::EXPORT_OK;
21 6 our %EXPORT_TAGS = %Promise::Me::EXPORT_TAGS;
22 6 our @EXPORT = @Promise::Me::EXPORT;
23 6 ▶ our $VERSION = 'v0.1.0';
Subroutine BEGIN: not called CC=1 SCAR=0.0
24 };
25  
26 sub import
27 6 ▶{
Subroutine import: called CC=11 SCAR=29.5
28 6 my $class = shift( @_ );
29 6 my $hash = {};
30 6 ▶ for( my $i = 0; $i < scalar( @_ ); $i++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @_) 5 6 11
31 {
32 5 ▶ if( $_[$i] eq 'debug' ||
Branch: 1 branch
BranchTrueFalseTotal
if ($_[$i] eq "debug" or $_[$i] eq "debug_code" or $_[$i] eq "debug_file" or $_[$i] eq "no_filter") 0 5 5
Condition33%3/9
$_[$i] eq "debug" or $_[$i] eq "debug_code" or $_[$i] eq "debug_file" or $_[$i] eq "no_filter"
l!l&&r!l&&!r
005
$_[$i] eq "debug" or $_[$i] eq "debug_code" or $_[$i] eq "debug_file"
l!l&&r!l&&!r
005
$_[$i] eq "debug" or $_[$i] eq "debug_code"
l!l&&r!l&&!r
005
MC/DC0%0/4
$_[$i] eq "debug" or $_[$i] eq "debug_code" or $_[$i] eq "debug_file" or $_[$i] eq "no_filter"
$_[$i] eq "debug" $_[$i] eq "debug_code" $_[$i] eq "debug_file" $_[$i] eq "no_filter"
Truth table20%1/5
A or B or C or D
A= $_[$i] eq "debug"B= $_[$i] eq "debug_code"C= $_[$i] eq "debug_file"D= $_[$i] eq "no_filter"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
33 $_[$i] eq 'debug_code' ||
34 $_[$i] eq 'debug_file' ||
35 $_[$i] eq 'no_filter' )
36 {
37 0 $hash->{ $_[$i] } = $_[$i+1];
38 0 CORE::splice( @_, $i, 2 );
39 0 $i--;
40 }
41 }
42 # $class->export_to_level( 1, @_ );
43 6 Promise::Me->export_to_level( 1, @_ );
44 #local $Exporter::ExportLevel = 1;
45 6 $class->SUPER::import( @_ );
46 #Promise::Me->SUPER::import( @_ );
47 # $class->export_to_level( 1, @_ );
48 6 ▶ $hash->{debug} = 0 if( !CORE::exists( $hash->{debug} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $hash->{"debug"} 6 0 6
49 6 ▶ $hash->{no_filter} = 0 if( !CORE::exists( $hash->{no_filter} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $hash->{"no_filter"} 6 0 6
50 6 ▶ $hash->{debug_code} = 0 if( !CORE::exists( $hash->{debug_code} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $hash->{"debug_code"} 6 0 6
51 6 ▶ Filter::Util::Call::filter_add( bless( $hash => ( ref( $class ) || $class ) ) );
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
060
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
52 6 my $caller = caller;
53 6 my $pm = 'Promise::Me';
54 6 for( qw( ARRAY HASH SCALAR ) )
55 {
56 18 *{"${caller}\::MODIFY_${_}_ATTRIBUTES"} = sub
57 3 ▶ {
Subroutine __ANON__: called CC=5 SCAR=20.4
58 3 my( $pack, $ref, $attr ) = @_;
59 {
60 3 ▶ if( $attr eq 'Promise_shared' )
Branch: 1 branch
BranchTrueFalseTotal
if ($attr eq "Promise_shared") 3 0 3
61 {
62 3 my $type = lc( ref( $ref ) );
63 3 ▶ if( $type !~ /^(array|hash|scalar)$/ )
Branch: 1 branch
BranchTrueFalseTotal
unless ($type =~ /^(array|hash|scalar)$/) 0 3 3
64 {
65 0 ▶ warnings::warn( "Unsupported variable type '$type': '$ref'\n" ) if( warnings::enabled() || $DEBUG );
Branch: 1 branch
BranchTrueFalseTotal
if warnings::enabled() or $DEBUG 0 0 0
Condition0%0/3
warnings::enabled() or $DEBUG
l!l&&r!l&&!r
000
MC/DC0%0/2
warnings::enabled() or $DEBUG
warnings::enabled() $DEBUG
Truth table0%0/3
A or B
A= warnings::enabled()B= $DEBUG
ABresult
1X1
011
000
66 0 return;
67 }
68 3 &{"${pm}\::share"}( $ref );
69 }
70 }
71 3 return;
72 18 };
73 }
74 }
75  
76 6 1;
77  
78 __END__
↑ Summary Scalar.pm »