| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 5 | ▶ | if( $_[$i] eq 'debug' || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$_[$i] eq "debug" or $_[$i] eq "debug_code" or $_[$i] eq "debug_file" or $_[$i] eq "no_filter"
$_[$i] eq "debug" or $_[$i] eq "debug_code" or $_[$i] eq "debug_file"
$_[$i] eq "debug" or $_[$i] eq "debug_code"
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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 6 | ▶ | $hash->{no_filter} = 0 if( !CORE::exists( $hash->{no_filter} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 6 | ▶ | $hash->{debug_code} = 0 if( !CORE::exists( $hash->{debug_code} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 6 | ▶ | Filter::Util::Call::filter_add( bless( $hash => ( ref( $class ) || $class ) ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 3 | my $type = lc( ref( $ref ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 3 | ▶ | if( $type !~ /^(array|hash|scalar)$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | warnings::warn( "Unsupported variable type '$type': '$ref'\n" ) if( warnings::enabled() || $DEBUG ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
warnings::enabled() or $DEBUG
MC/DC0%0/2
warnings::enabled() or $DEBUG
warnings::enabled()
$DEBUG
Truth table0%0/3
A or B
A= warnings::enabled()B= $DEBUG
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||