| 1 | package Spreadsheet::Reader::Format::ParseExcelFormatStrings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | our $AUTHORITY = 'cpan:JANDREW'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use version; our $VERSION = version->declare('v0.6.4'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ###LogSD warn "You uncovered internal logging statements for Spreadsheet::Reader::Format::ParseExcelFormatStrings-$VERSION"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | requires qw( get_defined_excel_format ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | ###LogSD requires 'get_all_space', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Types::Standard qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | Int Str Maybe | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | Num HashRef ArrayRef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | CodeRef Object ConsumerOf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | InstanceOf HasMethods Bool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | is_Object is_Num is_Int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use Carp qw( confess longmess ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use Type::Coercion; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use Type::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use DateTimeX::Format::Excel 0.014; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | use DateTime::Format::Flexible; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | ▶ | use DateTime; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use Clone 'clone'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | use lib '../../../../lib',; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | #~ ###LogSD use Capture::Tiny 'capture_stderr'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | ###LogSD use Log::Shiras::Telephone; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ###LogSD use Log::Shiras::Unhide; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | ▶ | use Spreadsheet::Reader::Format::Types qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | PositiveNum NegativeNum ZeroOrUndef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | NotNegativeNum Excel_number_0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | );# | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | #########1 Dispatch Tables & Package Variables 5#########6#########7#########8#########9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | my $coercion_index = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | my @type_list = ( PositiveNum, NegativeNum, ZeroOrUndef, Str ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 2 | my $last_date_cldr = 'yyyy-mm-dd';# This is critical to getting the next string to date conversion right | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | my $last_duration = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 2 | my $last_sub_seconds = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | my $last_format_rem = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | my $duration_order ={ h => 'm', m =>'s', s =>'0' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | my $number_build_dispatch ={ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | all =>[qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | _convert_negative | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | _divide_by_thousands | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | _convert_to_percent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | _split_decimal_integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | _move_decimal_point | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | _build_fraction | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | _round_decimal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | _add_commas | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | _pad_exponent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | scientific =>[qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | _convert_negative | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | _split_decimal_integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | _move_decimal_point | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | _round_decimal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | _add_commas | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | _pad_exponent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | percent =>[qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | _convert_negative | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | _convert_to_percent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | _split_decimal_integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | _round_decimal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | _add_commas | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | fraction =>[qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | _convert_negative | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | _split_decimal_integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | _build_fraction | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | _add_commas | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | integer =>[qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | _convert_negative | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | _divide_by_thousands | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | _split_decimal_integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | _round_decimal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | _add_commas | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | decimal =>[qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | _convert_negative | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | _divide_by_thousands | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | _split_decimal_integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | _round_decimal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | _add_commas | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | #########1 Public Attributes 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 2 | has workbook_inst =>( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | isa => 'Spreadsheet::Reader::ExcelXML::Workbook', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | handles =>[ qw( set_error get_epoch_year )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | writer => 'set_workbook_inst', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | predicate => '_has_workbook_inst', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 2 | has cache_formats =>( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | isa => Bool, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | reader => 'get_cache_behavior', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | writer => 'set_cache_behavior', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | default => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 2 | has datetime_dates =>( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | isa => Bool, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | reader => 'get_date_behavior', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | writer => 'set_date_behavior', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | default => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | has european_first =>( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | isa => Bool, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | reader => 'get_european_first', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | writer => 'set_european_first', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | default => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | #########1 Public Methods 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 38 | ▶ | sub get_defined_conversion{# Add a test for this function in 08-parse... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_defined_conversion: called CC=4 SCAR=15.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 38 | my( $self, $position, $target_name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | ###LogSD $self->get_all_space . '::get_defined_conversion', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | ###LogSD "Searching for the coercion for position: $position", ($target_name ? "With suggested name: $target_name" : '') ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 38 | my $coercion_string = $self->get_defined_excel_format( $position ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 38 | ▶ | if( !defined $coercion_string ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $self->set_error( "No coercion available for position: $position" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ###LogSD "Position -$position- is associated with the string: $coercion_string", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 38 | ▶ | my $coercion = $self->parse_excel_format_string( $coercion_string, ($target_name//"Excel__$position") ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$target_name // "Excel__$position"
MC/DC100%1/1
$target_name // "Excel__$position"
$target_name
Truth table100%2/2
A
A= $target_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 38 | ▶ | if( !$coercion ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $self->set_error( "Unparsable conversion string at position -$position- found: $coercion_string" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | ###LogSD my $level = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | #~ ###LogSD $position == 164 ? 'fatal' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | ###LogSD 'trace'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | ###LogSD $phone->talk( level => $level, message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | ###LogSD 'Returning coercion:', $coercion,] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 38 | return $coercion; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 105 | ▶ | sub parse_excel_format_string{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_excel_format_string: called CC=58 SCAR=42.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 105 | my( $self, $format_strings, $coercion_name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | ###LogSD $self->get_all_space . '::parse_excel_format_string', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 105 | ▶ | if( !defined $format_strings ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | ###LogSD "Nothing passed to convert",] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | return Excel_number_0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 105 | $format_strings =~ s/\\//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | ###LogSD "parsing the custom excel format string: $format_strings", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | ###LogSD ($coercion_name ? "With passed name: $coercion_name" : '')] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 105 | my $conversion_type = 'number'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # Check the cache | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 105 | my $cache_key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 105 | ▶ | if( $self->get_cache_behavior ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | ###LogSD "checking stored cache of the key: $format_strings", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | ###LogSD '..searching in stored keys:', keys %{$self->_get_all_format_cache} ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 105 | $cache_key = $format_strings; # TODO fix the non-hashkey character issues; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 105 | ▶ | if( $self->_has_cached_format( $cache_key ) ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | ###LogSD "Format already built - returning stored value for: $cache_key", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 6 | return $self->_get_cached_format( $cache_key ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | ###LogSD "Building new format for key: $cache_key", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | # Split into the four sections positive, negative, zero, and text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 99 | $format_strings =~ s/General/\@/ig;# Change General to text input | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 99 | my @format_string_list = split /;/, $format_strings; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 99 | ▶ | my $last_is_text = ( $format_string_list[-1] =~ /^[A-Za-z\@\s\"]*$/ ) ? 1 : 0 ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | ###LogSD "Is the last position text: $last_is_text", scalar( @format_string_list ) ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | # Make sure the full range of number inputs are sent down the right path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 99 | my @used_type_list = @{\@type_list}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 99 | ▶ | pop @used_type_list if !$last_is_text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 99 | ▶ | if( scalar( @format_string_list ) == ( 2 + $last_is_text ) ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 17 | $used_type_list[0] = NotNegativeNum;#Maybe[NotNegativeNum]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 17 | splice( @used_type_list, 2, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | }elsif( scalar( @format_string_list ) == ( 1 + $last_is_text ) ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 70 | $used_type_list[0] = Num;#Maybe[Num]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 70 | splice( @used_type_list, 1, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | }elsif( scalar( @format_string_list ) == ( 0 + $last_is_text ) ){# Generally only true for text only formats | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 4 | @used_type_list = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 4 | $used_type_list[0] = Str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 4 | $conversion_type = 'text'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | ###LogSD "Now operating on each format string", @format_string_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | ###LogSD '..with used type list:', map{ $_->name } @used_type_list, ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 99 | my $format_position = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 99 | my @coercion_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | my $action_type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 99 | my $is_date = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 99 | my $date_text = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 99 | my $last_deconstructed_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 99 | for my $format_string ( @format_string_list ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 145 | $format_string =~ s/_.//g;# no character justification to other rows | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 145 | $format_string =~ s/\*//g;# Remove the repeat character listing (not supported here) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | ###LogSD "Building format for: $format_string", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | # Pull out all the straight through stuff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 145 | my @deconstructed_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 145 | my $x = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | #~ $action_type = undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 145 | ▶ | while( defined $format_string and my @result = $format_string =~ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $format_string and my(@result) = $format_string =~ /^( # Collect any formatting stuff first
(AM\/PM| # Date 12 hr flag
A\/P| # Another date 12 hr flag
\[hh?\]| # Elapsed hours
\[mm\]| # Elapsed minutes
\[ss\]| # Elapsed seconds
[dmyhms]+)| # DateTime chunks
([0-9#\?]+[,\-\_]?[#0\?]*,*| # Number string
\.| # Split integers from decimals
[Ee][+\-]| # Exponential notiation
%)| # Percentage
(\@) # Text input
)?( # Finish collecting format actions
(\"[^\"]*\")| # Anything in quotes just passes through
(\[[^\]]*\])| # Anything in brackets needs modification
[\(\)\$\-\+\/\:\!\^\&\'\~\{\}\<\>\=\s]| # All the pass through characters
\,\s # comma space for verbal separation
)?(.*)/x
MC/DC0%0/2
defined $format_string and my(@result) = $format_string =~ /^( # Collect any formatting stuff first
(AM\/PM| # Date 12 hr flag
A\/P| # Another date 12 hr flag
\[hh?\]| # Elapsed hours
\[mm\]| # Elapsed minutes
\[ss\]| # Elapsed seconds
[dmyhms]+)| # DateTime chunks
([0-9#\?]+[,\-\_]?[#0\?]*,*| # Number string
\.| # Split integers from decimals
[Ee][+\-]| # Exponential notiation
%)| # Percentage
(\@) # Text input
)?( # Finish collecting format actions
(\"[^\"]*\")| # Anything in quotes just passes through
(\[[^\]]*\])| # Anything in brackets needs modification
[\(\)\$\-\+\/\:\!\^\&\'\~\{\}\<\>\=\s]| # All the pass through characters
\,\s # comma space for verbal separation
)?(.*)/x
defined $format_string
my(@result) = $format_string =~ /^( # Collect any formatting stuff first
(AM\/PM| # Date 12 hr flag
A\/P| # Another date 12 hr flag
\[hh?\]| # Elapsed hours
\[mm\]| # Elapsed minutes
\[ss\]| # Elapsed seconds
[dmyhms]+)| # DateTime chunks
([0-9#\?]+[,\-\_]?[#0\?]*,*| # Number string
\.| # Split integers from decimals
[Ee][+\-]| # Exponential notiation
%)| # Percentage
(\@) # Text input
)?( # Finish collecting format actions
(\"[^\"]*\")| # Anything in quotes just passes through
(\[[^\]]*\])| # Anything in brackets needs modification
[\(\)\$\-\+\/\:\!\^\&\'\~\{\}\<\>\=\s]| # All the pass through characters
\,\s # comma space for verbal separation
)?(.*)/x
Truth table33%1/3
A and B
A= defined $format_stringB= my(@result) = $format_string =~ /^( # Collect any formatting stuff first
(AM\/PM| # Date 12 hr flag
A\/P| # Another date 12 hr flag
\[hh?\]| # Elapsed hours
\[mm\]| # Elapsed minutes
\[ss\]| # Elapsed seconds
[dmyhms]+)| # DateTime chunks
([0-9#\?]+[,\-\_]?[#0\?]*,*| # Number string
\.| # Split integers from decimals
[Ee][+\-]| # Exponential notiation
%)| # Percentage
(\@) # Text input
)?( # Finish collecting format actions
(\"[^\"]*\")| # Anything in quotes just passes through
(\[[^\]]*\])| # Anything in brackets needs modification
[\(\)\$\-\+\/\:\!\^\&\'\~\{\}\<\>\=\s]| # All the pass through characters
\,\s # comma space for verbal separation
)?(.*)/x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | /^( # Collect any formatting stuff first | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | (AM\/PM| # Date 12 hr flag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | A\/P| # Another date 12 hr flag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | \[hh?\]| # Elapsed hours | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | \[mm\]| # Elapsed minutes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | \[ss\]| # Elapsed seconds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | [dmyhms]+)| # DateTime chunks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | ([0-9#\?]+[,\-\_]?[#0\?]*,*| # Number string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | \.| # Split integers from decimals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | [Ee][+\-]| # Exponential notiation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | %)| # Percentage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | (\@) # Text input | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | )?( # Finish collecting format actions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | (\"[^\"]*\")| # Anything in quotes just passes through | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | (\[[^\]]*\])| # Anything in brackets needs modification | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | [\(\)\$\-\+\/\:\!\^\&\'\~\{\}\<\>\=\s]| # All the pass through characters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | \,\s # comma space for verbal separation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | )?(.*)/x ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | ###LogSD "Now processing: $format_string", '..with result:', @result ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 459 | my $pre_action = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 459 | my $date = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 459 | my $number = $3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 459 | my $text = $4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 459 | my $fixed_value = $5; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 459 | my $quote_string = $6; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 459 | $format_string = $8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 459 | ▶ | if( $fixed_value ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 195 | ▶ | if( $fixed_value =~ /\[\$([^\-\]]*)\-?\d*\]/ ){# removed the localized element of fixed values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 4 | $fixed_value = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | }elsif( $fixed_value =~ /\[[^hms]*\]/ ){# Remove all color and conditionals as they will not be used | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 8 | $fixed_value = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | ▶ | }elsif( $fixed_value =~ /\"\-\"/ and $format_string ){# remove decimal justification for zero bars | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$fixed_value =~ /\"\-\"/ and $format_string
MC/DC100%2/2
$fixed_value =~ /\"\-\"/ and $format_string
$fixed_value =~ /\"\-\"/
$format_string
Truth table100%3/3
A and B
A= $fixed_value =~ /\"\-\"/B= $format_string
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | ###LogSD $phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | ###LogSD "Initial format string: $format_string", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 4 | $format_string =~ s/^(\?+)//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | ###LogSD $phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | ###LogSD "updated format string: $format_string", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 459 | ▶ | if( defined $pre_action ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 324 | ▶ | my $current_action = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | ( $date ) ? 'DATE' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | ( defined $number ) ? 'NUMBER' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | ( $text ) ? 'TEXT' : 'BAD' ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 324 | ▶ | $is_date = 1 if $date; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | ###LogSD "Current action from -$pre_action- is: $current_action", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | ###LogSD "..now testing against: " . ($action_type//'') ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 324 | ▶ | if( $action_type and $current_action and ($current_action ne $action_type) and $action_type ne 'TEXT' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
$action_type and $current_action and $current_action ne $action_type and $action_type ne "TEXT"
$action_type and $current_action and $current_action ne $action_type
$action_type and $current_action
MC/DC50%2/4
$action_type and $current_action and $current_action ne $action_type and $action_type ne "TEXT"
$action_type
$current_action
$current_action ne $action_type
$action_type ne "TEXT"
Truth table60%3/5
A and B and C and D
A= $action_typeB= $current_actionC= $current_action ne $action_typeD= $action_type ne "TEXT"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | ###LogSD "General action type: $action_type", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | ###LogSD "is failing current action: $current_action", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 33 | my $fail = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 33 | ▶ | if( $action_type eq 'DATE' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 8 | $conversion_type = 'date'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | ###LogSD "Checking the date mishmash", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 8 | ▶ | if( $current_action eq 'NUMBER' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | ###LogSD "Special case of number following action", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 4 | ▶ | if( ( $pre_action =~ /^\.$/ and $format_string =~ /^0+/ ) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
$pre_action =~ /^\.$/ and $format_string =~ /^0+/ or $pre_action =~ /^0+$/ and $deconstructed_list[-1][0] =~ /^\.$/
$pre_action =~ /^\.$/ and $format_string =~ /^0+/
$pre_action =~ /^0+$/ and $deconstructed_list[-1][0] =~ /^\.$/
MC/DC0%0/4
$pre_action =~ /^\.$/ and $format_string =~ /^0+/ or $pre_action =~ /^0+$/ and $deconstructed_list[-1][0] =~ /^\.$/
$pre_action =~ /^\.$/
$format_string =~ /^0+/
$pre_action =~ /^0+$/
$deconstructed_list[-1][0] =~ /^\.$/
Truth table28%2/7
A and B or C and D
A= $pre_action =~ /^\.$/B= $format_string =~ /^0+/C= $pre_action =~ /^0+$/D= $deconstructed_list[-1][0] =~ /^\.$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | ( $pre_action =~ /^0+$/ and $deconstructed_list[-1]->[0] =~ /^\.$/ ) ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 4 | $current_action = 'DATE'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 4 | $fail = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | }elsif( $pre_action eq '@' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | ###LogSD "Excel conversion of pre-epoch datestring pass through highjacked here", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 4 | $current_action = 'DATESTRING'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 4 | $fail = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | }elsif( $action_type eq 'NUMBER' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | ###LogSD "Checking for possible number field exceptions", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | if( $current_action eq 'TEXT' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | ###LogSD "Special case of text following a number", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | $fail = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | ▶ | }elsif( $action_type eq 'INTEGER' or $action_type eq 'DECIMAL'){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$action_type eq "INTEGER" or $action_type eq "DECIMAL"
MC/DC0%0/2
$action_type eq "INTEGER" or $action_type eq "DECIMAL"
$action_type eq "INTEGER"
$action_type eq "DECIMAL"
Truth table66%2/3
A or B
A= $action_type eq "INTEGER"B= $action_type eq "DECIMAL"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | ###LogSD "Checking for possible sub-Number generalities", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 25 | ▶ | if( $current_action eq 'NUMBER' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | ###LogSD "Integers are numbers", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 25 | $fail = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 33 | ▶ | if( $fail ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | confess "Bad combination of actions in this format string: $format_strings - $action_type - $current_action"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 324 | ▶ | $action_type = $current_action if $current_action; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | ###LogSD (($pre_action) ? "First action resolved to: $pre_action" : undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | ###LogSD (($fixed_value) ? "Extracted fixed value: $fixed_value" : undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | ###LogSD (($format_string) ? "Remaining string: $format_string" : undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | ###LogSD "With updated deconstruction list:", @deconstructed_list, ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | ###LogSD "Early elements unusable - remaining string: $fixed_value", $quote_string ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 135 | ▶ | $action_type = 'TEXT' if $quote_string and $fixed_value eq $quote_string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$quote_string and $fixed_value eq $quote_string
MC/DC50%1/2
$quote_string and $fixed_value eq $quote_string
$quote_string
$fixed_value eq $quote_string
Truth table66%2/3
A and B
A= $quote_stringB= $fixed_value eq $quote_string
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 459 | push @deconstructed_list, [ $pre_action, $fixed_value ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 459 | ▶ | if( $x++ == 30 ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 2 | confess "Attempts to use string |$format_string| as an excel custom format failed. Contact the author jandrew\@cpan (.org) if you feel there is an error"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | ###LogSD (($pre_action) ? "First action resolved to: $pre_action" : undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | ###LogSD (($fixed_value) ? "Extracted fixed value: $fixed_value" : undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | ###LogSD (($format_string) ? "Remaining string: $format_string" : undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | ###LogSD "With updated deconstruction list:", @deconstructed_list, ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 457 | ▶ | last if length( $format_string ) == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | ###LogSD "Handling action type: $action_type", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 143 | ▶ | push @deconstructed_list, [ $format_string, undef ] if $format_string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | ###LogSD "List with fixed values separated:", @deconstructed_list ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 143 | ▶ | my $method = '_build_' . ( $action_type =~ /^(NUMBER|SCIENTIFIC|INTEGER|PERCENT|FRACTION|DECIMAL)$/ ? 'number' : lc($action_type) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | ###LogSD $phone->talk( level => 'info', message => [ "Method: $method", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 143 | ▶ | my $filter = ( $action_type and $action_type eq 'TEXT' ) ? Str : $used_type_list[$format_position++]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$action_type and $action_type eq "TEXT"
MC/DC50%1/2
$action_type and $action_type eq "TEXT"
$action_type
$action_type eq "TEXT"
Truth table66%2/3
A and B
A= $action_typeB= $action_type eq "TEXT"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 143 | ▶ | if( $action_type and $action_type eq 'DATESTRING' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$action_type and $action_type eq "DATESTRING"
MC/DC50%1/2
$action_type and $action_type eq "DATESTRING"
$action_type
$action_type eq "DATESTRING"
Truth table66%2/3
A and B
A= $action_typeB= $action_type eq "DATESTRING"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | ###LogSD $phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | ###LogSD "Found date string and making adjustments with:", @deconstructed_list, $last_deconstructed_list ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 4 | $date_text = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 4 | $filter = Str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 4 | ▶ | @deconstructed_list = @$last_deconstructed_list if $last_deconstructed_list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | ###LogSD "Updated deconstructed list:", @deconstructed_list, ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 143 | $last_deconstructed_list = clone( [@deconstructed_list] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | ###LogSD "Running method -$method- for list:", @deconstructed_list ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 143 | my( $intermediate_action, @intermediate_coercions ) = $self->$method( $filter, \@deconstructed_list, $format_string ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | ###LogSD $phone->talk( level => 'trace', message => [ "Returning from: $method", $intermediate_action, @intermediate_coercions ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 143 | push @coercion_list, @intermediate_coercions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 143 | ▶ | $action_type = $intermediate_action =~ /^(NUMBER|SCIENTIFIC|INTEGER|PERCENT|FRACTION|DECIMAL|DATE|DATESTRING)$/ ? $intermediate_action : $action_type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | ###LogSD $phone->talk( level => 'trace', message => [ "Action type: $action_type", $intermediate_action, @coercion_list ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 97 | ▶ | if( $is_date and !$date_text ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$is_date and not $date_text
MC/DC100%2/2
$is_date and not $date_text
$is_date
not $date_text
Truth table100%3/3
A and not(B)
A= $is_dateB= not $date_text
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 26 | ( my $intermediate_action, my @intermediate_coercions ) = $self->_build_datestring( Str, $last_deconstructed_list ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 26 | push @coercion_list, @intermediate_coercions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 26 | ▶ | $action_type = $intermediate_action =~ /^(NUMBER|SCIENTIFIC|INTEGER|PERCENT|FRACTION|DECIMAL|DATE|DATESTRING)$/ ? $intermediate_action : $action_type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | ###LogSD $phone->talk( level => 'info', message => [ "Adjusted action type: $action_type", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | ###LogSD 'Length of coersion list: ' . scalar( @coercion_list ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | ###LogSD "Action type: $action_type", "Conversion type: $conversion_type", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | ###LogSD $phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | ###LogSD ($coercion_name ? "Initial coercion name: $coercion_name" : ''), ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | # Build the final format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | #~ $conversion_type = 'text' if $action_type eq 'TEXT'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 97 | ▶ | $coercion_name =~ s/__/_${conversion_type}_/ if $coercion_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | ###LogSD $phone->talk( level => 'info', message => [ "Action type: $action_type" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 97 | ▶ | my %args = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$coercion_name // $action_type . '_' . $coercion_index++
MC/DC100%1/1
$coercion_name // $action_type . '_' . $coercion_index++
$coercion_name
Truth table100%2/2
A
A= $coercion_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | name => $action_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | display_name => ($coercion_name // ($action_type . '_' . $coercion_index++)), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | coercion => Type::Coercion->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | type_coercion_map => [ @coercion_list ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | #~ coerce => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 97 | my $final_type = Type::Tiny->new( %args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | ###LogSD $phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | ###LogSD "Final type:", $final_type ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | # Save the cache | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 97 | ▶ | if( $self->get_cache_behavior ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | ###LogSD "setting cache for key:", $cache_key ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 97 | $self->_set_cashed_format( $cache_key => $final_type ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 97 | return $final_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | #########1 Private Attributes 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | has _format_cash =>( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | isa => HashRef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | traits => ['Hash'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | reader => '_get_all_format_cache', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | handles =>{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | _has_cached_format => 'exists', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | _get_cached_format => 'get', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | _set_cashed_format => 'set', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 2 | ▶ | default => sub{ {} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 2 | has _alt_epoch_year =>( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | isa => Int, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | reader => '_get_alt_epoch_year', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | default => 1900, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | #########1 Private Methods 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 21 | ▶ | sub _build_text{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_text: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 21 | my( $self, $type_filter, $list_ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | ###LogSD $self->get_all_space . '::hidden::_build_text', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | ###LogSD "Building an anonymous sub to process text values", $list_ref ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 21 | my $sprintf_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 21 | my $found_string = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 21 | my $alt_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 21 | for my $piece ( @$list_ref ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | ###LogSD "processing text piece:", $piece ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 25 | ▶ | if( !$found_string and defined $piece->[0] ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $found_string and defined $piece->[0]
MC/DC50%1/2
not $found_string and defined $piece->[0]
not $found_string
defined $piece->[0]
Truth table66%2/3
not(A) and B
A= not $found_stringB= defined $piece->[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | ###LogSD "The first element is defined:", $piece->[0] ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 12 | $sprintf_string .= '%s'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 12 | $found_string = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 25 | ▶ | if( $piece->[1] ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 13 | $piece->[1] =~ s/\"(.*)\"/$1/g;# Remove quotes around text strings (mostly spaces?) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | ###LogSD "Adding fixed value |$piece->[1]|" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 13 | $sprintf_string .= $piece->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 13 | $alt_string .= $piece->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | ###LogSD "Final sprintf string: $sprintf_string", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | ###LogSD "Final alt string: " . ($alt_string//'undef') ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 21 | my $return_sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | ###LogSD my $sub_phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | ###LogSD $self->get_log_space . '::Cell::_hidden::_return_value_only::_build_text', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 21 | ▶ | if( $found_string ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 8 | ▶ | $return_sub = sub{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | #~ print "Using Text sub!!!!!!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | ###LogSD "Updated Input: $_[0]" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 8 | return sprintf( $sprintf_string, $_[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 2 | ▶ | $return_sub = sub{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | #~ print "Using Text sub!!!!!!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | ###LogSD "Received Input |$_[0]| -> returning $alt_string" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 2 | return $alt_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 21 | return( 'TEXT', Str, $return_sub ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 30 | ▶ | sub _build_date{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_date: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 30 | my( $self, $type_filter, $list_ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | ###LogSD $self->get_all_space . '::hidden::_build_date', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | ###LogSD "Building an anonymous sub to process date values", $list_ref ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 30 | my $build_ref;# | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 30 | @$build_ref{qw( is_duration sub_seconds )} = ( 0, 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | # Process once to build the cldr string and other flags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 30 | @$build_ref{qw( cldr_string is_duration sub_seconds format_remainder )} = $self->_build_date_cldr( $list_ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 30 | my $clone_ref = clone( $build_ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | ###LogSD "Conversion sub will use ref: ", $clone_ref ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 30 | ▶ | my @args_list = ( $self->get_epoch_year == 1904 ) ? ( system_type => 'apple_excel' ) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 30 | my $converter = DateTimeX::Format::Excel->new( @args_list ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | ###LogSD "Building sub with:", @args_list, "And get_date_behavior set to: " . $self->get_date_behavior ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 172 | ▶ | my $conversion_sub = sub{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=12 SCAR=25.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 172 | my $num = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 172 | ▶ | if( !defined $num ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | #~ print "Using Date sub!!!!!!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | ###LogSD my $sub_phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | ###LogSD $self->get_log_space . '::Cell::_hidden::_return_value_only::_build_date', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | ###LogSD "Processing date number: $num", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | ###LogSD '..with adjustement ref:', $clone_ref, ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 172 | my $dt = $converter->parse_datetime( $num ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 172 | my $return_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | my $calc_sub_secs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 172 | ▶ | if( $clone_ref->{is_duration} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 12 | my $di = $dt->subtract_datetime_absolute( $converter->_get_epoch_start ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 12 | ▶ | if( $self->get_date_behavior ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | return $di; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 12 | my $sign = DateTime->compare_ignore_floating( $dt, $converter->_get_epoch_start ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 12 | ▶ | $return_string = ( $sign == -1 ) ? '-' : '' ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 12 | my $key = $clone_ref->{is_duration}->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 12 | my $delta_seconds = $di->seconds; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 12 | my $delta_nanosecs = $di->nanoseconds; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 12 | $return_string .= $self->_build_duration( $clone_ref->{is_duration}, $delta_seconds, $delta_nanosecs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | ###LogSD "Duration return string: $return_string" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 160 | ▶ | if( $self->get_date_behavior ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | ###LogSD "Returning the DateTime object rather than the format string" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 4 | return $dt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 156 | ▶ | if( $clone_ref->{sub_seconds} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 12 | $calc_sub_secs = $dt->format_cldr( $clone_ref->{sub_seconds} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | ###LogSD "Processing sub-seconds: $calc_sub_secs" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 12 | ▶ | if( "0.$calc_sub_secs" >= 0.5 ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | ###LogSD "Rounding seconds back down" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 10 | $dt->subtract( seconds => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | ###LogSD "Converting it with CLDR string: " . ($clone_ref->{cldr_string}//'undef') ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 156 | ▶ | if( $clone_ref->{cldr_string} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 156 | $return_string .= $dt->format_cldr( $clone_ref->{cldr_string} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | $self->set_error( "No cldr string passed where one is expected while processing |$num|" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | $return_string .= scalar( $dt ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 156 | ▶ | if( $clone_ref->{sub_seconds} and $clone_ref->{sub_seconds} ne '1' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$clone_ref->{"sub_seconds"} and $clone_ref->{"sub_seconds"} ne 1
MC/DC50%1/2
$clone_ref->{"sub_seconds"} and $clone_ref->{"sub_seconds"} ne 1
$clone_ref->{"sub_seconds"}
$clone_ref->{"sub_seconds"} ne 1
Truth table66%2/3
A and B
A= $clone_ref->{"sub_seconds"}B= $clone_ref->{"sub_seconds"} ne 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 12 | $return_string .= $calc_sub_secs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 156 | ▶ | $return_string .= $dt->format_cldr( $clone_ref->{format_remainder} ) if $clone_ref->{format_remainder}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | ###LogSD "returning: $return_string" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 168 | return $return_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 30 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 30 | return( 'DATE', $type_filter, $conversion_sub, ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 30 | ▶ | sub _build_datestring{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_datestring: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 30 | my( $self, $type_filter, $list_ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | ###LogSD $self->get_all_space . '::hidden::_build_datestring', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | ###LogSD "Building an anonymous sub to process date strings", $list_ref, ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 30 | my $build_ref;# | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 30 | @$build_ref{qw( is_duration sub_seconds )} = ( 0, 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | # Process once to build the cldr string and other flags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 30 | @$build_ref{qw( cldr_string is_duration sub_seconds format_remainder )} = $self->_build_date_cldr( $list_ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 30 | my $clone_ref = clone( $build_ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | ###LogSD "Conversion sub will use ref: ", $clone_ref ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 46 | ▶ | my $conversion_sub = sub{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=33 SCAR=40.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 46 | my $date = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 46 | ▶ | if( !$date ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | #~ print "Using DateString sub!!!!!!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | ###LogSD my $sub_phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | ###LogSD $self->get_log_space . '::Cell::_hidden::_return_value_only::_build_datestring', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 46 | my $calc_sub_secs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | ###LogSD "Processing date: $date", "..with clone_ref:", $clone_ref] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 46 | ▶ | if( $date =~ /(.*:\d+)\.(\d+)(.*)/ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 28 | $calc_sub_secs = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | ###LogSD "updated sub seconds: " . ($calc_sub_secs//'undef') ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 28 | $date = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 28 | ▶ | $date .= $3 if $3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 28 | $calc_sub_secs .= 0 x (9 - length( $calc_sub_secs )); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | ###LogSD "Processing new date string: $date", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | ###LogSD "..with stripped nanoseconds: " . ($calc_sub_secs//'undef'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | ###LogSD "..against date return behaviour: " . $self->get_date_behavior, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | ###LogSD "..and format ref:", $clone_ref ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 46 | my ( $dt_us, $dt_eu ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 46 | eval '$dt_us = DateTime::Format::Flexible->parse_datetime( $date )'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 46 | eval '$dt_eu = DateTime::Format::Flexible->parse_datetime( $date, european => 1, )'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 46 | ▶ | if( !$dt_us and !$dt_eu ){# handle double digit years in formats unreadable by ~::Flexible | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$dt_us or $dt_eu
MC/DC50%1/2
$dt_us or $dt_eu
$dt_us
$dt_eu
Truth table66%2/3
A or B
A= $dt_usB= $dt_eu
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | ###LogSD "Initial DateTime conversion failed - attempting backup work for: $date" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 2 | my $current_year = DateTime->now()->truncate( to => 'year' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 2 | my $century_prefix = substr( $current_year, 0, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 2 | my $century_postfix = substr( $current_year, 2, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 2 | ▶ | my $bump_year = ( $century_postfix + 20 > 99 ) ? ( $century_postfix - 80 ) : undef;# The double digit years are probably less than 21 years in the future of the processing time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 2 | ▶ | my $drop_year = ( $century_postfix - 79 < 0 ) ? ( $century_postfix + 21 ) : undef;# The double digit years are probably less than 81 years in the past of the processing time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 2 | $date =~ /(\d{1,2})\D(\d{1,2})\D(\d{1,2})(\s|T)(\d{1,2})\D(\d{1,2})(\D(\d{1,2}))?/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 2 | ▶ | if ( defined $1 and defined $2 and defined $3 ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $1 and defined $2 and defined $3
defined $1 and defined $2
MC/DC0%0/3
defined $1 and defined $2 and defined $3
defined $1
defined $2
defined $3
Truth table25%1/4
A and B and C
A= defined $1B= defined $2C= defined $3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | ###LogSD "Processing date parse for: $date", $1, $2, $3, $4, $5, $6, $7 ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 2 | my $year = $3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 2 | ▶ | $year = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
defined $bump_year and $year <= $bump_year
defined $drop_year and $year >= $drop_year
MC/DC0%0/2
defined $bump_year and $year <= $bump_year
defined $bump_year
$year <= $bump_year
MC/DC0%0/2
defined $drop_year and $year >= $drop_year
defined $drop_year
$year >= $drop_year
Truth table33%1/3
A and B
A= defined $bump_yearB= $year <= $bump_year
Truth table33%1/3
A and B
A= defined $drop_yearB= $year >= $drop_year
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | (defined $bump_year and $year <= $bump_year ) ? $century_prefix + 1 : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | (defined $drop_year and $year >= $drop_year ) ? $century_prefix - 1 : $century_prefix ) . sprintf '%02u', $year; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 2 | ▶ | my $us_str = sprintf "%u-%02u-%02uT%02u:%02u:%02u", $year, $1, $2, $5, $6, ($7//'00'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$7 // "00"
MC/DC0%0/1
$7 // "00"
$7
Truth table50%1/2
A
A= $7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 2 | ▶ | my $eu_str = sprintf "%u-%02u-%02uT%02u:%02u:%02u", $year, $2, $1, $5, $6, ($7//'00'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$7 // "00"
MC/DC0%0/1
$7 // "00"
$7
Truth table50%1/2
A
A= $7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 2 | eval '$dt_us = DateTime::Format::Flexible->parse_datetime( $us_str )'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 2 | eval '$dt_eu = DateTime::Format::Flexible->parse_datetime( $eu_str )';# european => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 46 | ▶ | my $dt = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$self->get_european_first and $dt_eu
MC/DC50%1/2
$self->get_european_first and $dt_eu
$self->get_european_first
$dt_eu
Truth table66%2/3
A and B
A= $self->get_european_firstB= $dt_eu
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | ( $self->get_european_first and $dt_eu )? $dt_eu :# DD-MM-YY tested instead of MM-DD-YY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | ( $dt_us ) ? $dt_us : $dt_eu ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | ###LogSD "Result of the processing of -$date- " . $dt ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 46 | ▶ | if( $dt ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 46 | ▶ | $dt->add( nanoseconds => $calc_sub_secs ) if $calc_sub_secs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | ###LogSD "Date building sucessfull - result to this point: $dt" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | ###LogSD "Unable to convert the string to a date time object: $date" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | return $date; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 46 | my $return_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 46 | ▶ | if( $clone_ref->{is_duration} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 2 | ▶ | my @args_list = ( $self->get_epoch_year == 1904 ) ? ( system_type => 'apple_excel' ) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 2 | my $converter = DateTimeX::Format::Excel->new( @args_list ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 2 | my $di = $dt->subtract_datetime_absolute( $converter->_get_epoch_start ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 2 | ▶ | if( $self->get_date_behavior ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | return $di; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 2 | my $sign = DateTime->compare_ignore_floating( $dt, $converter->_get_epoch_start ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 2 | ▶ | $return_string = ( $sign == -1 ) ? '-' : '' ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 2 | my $key = $clone_ref->{is_duration}->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 2 | my $delta_seconds = $di->seconds; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 2 | my $delta_nanosecs = $di->nanoseconds;; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | ###LogSD "Delta seconds: $delta_seconds", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | ###LogSD (($delta_nanosecs) ? "Delta nanoseconds: $delta_nanosecs" : undef) ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 2 | $return_string .= $self->_build_duration( $clone_ref->{is_duration}, $delta_seconds, $delta_nanosecs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | ###LogSD "Duration return string: $return_string" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 44 | ▶ | if( $self->get_date_behavior ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | return $dt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 44 | ▶ | if( $clone_ref->{sub_seconds} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 2 | $calc_sub_secs = $dt->format_cldr( $clone_ref->{sub_seconds} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | ###LogSD "Processing sub-seconds: $calc_sub_secs" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 2 | ▶ | if( "0.$calc_sub_secs" >= 0.5 ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | ###LogSD "Rounding seconds back down" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | $dt->subtract( seconds => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 44 | ▶ | if( $clone_ref->{cldr_string} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | ###LogSD "Using CLDR string: $clone_ref->{cldr_string}\n", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 44 | $return_string .= $dt->format_cldr( $clone_ref->{cldr_string} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | $self->set_error( "No cldr string passed where one is expected while processing |$date|" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | $return_string .= scalar( $dt ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 44 | ▶ | if( $clone_ref->{sub_seconds} and $clone_ref->{sub_seconds} ne '1' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$clone_ref->{"sub_seconds"} and $clone_ref->{"sub_seconds"} ne 1
MC/DC50%1/2
$clone_ref->{"sub_seconds"} and $clone_ref->{"sub_seconds"} ne 1
$clone_ref->{"sub_seconds"}
$clone_ref->{"sub_seconds"} ne 1
Truth table66%2/3
A and B
A= $clone_ref->{"sub_seconds"}B= $clone_ref->{"sub_seconds"} ne 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 2 | $return_string .= $calc_sub_secs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 44 | ▶ | $return_string .= $dt->format_cldr( $clone_ref->{format_remainder} ) if $clone_ref->{format_remainder}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | ###LogSD "returning: $return_string" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 46 | return $return_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 30 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | ###LogSD $phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | ###LogSD "returning:", 'DATESTRING', $type_filter, $conversion_sub ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 30 | return( 'DATESTRING', $type_filter, $conversion_sub ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 60 | ▶ | sub _build_date_cldr{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_date_cldr: called CC=27 SCAR=33.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 60 | my( $self, $list_ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | ###LogSD $self->get_all_space . '::hidden::_build_date_cldr', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | ###LogSD "transforming an excel format string to the cldr equivalent", $list_ref ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 60 | my ( $cldr_string, $format_remainder ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 60 | my $is_duration = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 60 | my $sub_seconds = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | # Process once to build the cldr string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 60 | my $prior_duration; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 60 | for my $piece ( @$list_ref ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | ###LogSD "processing date piece:", $piece ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 192 | ▶ | if( defined $piece->[0] ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | ###LogSD $phone->talk( level => 'debug', message =>[ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | ###LogSD "Manageing the cldr part: " . $piece->[0] ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 184 | ▶ | if( $piece->[0] =~ /\[(.+)\]/ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | ###LogSD $phone->talk( level => 'debug', message =>[ "Possible duration" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 4 | (my $initial,) = split //, $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 4 | my $length = length( $1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 4 | $is_duration = [ $initial, 0, [ $piece->[1] ], [ $length ] ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 4 | ▶ | if( $is_duration->[0] =~ /[hms]/ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 4 | $piece->[0] = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 4 | $piece->[1] = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 4 | $prior_duration = $is_duration->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | ###LogSD "found a duration piece:", $is_duration, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | ###LogSD "with prior duration: $prior_duration" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | confess "Bad duration element found: $is_duration->[0]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | }elsif( ref( $is_duration ) eq 'ARRAY' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | ###LogSD $phone->talk( level => 'debug', message =>[ "adding to duration", $piece ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 8 | my $next_duration = $duration_order->{$prior_duration}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 8 | ▶ | if( $piece->[0] eq '.' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | push @{$is_duration->[2]}, $piece->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | ###LogSD "found a period" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | }elsif( $piece->[0] =~ /$next_duration/ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 8 | my $length = length( $piece->[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 8 | $is_duration->[1]++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 8 | ▶ | push @{$is_duration->[2]}, $piece->[1] if $piece->[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 8 | push @{$is_duration->[3]}, $length; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 8 | ($prior_duration,) = split //, $piece->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 8 | ▶ | if( $piece->[0] =~ /^0+$/ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | $piece->[0] =~ s/0/S/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | $sub_seconds = $piece->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | ###LogSD "found a subseconds format piece: $sub_seconds" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 8 | $piece->[0] = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 8 | $piece->[1] = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | ###LogSD "Current duration:", $is_duration, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | ###LogSD "with prior duration: $prior_duration" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | confess "Bad duration element found: $piece->[0]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | }elsif( $piece->[0] =~ /m/ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | ###LogSD $phone->talk( level => 'debug', message =>[ "Minutes or Months" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 60 | ▶ | if( ($cldr_string and $cldr_string =~ /:'?$/) or ($piece->[1] and $piece->[1] eq ':') ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
$cldr_string and $cldr_string =~ /:'?$/ or $piece->[1] and $piece->[1] eq ":"
$cldr_string and $cldr_string =~ /:'?$/
$piece->[1] and $piece->[1] eq ":"
MC/DC75%3/4
$cldr_string and $cldr_string =~ /:'?$/ or $piece->[1] and $piece->[1] eq ":"
$cldr_string
$cldr_string =~ /:'?$/
$piece->[1]
$piece->[1] eq ":"
Truth table71%5/7
A and B or C and D
A= $cldr_stringB= $cldr_string =~ /:'?$/C= $piece->[1]D= $piece->[1] eq ":"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | ###LogSD "Found minutes - leave them alone" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 32 | $piece->[0] =~ s/m/L/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | ###LogSD "Converting to cldr stand alone months (m->L)" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | }elsif( $piece->[0] =~ /h/ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 20 | $piece->[0] =~ s/h/H/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | ###LogSD "Converting 12 hour clock to 24 hour clock" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | }elsif( $piece->[0] =~ /AM?\/PM?/i ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 8 | $cldr_string =~ s/H/h/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 8 | $piece->[0] = 'a'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | ###LogSD $phone->talk( level => 'debug', message =>[ "Set 12 hour clock and AM/PM" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | }elsif( $piece->[0] =~ /d{3,5}/ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 4 | $piece->[0] =~ s/d/E/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | ###LogSD $phone->talk( level => 'debug', message =>[ "Found a weekday request" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | ▶ | }elsif( !$sub_seconds and $piece->[0] =~ /[\.]/){# | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
not $sub_seconds and $piece->[0] =~ /[\.]/
MC/DC100%2/2
not $sub_seconds and $piece->[0] =~ /[\.]/
not $sub_seconds
$piece->[0] =~ /[\.]/
Truth table100%3/3
not(A) and B
A= not $sub_secondsB= $piece->[0] =~ /[\.]/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 4 | $piece->[0] = "'.'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | #~ $piece->[0] = "':'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 4 | $sub_seconds = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | ###LogSD $phone->talk( level => 'debug', message =>[ "Starting sub seconds" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | }elsif( $sub_seconds eq '1' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | ###LogSD $phone->talk( level => 'debug', message =>[ "Formatting sub seconds" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 4 | ▶ | if( $piece->[0] =~ /^0+$/ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 4 | $piece->[0] =~ s/0/S/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 4 | $sub_seconds = $piece->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 4 | $piece->[0] = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | ###LogSD "found a subseconds format piece: $sub_seconds" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | confess "Bad sub-seconds element after [$cldr_string] found: $piece->[0]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 184 | ▶ | if( $sub_seconds and $sub_seconds ne '1' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$sub_seconds and $sub_seconds ne 1
MC/DC100%2/2
$sub_seconds and $sub_seconds ne 1
$sub_seconds
$sub_seconds ne 1
Truth table100%3/3
A and B
A= $sub_secondsB= $sub_seconds ne 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 4 | $format_remainder .= $piece->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 180 | $cldr_string .= $piece->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 192 | ▶ | if( $piece->[1] ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 108 | ▶ | if( $sub_seconds and $sub_seconds ne '1' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$sub_seconds and $sub_seconds ne 1
MC/DC0%0/2
$sub_seconds and $sub_seconds ne 1
$sub_seconds
$sub_seconds ne 1
Truth table33%1/3
A and B
A= $sub_secondsB= $sub_seconds ne 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | $format_remainder .= $piece->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 108 | $cldr_string .= $piece->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | ###LogSD (($cldr_string) ? "Updated CLDR string: $cldr_string" : undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | ###LogSD (($format_remainder) ? "Updated format remainder: $format_remainder" : undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | ###LogSD (($is_duration) ? ('Duration ref:', $is_duration) : undef) ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | ###LogSD "Updated CLDR string: $cldr_string", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | ###LogSD (($is_duration) ? ('...and duration:', $is_duration) : undef ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | ###LogSD (($sub_seconds) ? ('...and sub seconds:' . $sub_seconds) : undef ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | ###LogSD (($format_remainder) ? ('...and format_remainder:' . $format_remainder) : undef ) ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 60 | return( $cldr_string, $is_duration, $sub_seconds, $format_remainder ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 14 | ▶ | sub _build_duration{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_duration: called CC=10 SCAR=23.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 14 | my( $self, $duration_ref, $delta_seconds, $delta_nanosecs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | ###LogSD $self->get_all_space . '::hidden::_build_date::_build_duration', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | ###LogSD 'Building a duration string with duration ref:', $duration_ref, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | ###LogSD "With delta seconds: $delta_seconds", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | ###LogSD (($delta_nanosecs) ? "And delta nanoseconds: $delta_nanosecs" : undef) ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 14 | my $return_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 14 | my $key = $duration_ref->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 14 | my $first = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 14 | for my $position ( 0 .. $duration_ref->[1] ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 42 | ▶ | if( $key eq '0' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | my $length = length( $last_sub_seconds ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | $return_string .= '.' . sprintf( "%0.${length}f", $delta_nanosecs/1000000000); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | ###LogSD "Return string with nanoseconds: $return_string", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 42 | ▶ | if( $key eq 's' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 14 | ▶ | $return_string .= ( $first ) ? $delta_seconds : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | sprintf "%0$duration_ref->[3]->[$position]d", $delta_seconds; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 14 | $first = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 14 | $key = $duration_order->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | ###LogSD "Delta seconds: $delta_seconds", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | ###LogSD "Next key to process: $key" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 42 | ▶ | if( $key eq 'm' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 14 | my $minutes = int($delta_seconds/60); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 14 | $delta_seconds = $delta_seconds - ($minutes*60); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 14 | ▶ | $return_string .= ( $first ) ? $minutes : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | sprintf "%0$duration_ref->[3]->[$position]d", $minutes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 14 | $first = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 14 | $key = $duration_order->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | ###LogSD "Calculated minutes: $minutes", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | ###LogSD "Remaining seconds: $delta_seconds", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | ###LogSD "Next key to process: $key" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 42 | ▶ | if( $key eq 'h' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 14 | my $hours = int($delta_seconds /(60*60)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 14 | $delta_seconds = $delta_seconds - ($hours*60*60); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 14 | ▶ | $return_string .= ( $first ) ? $hours : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | sprintf "%0$duration_ref->[3]->[$position]d", $hours; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 14 | $first = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 14 | $key = $duration_order->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | ###LogSD "Calculated hours: $hours", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | ###LogSD "Remaining seconds: $delta_seconds", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | ###LogSD "Next key to process: $key" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 42 | ▶ | $return_string .= $duration_ref->[2]->[$position] if $duration_ref->[2]->[$position]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 14 | return $return_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 88 | ▶ | sub _build_number{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_number: called CC=43 SCAR=42.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 88 | my( $self, $type_filter, $list_ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | ###LogSD $self->get_all_space . '::hidden::_build_number', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | ###LogSD "Processing a number list to see how it should be converted", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | ###LogSD 'With type constraint: ' . $type_filter->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | ###LogSD '..using list ref:' , $list_ref ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 88 | my ( $code_hash_ref, $number_type, ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | # Resolve zero replacements quickly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 88 | ▶ | if( $type_filter->name eq 'ZeroOrUndef' and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$type_filter->name eq "ZeroOrUndef" and not $list_ref->[-1][0] and $list_ref->[-1][1] eq "\"-\""
$type_filter->name eq "ZeroOrUndef" and not $list_ref->[-1][0]
MC/DC0%0/3
$type_filter->name eq "ZeroOrUndef" and not $list_ref->[-1][0] and $list_ref->[-1][1] eq "\"-\""
$type_filter->name eq "ZeroOrUndef"
not $list_ref->[-1][0]
$list_ref->[-1][1] eq "\"-\""
Truth table25%1/4
A and not(B) and C
A= $type_filter->name eq "ZeroOrUndef"B= not $list_ref->[-1][0]C= $list_ref->[-1][1] eq "\"-\""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | !$list_ref->[-1]->[0] and $list_ref->[-1]->[1] eq '"-"' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | ###LogSD $phone->talk( level => 'debug', message =>[ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | ###LogSD "Found a zero to bar replacement" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | my $return_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | for my $piece ( @$list_ref ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | $return_string .= $piece->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | $return_string =~ s/"\-"/\-/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | ▶ | return( 'NUMBER', $type_filter, sub{ $return_string } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | # Handle trailing negative | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 88 | ▶ | if( $list_ref->[-1]->[0] =~ /(.*[\d\#])\-$/ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | ###LogSD $phone->talk( level => 'debug', message =>[ "Found a trailing negative sign", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 1 | $list_ref->[-1]->[0] = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 1 | push @$list_ref, [ undef, '-' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | # Process once to determine what to do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 88 | for my $piece ( @$list_ref ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | ###LogSD "processing number piece:", $piece ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 273 | ▶ | if( defined $piece->[0] ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 216 | ▶ | if( my @result = $piece->[0] =~ /^([0-9#\?]+)([,\-\_])?([#0\?]+)?(,+)?$/ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | ###LogSD "Regex yielded result:", @result ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 170 | ▶ | my $comma = ($2) ? $2 : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | my $comma_less = defined( $3) ? "$1$3" : $1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 170 | ▶ | my $comma_group = $3 ? length( $3 ) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 170 | ▶ | my $divide_by_thousands = ( $4 ) ? (( $2 and $2 ne ',' ) ? $4 : "$2$4" ) : undef;#eval{ $2 . $4 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$2 and $2 ne ","
MC/DC0%0/2
$2 and $2 ne ","
$2
$2 ne ","
Truth table0%0/3
A and B
A= $2B= $2 ne ","
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 170 | ▶ | my $divisor = $1 if $1 =~ /^([0-9]+)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 170 | my ( $leading_zeros, $trailinq_zeros ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 170 | ▶ | if( $comma_less =~ /^[\#\?]*(0+)$/ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 110 | $leading_zeros = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 170 | ▶ | if( $comma_less =~ /^(0+)[\#\?]*$/ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 52 | $trailinq_zeros = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 170 | ▶ | $code_hash_ref->{divide_by_thousands} = length( $divide_by_thousands ) if $divide_by_thousands; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | ###LogSD "The comma less string is extracted to: $comma_less", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | ###LogSD ((defined $comma_group) ? "The separator group length is: $comma_group" : undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | ###LogSD (($comma) ? "The separator character is: $comma" : undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | ###LogSD (($leading_zeros and length( $leading_zeros )) ? ".. w/leading zeros: $leading_zeros" : undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | ###LogSD (($trailinq_zeros and length( $trailinq_zeros )) ? ".. w/trailing zeros: $trailinq_zeros" : undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | ###LogSD (($divisor) ? "..with identified divisor: $divisor" : undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | ###LogSD 'Initial code hash:', $code_hash_ref] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 170 | ▶ | if( !$number_type ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 88 | $number_type = 'INTEGER'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 88 | ▶ | $code_hash_ref->{integer}->{leading_zeros} = length( $leading_zeros ) if $leading_zeros and length( $leading_zeros ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$leading_zeros and length $leading_zeros
MC/DC0%0/2
$leading_zeros and length $leading_zeros
$leading_zeros
length $leading_zeros
Truth table33%1/3
A and B
A= $leading_zerosB= length $leading_zeros
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 88 | $code_hash_ref->{integer}->{minimum_length} = length( $comma_less ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 88 | ▶ | if( $comma ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 56 | @{$code_hash_ref->{integer}}{ 'group_length', 'comma' } = ( $comma_group, $comma ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 88 | ▶ | if( defined $piece->[1] ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 32 | ▶ | if( $piece->[1] =~ /(\s+)/ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 20 | $code_hash_ref->{separator} = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | }elsif( $piece->[1] eq '/' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | $number_type = 'FRACTION'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | ▶ | $code_hash_ref->{numerator}->{leading_zeros} = length( $leading_zeros ) if $leading_zeros and length( $leading_zeros ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$leading_zeros and length $leading_zeros
MC/DC0%0/2
$leading_zeros and length $leading_zeros
$leading_zeros
length $leading_zeros
Truth table0%0/3
A and B
A= $leading_zerosB= length $leading_zeros
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | delete $code_hash_ref->{integer}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | ▶ | }elsif( ($number_type eq 'INTEGER') or $number_type eq 'DECIMAL' ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$number_type eq "INTEGER" or $number_type eq "DECIMAL"
MC/DC100%2/2
$number_type eq "INTEGER" or $number_type eq "DECIMAL"
$number_type eq "INTEGER"
$number_type eq "DECIMAL"
Truth table100%3/3
A or B
A= $number_type eq "INTEGER"B= $number_type eq "DECIMAL"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 56 | ▶ | if( $piece->[1] and $piece->[1] eq '/'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$piece->[1] and $piece->[1] eq "/"
MC/DC100%2/2
$piece->[1] and $piece->[1] eq "/"
$piece->[1]
$piece->[1] eq "/"
Truth table100%3/3
A and B
A= $piece->[1]B= $piece->[1] eq "/"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 20 | $number_type = 'FRACTION'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 36 | $number_type = 'DECIMAL'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 36 | ▶ | $code_hash_ref->{decimal}->{trailing_zeros} = length( $trailinq_zeros ) if $trailinq_zeros and length( $trailinq_zeros ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$trailinq_zeros and length $trailinq_zeros
MC/DC50%1/2
$trailinq_zeros and length $trailinq_zeros
$trailinq_zeros
length $trailinq_zeros
Truth table66%2/3
A and B
A= $trailinq_zerosB= length $trailinq_zeros
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 36 | $code_hash_ref->{decimal}->{max_length} = length( $comma_less ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | ▶ | }elsif( ($number_type eq 'SCIENTIFIC') or $number_type eq 'FRACTION' ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$number_type eq "SCIENTIFIC" or $number_type eq "FRACTION"
MC/DC0%0/2
$number_type eq "SCIENTIFIC" or $number_type eq "FRACTION"
$number_type eq "SCIENTIFIC"
$number_type eq "FRACTION"
Truth table66%2/3
A or B
A= $number_type eq "SCIENTIFIC"B= $number_type eq "FRACTION"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 26 | ▶ | $code_hash_ref->{exponent}->{leading_zeros} = length( $leading_zeros ) if $leading_zeros and length( $leading_zeros ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$leading_zeros and length $leading_zeros
MC/DC50%1/2
$leading_zeros and length $leading_zeros
$leading_zeros
length $leading_zeros
Truth table66%2/3
A and B
A= $leading_zerosB= length $leading_zeros
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 26 | $code_hash_ref->{fraction}->{target_length} = length( $comma_less ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 26 | ▶ | if( $divisor ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 14 | $code_hash_ref->{fraction}->{divisor} = $divisor; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | ###LogSD $phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | ###LogSD "Current number type: $number_type", 'updated settings:', $code_hash_ref] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | }elsif( $piece->[0] =~ /^((\.)|([Ee][+\-])|(%))$/ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 46 | ▶ | if( $2 ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 36 | $number_type = 'DECIMAL'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 36 | $code_hash_ref->{separator} = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | }elsif( $3 ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 6 | $number_type = 'SCIENTIFIC'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 6 | $code_hash_ref->{separator} = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 4 | $number_type = 'PERCENT'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | ###LogSD "Number type now: $number_type" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 0 | confess "badly formed number format passed: $piece->[0]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | # Set negative type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 88 | ▶ | if( $type_filter->name eq 'NegativeNum' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | ###LogSD "Setting this as a negative number type" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 25 | $code_hash_ref->{negative_type} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 88 | my $method = '_build_' . lc( $number_type ) . '_sub'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | ###LogSD $phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | ###LogSD "Resolved the number type to: $number_type", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | ###LogSD 'Working with settings:', $list_ref, $code_hash_ref ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 88 | my $conversion_sub = $self->$method( $type_filter, $list_ref, $code_hash_ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 88 | return( $number_type, $type_filter, $conversion_sub ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 28 | ▶ | sub _build_integer_sub{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_integer_sub: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 28 | my( $self, $type_filter, $list_ref, $conversion_defs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | ###LogSD $self->get_all_space . '::hidden::_build_number::_build_integer_sub', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | ###LogSD "Building an anonymous sub to return integer values", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | ###LogSD 'With type constraint: ' . $type_filter->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | ###LogSD '..using list ref:' , $list_ref, '..and conversion defs:', $conversion_defs ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 28 | my $sprintf_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | # Process once to determine what to do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 28 | my $found_integer = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 28 | for my $piece ( @$list_ref ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | ###LogSD "processing number piece:", $piece ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 56 | ▶ | if( !$found_integer and defined $piece->[0] ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $found_integer and defined $piece->[0]
MC/DC50%1/2
not $found_integer and defined $piece->[0]
not $found_integer
defined $piece->[0]
Truth table66%2/3
not(A) and B
A= not $found_integerB= defined $piece->[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 28 | $sprintf_string .= '%s'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 28 | $found_integer = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 56 | ▶ | if( $piece->[1] ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 36 | $sprintf_string .= $piece->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 28 | $conversion_defs->{no_decimal} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 28 | $conversion_defs->{sprintf_string} = $sprintf_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | ###LogSD "Final sprintf string: $sprintf_string" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 28 | my $dispatch_sequence = $number_build_dispatch->{decimal}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 112 | ▶ | my $conversion_sub = sub{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | #~ print "Using Integer sub!!!!!!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | ###LogSD my $sub_phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | ###LogSD $self->get_log_space . '::Cell::_hidden::_return_value_only::_build_number::_build_integer_sub', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 112 | my $adjusted_input = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 112 | ▶ | if( !defined $adjusted_input or $adjusted_input eq '' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $adjusted_input or $adjusted_input eq ""
MC/DC0%0/2
not defined $adjusted_input or $adjusted_input eq ""
not defined $adjusted_input
$adjusted_input eq ""
Truth table33%1/3
not(A) or B
A= not defined $adjusted_inputB= $adjusted_input eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | ###LogSD "Return undef for empty strings" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 112 | my $value_definitions = clone( $conversion_defs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 112 | $value_definitions->{initial_value} = $adjusted_input; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | ###LogSD $sub_phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | ###LogSD 'Building scientific output with:', $conversion_defs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | ###LogSD '..and dispatch sequence:', $dispatch_sequence ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 112 | my $built_ref = $self->_build_elements( $dispatch_sequence, $value_definitions ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | ###LogSD $sub_phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | ###LogSD "Received built ref:", $built_ref ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | my $return .= sprintf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | $built_ref->{sprintf_string}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | $built_ref->{integer}->{value} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 112 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 112 | ▶ | $return = $built_ref->{sign} . $return if $built_ref->{sign} and $return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$built_ref->{"sign"} and $return
MC/DC50%1/2
$built_ref->{"sign"} and $return
$built_ref->{"sign"}
$return
Truth table66%2/3
A and B
A= $built_ref->{"sign"}B= $return
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 112 | return $return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 28 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | ###LogSD "Conversion sub for filter name: " . $type_filter->name, $conversion_sub ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 28 | return $conversion_sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 30 | ▶ | sub _build_decimal_sub{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_decimal_sub: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 30 | my( $self, $type_filter, $list_ref, $conversion_defs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | ###LogSD $self->get_all_space . '::hidden::_build_number::_build_decimal_sub', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | ###LogSD "Building an anonymous sub to return decimal values", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | ###LogSD 'With type constraint: ' . $type_filter->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | ###LogSD '..using list ref:' , $list_ref, '..and code hash ref:', $conversion_defs ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 30 | my $sprintf_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | # Process once to determine what to do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 30 | for my $piece ( @$list_ref ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | ###LogSD "processing number piece:", $piece ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 119 | ▶ | if( defined $piece->[0] ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 90 | ▶ | if( $piece->[0] eq '.' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 30 | $sprintf_string .= '.'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 60 | $sprintf_string .= '%s'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 119 | ▶ | if( $piece->[1] ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 37 | $sprintf_string .= $piece->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 30 | $conversion_defs->{sprintf_string} = $sprintf_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | ###LogSD "Final sprintf string: $sprintf_string" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 30 | my $dispatch_sequence = $number_build_dispatch->{decimal}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 114 | ▶ | my $conversion_sub = sub{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | #~ print "Using Decimal sub!!!!!!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | ###LogSD my $sub_phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | ###LogSD $self->get_log_space . '::Cell::_hidden::_return_value_only::_build_number::_build_decimal_sub', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 114 | my $adjusted_input = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 114 | ▶ | if( !defined $adjusted_input or $adjusted_input eq '' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $adjusted_input or $adjusted_input eq ""
MC/DC0%0/2
not defined $adjusted_input or $adjusted_input eq ""
not defined $adjusted_input
$adjusted_input eq ""
Truth table33%1/3
not(A) or B
A= not defined $adjusted_inputB= $adjusted_input eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | ###LogSD "Return undef for empty strings" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 114 | my $value_definitions = clone( $conversion_defs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 114 | $value_definitions->{initial_value} = $adjusted_input; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | ###LogSD $sub_phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | ###LogSD 'Building scientific output with:', $conversion_defs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | ###LogSD '..and dispatch sequence:', $dispatch_sequence ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 114 | my $built_ref = $self->_build_elements( $dispatch_sequence, $value_definitions ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | ###LogSD $sub_phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | ###LogSD "Received built ref:", $built_ref ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | my $return .= sprintf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | $built_ref->{sprintf_string}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | $built_ref->{integer}->{value}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | $built_ref->{decimal}->{value}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 114 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 114 | ▶ | $return = $built_ref->{sign} . $return if $built_ref->{sign} and $return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$built_ref->{"sign"} and $return
MC/DC50%1/2
$built_ref->{"sign"} and $return
$built_ref->{"sign"}
$return
Truth table66%2/3
A and B
A= $built_ref->{"sign"}B= $return
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 114 | return $return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 30 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | ###LogSD "Conversion sub for filter name: " . $type_filter->name, $conversion_sub ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 30 | return $conversion_sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 4 | ▶ | sub _build_percent_sub{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_percent_sub: called CC=7 SCAR=19.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 4 | my( $self, $type_filter, $list_ref, $conversion_defs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | ###LogSD $self->get_all_space . '::hidden::_build_number::_build_percent_sub', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | ###LogSD "Building an anonymous sub to return decimal values", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | ###LogSD 'With type constraint: ' . $type_filter->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | ###LogSD '..using list ref:' , $list_ref, '..and code hash ref:', $conversion_defs ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | 4 | my $sprintf_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 4 | my $decimal_count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | # Process once to determine what to do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 4 | for my $piece ( @$list_ref ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | ###LogSD "processing number piece:", $piece ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 12 | ▶ | if( defined $piece->[0] ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | 12 | ▶ | if( $piece->[0] eq '%' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 4 | $sprintf_string .= '%%'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | }elsif( $piece->[0] eq '.' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 2 | $sprintf_string .= '.'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | 6 | $sprintf_string .= '%s'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | 6 | $decimal_count++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 12 | ▶ | if( $piece->[1] ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 0 | $sprintf_string .= $piece->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 4 | ▶ | $conversion_defs->{no_decimal} = 1 if $decimal_count < 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 4 | $conversion_defs->{sprintf_string} = $sprintf_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | ###LogSD "Final sprintf string: $sprintf_string" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 4 | my $dispatch_sequence = $number_build_dispatch->{percent}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 28 | ▶ | my $conversion_sub = sub{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | #~ print "Using Percent sub!!!!!!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | ###LogSD my $sub_phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | ###LogSD $self->get_log_space . '::Cell::_hidden::_return_value_only::_build_number::_build_percent_sub', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 28 | my $adjusted_input = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 28 | ▶ | if( !defined $adjusted_input or $adjusted_input eq '' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $adjusted_input or $adjusted_input eq ""
MC/DC0%0/2
not defined $adjusted_input or $adjusted_input eq ""
not defined $adjusted_input
$adjusted_input eq ""
Truth table33%1/3
not(A) or B
A= not defined $adjusted_inputB= $adjusted_input eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | ###LogSD "Return undef for empty strings" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 28 | my $value_definitions = clone( $conversion_defs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 28 | $value_definitions->{initial_value} = $adjusted_input; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | ###LogSD $sub_phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | ###LogSD 'Building scientific output with:', $conversion_defs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | ###LogSD '..and dispatch sequence:', $dispatch_sequence ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 28 | my $built_ref = $self->_build_elements( $dispatch_sequence, $value_definitions ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | ###LogSD $sub_phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | ###LogSD "Received built ref:", $built_ref ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 28 | my $return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 28 | ▶ | if( $decimal_count < 2 ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | $return .= sprintf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | $built_ref->{sprintf_string}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | $built_ref->{integer}->{value}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | 14 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | $return .= sprintf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | $built_ref->{sprintf_string}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | $built_ref->{integer}->{value}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | $built_ref->{decimal}->{value}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 14 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 28 | ▶ | $return = $built_ref->{sign} . $return if $built_ref->{sign} and $return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$built_ref->{"sign"} and $return
MC/DC50%1/2
$built_ref->{"sign"} and $return
$built_ref->{"sign"}
$return
Truth table66%2/3
A and B
A= $built_ref->{"sign"}B= $return
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 28 | return $return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | ###LogSD "Conversion sub for filter name: " . $type_filter->name, $conversion_sub ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | 4 | return $conversion_sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 6 | ▶ | sub _build_scientific_sub{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_scientific_sub: called CC=10 SCAR=25.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | 6 | my( $self, $type_filter, $list_ref, $conversion_defs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | ###LogSD $self->get_all_space . '::hidden::_build_number::_build_scientific_sub', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | ###LogSD "Building an anonymous sub to return scientific values", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | ###LogSD 'With type constraint: ' . $type_filter->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | ###LogSD '..using list ref:' , $list_ref, '..and code hash ref:', $conversion_defs ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | # Process once to determine what to do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | 6 | my ( $sprintf_string, $exponent_sprintf ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 6 | ▶ | $conversion_defs->{no_decimal} = ( exists $conversion_defs->{decimal} ) ? 0 : 1 ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 6 | for my $piece ( @$list_ref ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | ###LogSD "processing number piece:", $piece ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | 26 | ▶ | if( defined $piece->[0] ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | 26 | ▶ | if( $piece->[0] =~ /(E)(.)/ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | 6 | $sprintf_string .= $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 6 | $exponent_sprintf = '%'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 6 | ▶ | $exponent_sprintf .= '+' if $2 eq '+'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 6 | ▶ | if( exists $conversion_defs->{exponent}->{leading_zeros} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 2 | $exponent_sprintf .= '0.' . $conversion_defs->{exponent}->{leading_zeros}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | 6 | $exponent_sprintf .= 'd'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | }elsif( $piece->[0] eq '.' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 4 | $sprintf_string .= '.'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 4 | $conversion_defs->{no_decimal} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | }elsif( $exponent_sprintf ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 6 | $sprintf_string .= $exponent_sprintf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | 10 | $sprintf_string .= '%s'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | 26 | ▶ | if( $piece->[1] ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 0 | $sprintf_string .= $piece->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 6 | $conversion_defs->{sprintf_string} = $sprintf_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | ###LogSD "Final sprintf string: $sprintf_string" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 6 | my $dispatch_sequence = $number_build_dispatch->{scientific}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 48 | ▶ | my $conversion_sub = sub{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=11 SCAR=31.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | 48 | my $adjusted_input = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 48 | ▶ | if( !defined $adjusted_input or $adjusted_input eq '' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
not defined $adjusted_input or $adjusted_input eq ""
MC/DC0%0/2
not defined $adjusted_input or $adjusted_input eq ""
not defined $adjusted_input
$adjusted_input eq ""
Truth table33%1/3
not(A) or B
A= not defined $adjusted_inputB= $adjusted_input eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | ###LogSD "Return undef for empty strings" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | ▶ | }elsif( $adjusted_input =~ /^\-?\d*(\.\d+)?$/ or | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition8%1/12
$adjusted_input =~ /^\-?\d*(\.\d+)?$/ or $adjusted_input =~ /^(\-)?((\d{1,3})?(\.\d+)?)[Ee](\-)?(\d+)$/ and $2 and $6 and $6 < 309
$adjusted_input =~ /^(\-)?((\d{1,3})?(\.\d+)?)[Ee](\-)?(\d+)$/ and $2 and $6 and $6 < 309
$adjusted_input =~ /^(\-)?((\d{1,3})?(\.\d+)?)[Ee](\-)?(\d+)$/ and $2 and $6
$adjusted_input =~ /^(\-)?((\d{1,3})?(\.\d+)?)[Ee](\-)?(\d+)$/ and $2
MC/DC0%0/5
$adjusted_input =~ /^\-?\d*(\.\d+)?$/ or $adjusted_input =~ /^(\-)?((\d{1,3})?(\.\d+)?)[Ee](\-)?(\d+)$/ and $2 and $6 and $6 < 309
$adjusted_input =~ /^\-?\d*(\.\d+)?$/
$adjusted_input =~ /^(\-)?((\d{1,3})?(\.\d+)?)[Ee](\-)?(\d+)$/
$2
$6
$6 < 309
Truth table16%1/6
A or B and C and D and E
A= $adjusted_input =~ /^\-?\d*(\.\d+)?$/B= $adjusted_input =~ /^(\-)?((\d{1,3})?(\.\d+)?)[Ee](\-)?(\d+)$/C= $2D= $6E= $6 < 309
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | ( $adjusted_input =~ /^(\-)?((\d{1,3})?(\.\d+)?)[Ee](\-)?(\d+)$/ and $2 and $6 and $6 < 309 ) ){# Check for non-scientific numbers passed to scientific format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | ###LogSD $phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | ###LogSD "Passed the first scientific format test with: $adjusted_input" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | 48 | my $value_definitions = clone( $conversion_defs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | 48 | $value_definitions->{initial_value} = $adjusted_input; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | ###LogSD $phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | ###LogSD 'Building scientific output with:', $conversion_defs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | ###LogSD '..and dispatch sequence:', $dispatch_sequence ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | 48 | my $built_ref = $self->_build_elements( $dispatch_sequence, $value_definitions ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | ###LogSD $phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | ###LogSD "Received built ref:", $built_ref ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | 48 | my $return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 48 | ▶ | if( $built_ref->{no_decimal} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | $return .= sprintf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | $built_ref->{sprintf_string}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | $built_ref->{integer}->{value}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | $built_ref->{exponent}->{value} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 16 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | $return .= sprintf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | $built_ref->{sprintf_string}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | $built_ref->{integer}->{value}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | $built_ref->{decimal}->{value} , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | $built_ref->{exponent}->{value} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | 32 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | 48 | ▶ | $return = $built_ref->{sign} . $return if $built_ref->{sign} and $return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$built_ref->{"sign"} and $return
MC/DC50%1/2
$built_ref->{"sign"} and $return
$built_ref->{"sign"}
$return
Truth table66%2/3
A and B
A= $built_ref->{"sign"}B= $return
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | 48 | return $return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | ###LogSD $phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | ###LogSD "Doesn't really seem like this is a scientific number recognized by excel: $adjusted_input" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 0 | return $adjusted_input; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | ###LogSD "Conversion sub for filter name: " . $type_filter->name, $conversion_sub ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | 6 | return $conversion_sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | 20 | ▶ | sub _build_fraction_sub{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_fraction_sub: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 20 | my( $self, $type_filter, $list_ref, $conversion_defs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | ###LogSD $self->get_all_space . '::hidden::_build_number::_build_fraction_sub', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | ###LogSD "Building an anonymous sub to return integer and fraction strings", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | ###LogSD 'With type constraint: ' . $type_filter->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | ###LogSD '..using list ref:' , $list_ref, '..and code hash ref:', $conversion_defs ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | # I'm worried about pulling the sprintf parser out of here and I may need to put it back sometime | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | 20 | my $dispatch_sequence = $number_build_dispatch->{fraction}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | 460 | ▶ | my $conversion_sub = sub{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=10 SCAR=23.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | #~ print "Using Fraction sub!!!!!!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | ###LogSD my $sub_phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | ###LogSD $self->get_log_space . '::Cell::_hidden::_return_value_only::_build_number::_build_fraction_sub', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | 460 | my $adjusted_input = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | 460 | ▶ | if( !defined $adjusted_input or $adjusted_input eq '' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $adjusted_input or $adjusted_input eq ""
MC/DC0%0/2
not defined $adjusted_input or $adjusted_input eq ""
not defined $adjusted_input
$adjusted_input eq ""
Truth table33%1/3
not(A) or B
A= not defined $adjusted_inputB= $adjusted_input eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | ###LogSD $sub_phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | ###LogSD "Return undef for empty strings" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | 460 | my $value_definitions = clone( $conversion_defs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | 460 | $value_definitions->{initial_value} = $adjusted_input; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | ###LogSD $sub_phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | ###LogSD 'Building scientific output with:', $conversion_defs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | ###LogSD '..and dispatch sequence:', $dispatch_sequence ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | 460 | my $built_ref = $self->_build_elements( $dispatch_sequence, $value_definitions ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | ###LogSD $sub_phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | ###LogSD "Received built ref:", $built_ref ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | 460 | my $return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | 460 | ▶ | if( $built_ref->{integer}->{value} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | 298 | $return = sprintf( '%s', $built_ref->{integer}->{value} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 298 | ▶ | if( $built_ref->{fraction}->{value} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | 234 | $return .= ' '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | 460 | ▶ | if( $built_ref->{fraction}->{value} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | 332 | $return .= $built_ref->{fraction}->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | 460 | ▶ | if( !$return and $built_ref->{initial_value} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $return and $built_ref->{"initial_value"}
MC/DC50%1/2
not $return and $built_ref->{"initial_value"}
not $return
$built_ref->{"initial_value"}
Truth table66%2/3
not(A) and B
A= not $returnB= $built_ref->{"initial_value"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | 64 | $return = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | 460 | ▶ | $return = $built_ref->{sign} . $return if $built_ref->{sign} and $return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$built_ref->{"sign"} and $return
MC/DC100%2/2
$built_ref->{"sign"} and $return
$built_ref->{"sign"}
$return
Truth table100%3/3
A and B
A= $built_ref->{"sign"}B= $return
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | 460 | return $return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | 20 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | ###LogSD "Conversion sub for filter name: " . $type_filter->name, $conversion_sub ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | 20 | return $conversion_sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | 762 | ▶ | sub _build_elements{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_elements: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 762 | my( $self, $dispatch_ref, $value_definitions, ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | ###LogSD $self->get_all_space . '::hidden::_build_number::_build_elements', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | ###LogSD 'Reached the dispatcher for number building with:', $value_definitions, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | ###LogSD '..using dispatch list', $dispatch_ref ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | 762 | for my $method ( @$dispatch_ref ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | 3398 | $value_definitions = $self->$method( $value_definitions ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | ###LogSD 'Updated value definitions:', $value_definitions, ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | 762 | return $value_definitions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | 762 | ▶ | sub _convert_negative{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_convert_negative: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | 762 | my( $self, $value_definitions, ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | ###LogSD $self->get_all_space . '::hidden::_build_number::_build_elements::_convert_negative', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | ###LogSD 'Reached _convert_negative with:', $value_definitions, ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | 762 | ▶ | if( $value_definitions->{negative_type} and $value_definitions->{initial_value} < 0 ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$value_definitions->{"negative_type"} and $value_definitions->{"initial_value"} < 0
MC/DC50%1/2
$value_definitions->{"negative_type"} and $value_definitions->{"initial_value"} < 0
$value_definitions->{"negative_type"}
$value_definitions->{"initial_value"} < 0
Truth table66%2/3
A and B
A= $value_definitions->{"negative_type"}B= $value_definitions->{"initial_value"} < 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | 73 | $value_definitions->{initial_value} = $value_definitions->{initial_value} * -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | ###LogSD 'updated value definitions:', $value_definitions, ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 762 | return $value_definitions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | 226 | ▶ | sub _divide_by_thousands{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_divide_by_thousands: called CC=3 SCAR=13.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | 226 | my( $self, $value_definitions, ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | ###LogSD $self->get_all_space . '::hidden::_build_number::_build_elements::_divide_by_thousands', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | ###LogSD 'Reached _convert_to_percent with:', $value_definitions, ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | 226 | ▶ | if( $value_definitions->{initial_value} and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$value_definitions->{"initial_value"} and $value_definitions->{"divide_by_thousands"}
MC/DC0%0/2
$value_definitions->{"initial_value"} and $value_definitions->{"divide_by_thousands"}
$value_definitions->{"initial_value"}
$value_definitions->{"divide_by_thousands"}
Truth table33%1/3
A and B
A= $value_definitions->{"initial_value"}B= $value_definitions->{"divide_by_thousands"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | $value_definitions->{divide_by_thousands} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | $value_definitions->{initial_value} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | $value_definitions->{initial_value}/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | 0 | ( 1000**$value_definitions->{divide_by_thousands} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | ###LogSD 'updated value definitions:', $value_definitions, ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | 226 | return $value_definitions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | 28 | ▶ | sub _convert_to_percent{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_convert_to_percent: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | 28 | my( $self, $value_definitions, ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | ###LogSD $self->get_all_space . '::hidden::_build_number::_build_elements::_convert_to_percent', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | ###LogSD 'Reached _convert_to_percent with:', $value_definitions, ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | 28 | $value_definitions->{initial_value} = $value_definitions->{initial_value} * 100; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | ###LogSD 'updated value definitions:', $value_definitions, ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | 28 | return $value_definitions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | 762 | ▶ | sub _split_decimal_integer{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_split_decimal_integer: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | 762 | my( $self, $value_definitions, ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | ###LogSD $self->get_all_space . '::hidden::_build_number::_build_elements::_split_decimal_integer', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | ###LogSD 'Reached _split_decimal_integer with:', $value_definitions, ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | # Extract negative sign | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | 762 | ▶ | if( $value_definitions->{initial_value} < 0 ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | 272 | $value_definitions->{sign} = '-'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | 272 | $value_definitions->{initial_value} = $value_definitions->{initial_value} * -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | # Build the integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | 762 | $value_definitions->{integer}->{value} = int( $value_definitions->{initial_value} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | # Build the decimal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | 762 | $value_definitions->{decimal}->{value} = $value_definitions->{initial_value} - $value_definitions->{integer}->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | ###LogSD $phone->talk( level => 'debug', message =>[ 'Updated ref: ', $value_definitions ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | 762 | return $value_definitions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | 48 | ▶ | sub _move_decimal_point{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_move_decimal_point: called CC=8 SCAR=21.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | 48 | my( $self, $value_definitions, ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | ###LogSD $self->get_all_space . '::hidden::_build_number::_build_elements::_move_decimal_point', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | ###LogSD 'Reached _move_decimal_point with:', $value_definitions, ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | 48 | my ( $exponent, $stopped ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | 48 | ▶ | if(defined $value_definitions->{integer}->{value} and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $value_definitions->{"integer"}{"value"} and sprintf("%.0f", $value_definitions->{"integer"}{"value"}) =~ /([1-9])/
MC/DC50%1/2
defined $value_definitions->{"integer"}{"value"} and sprintf("%.0f", $value_definitions->{"integer"}{"value"}) =~ /([1-9])/
defined $value_definitions->{"integer"}{"value"}
sprintf("%.0f", $value_definitions->{"integer"}{"value"}) =~ /([1-9])/
Truth table66%2/3
A and B
A= defined $value_definitions->{"integer"}{"value"}B= sprintf("%.0f", $value_definitions->{"integer"}{"value"}) =~ /([1-9])/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | sprintf( '%.0f', $value_definitions->{integer}->{value} ) =~ /([1-9])/ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | 36 | $stopped = $+[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | ###LogSD $phone->talk( level => 'debug', message =>[ "Matched integer value at: $stopped", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | 36 | $exponent = length( sprintf( '%.0f', $value_definitions->{integer}->{value} ) ) - $stopped; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | }elsif( $value_definitions->{decimal}->{value} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | 12 | ▶ | if( $value_definitions->{decimal}->{value} =~ /E(-?\d+)$/i ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | 12 | $exponent = $1 * 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | }elsif( $value_definitions->{decimal}->{value} =~ /([1-9])/ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | 0 | $exponent = $+[0] * -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | 0 | $exponent += 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | ###LogSD $phone->talk( level => 'debug', message =>[ "Matched decimal value at: $exponent", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | 0 | $exponent = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | ###LogSD $phone->talk( level => 'debug', message =>[ "Initial exponent: $exponent", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | 48 | my $exponent_remainder = $exponent % $value_definitions->{integer}->{minimum_length}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | ###LogSD $phone->talk( level => 'debug', message =>[ "Exponent remainder: $exponent_remainder", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | 48 | $exponent -= $exponent_remainder; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | ###LogSD $phone->talk( level => 'debug', message =>[ "New exponent: $exponent", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | 48 | $value_definitions->{exponent}->{value} = $exponent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | 48 | ▶ | if( $exponent < 0 ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | 12 | my $adjustment = '1' . (0 x abs($exponent)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | ###LogSD "The exponent |$exponent| is less than zero - the decimal must move to the right by: $adjustment" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | 12 | my $new_integer = $value_definitions->{integer}->{value} * $adjustment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | 12 | my $new_decimal = $value_definitions->{decimal}->{value} * $adjustment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | 12 | my $decimal_int = int( $new_decimal ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | ###LogSD "Bumped integer: $new_integer", "Bumped decimal: $new_decimal", "Decimal integer: $decimal_int" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | 12 | $value_definitions->{integer}->{value} = $new_integer + $decimal_int; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | 12 | $value_definitions->{decimal}->{value} = $new_decimal - $decimal_int; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | }elsif( $exponent > 0 ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | 22 | my $adjustment = '1' . (0 x $exponent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | ###LogSD "The exponent -$exponent- is greater than zero - the decimal must move to the left" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | 22 | my $new_integer = $value_definitions->{integer}->{value} / $adjustment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | 22 | my $new_decimal = $value_definitions->{decimal}->{value} / $adjustment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | 22 | my $integer_int = int( $new_integer ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | 22 | $value_definitions->{integer}->{value} = $integer_int; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | 22 | $value_definitions->{decimal}->{value} = $new_decimal + ($new_integer - $integer_int); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | ###LogSD 'Updated ref:', $value_definitions ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | 48 | return $value_definitions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | 302 | ▶ | sub _round_decimal{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_round_decimal: called CC=7 SCAR=19.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | 302 | my( $self, $value_definitions, ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | ###LogSD $self->get_all_space . '::hidden::_build_number::_build_elements::_round_decimal', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | ###LogSD 'Reached _round_decimal with:', $value_definitions, ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | 302 | ▶ | if( $value_definitions->{no_decimal} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | 142 | ▶ | if( $value_definitions->{decimal}->{value} > 0.4998 ){# Err on the side of fixing precision up | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | ###LogSD 'Rouding the integer -' . $value_definitions->{integer}->{value} . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | ###LogSD "- for the no-decimal condition with decimal: $value_definitions->{decimal}->{value}", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | 34 | $value_definitions->{integer}->{value}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | 142 | delete $value_definitions->{decimal}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | }elsif( $value_definitions->{decimal}->{max_length} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | ###LogSD "Enforcing decimal max length: " . $value_definitions->{decimal}->{max_length} ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | 160 | ▶ | if( $value_definitions->{decimal}->{value} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | 70 | my $adder = '0.' . (0 x $value_definitions->{decimal}->{max_length}) . '00002'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | 70 | my $sprintf_string = '%.' . $value_definitions->{decimal}->{max_length} . 'f'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | 70 | my $round_decimal = sprintf( $sprintf_string, ($value_definitions->{decimal}->{value}+$adder) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | ###LogSD "Sprintf string: $sprintf_string", "Rounded decimal: $round_decimal", "Adder: $adder",] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | 70 | ▶ | if( $round_decimal >= 1 ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | 0 | $value_definitions->{integer}->{value}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | 0 | $round_decimal -= 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | ###LogSD "New integer: " . $value_definitions->{integer}->{value}, "New decimal: $round_decimal" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | 70 | my $decimal_multiply = '1' . (0 x $value_definitions->{decimal}->{max_length}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | 70 | my $string_sprintf = '%0' . $value_definitions->{decimal}->{max_length} . 's'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | 70 | $value_definitions->{decimal}->{value} = sprintf( $string_sprintf, ($round_decimal * $decimal_multiply) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | 160 | ▶ | if( !$value_definitions->{decimal}->{value} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | 92 | $value_definitions->{decimal}->{value} = 0 x $value_definitions->{decimal}->{max_length}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | ###LogSD 'Updated ref:', $value_definitions ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | 302 | return $value_definitions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | 762 | ▶ | sub _add_commas{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_commas: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | 762 | my( $self, $value_definitions, ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | ###LogSD $self->get_all_space . '::hidden::_build_number::_build_elements::_add_commas', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | ###LogSD 'Reached _add_commas with:', $value_definitions, ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | 762 | ▶ | if( exists $value_definitions->{integer}->{comma} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | $value_definitions->{integer}->{value} = $self->_add_integer_separator( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | sprintf( '%.0f', $value_definitions->{integer}->{value} ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | $value_definitions->{integer}->{comma}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | $value_definitions->{integer}->{group_length}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | 214 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | ###LogSD 'Updated ref:', $value_definitions ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | 762 | return $value_definitions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | 48 | ▶ | sub _pad_exponent{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pad_exponent: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | 48 | my( $self, $value_definitions, ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | ###LogSD $self->get_all_space . '::hidden::_build_number::_build_elements::_pad_exponent', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | ###LogSD 'Reached _pad_exponent with:', $value_definitions, ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | 48 | ▶ | if( $value_definitions->{exponent}->{leading_zeros} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | 16 | my $pad_string = '%0' . $value_definitions->{exponent}->{leading_zeros} . 's'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | $value_definitions->{exponent}->{value} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | 16 | sprintf( $pad_string, sprintf( '%.0f', $value_definitions->{exponent}->{value} ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | ###LogSD 'Updated ref:', $value_definitions ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | 48 | return $value_definitions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | 460 | ▶ | sub _build_fraction{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_fraction: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | 460 | my( $self, $value_definitions, ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | ###LogSD $self->get_all_space . '::hidden::_build_number::_build_elements::_build_fraction', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | ###LogSD 'Reached _build_fraction with:', $value_definitions, ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | 460 | ▶ | if( $value_definitions->{decimal}->{value} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | $value_definitions->{fraction}->{value} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | ( $value_definitions->{fraction}->{divisor} ) ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | $self->_build_divisor_fraction( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | $value_definitions->{fraction}->{divisor}, $value_definitions->{decimal}->{value} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | ) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | $self->_continued_fraction( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | $value_definitions->{decimal}->{value}, 20, $value_definitions->{fraction}->{target_length}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | 460 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | 460 | delete $value_definitions->{decimal}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | 460 | ▶ | $value_definitions->{fraction}->{value} //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$value_definitions->{"fraction"}{"value"} //= 0
MC/DC100%1/1
$value_definitions->{"fraction"}{"value"} //= 0
$value_definitions->{"fraction"}{"value"}
Truth table100%2/2
A
A= $value_definitions->{"fraction"}{"value"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | 460 | ▶ | if( $value_definitions->{fraction}->{value} eq '1' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | 46 | $value_definitions->{integer}->{value}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | 46 | $value_definitions->{fraction}->{value} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | ###LogSD 'Updated ref:', $value_definitions ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | 460 | return $value_definitions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | 276 | ▶ | sub _build_divisor_fraction{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_divisor_fraction: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | 276 | my( $self, $divisor, $decimal ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | ###LogSD $self->get_all_space . '::hidden::_build_number::_build_elements::_build_divisor_fraction', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | ###LogSD 'Reached _build_divisor_fraction with:', $divisor, $decimal ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | 276 | my $low_numerator = int( $divisor * $decimal ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | 276 | my $high_numerator = $low_numerator + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | 276 | my $low_delta = $decimal - ($low_numerator / $divisor); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | 276 | my $high_delta = ($high_numerator / $divisor) - $decimal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | 276 | my $return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | 276 | my $add_denominator = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | 276 | ▶ | if( $low_delta < $high_delta ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | 154 | $return = $low_numerator; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | 154 | ▶ | $add_denominator = 1 if $return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | 122 | $return = $high_numerator; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | 122 | ▶ | if( $high_numerator == $divisor ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | 34 | $return = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | 88 | $add_denominator = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | 276 | ▶ | $return .= "/$divisor" if $add_denominator; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | ###LogSD "Final fraction: $return" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | 276 | return $return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | 214 | ▶ | sub _add_integer_separator{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_integer_separator: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | 214 | my ( $self, $int, $comma, $frequency ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | ###LogSD $self->get_all_space . '::hidden::_util_function::_add_integer_separator', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | ###LogSD "Attempting to add the separator -$comma- to " . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | ###LogSD "the integer portion of: $int" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | 214 | ▶ | $comma //= ','; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$comma //= ","
MC/DC0%0/1
$comma //= ","
$comma
Truth table50%1/2
A
A= $comma
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | 214 | my @number_segments; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | 214 | ▶ | if( is_Int( $int ) ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | 214 | ▶ | while( $int =~ /(-?\d+)(\d{$frequency})$/ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | 146 | $int= $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | 146 | unshift @number_segments, $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | 214 | unshift @number_segments, $int; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | ###LogSD 'Final parsed list:', @number_segments ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | 214 | return join( $comma, @number_segments ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | ###LogSD $phone->talk( level => 'warn', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | ###LogSD "-$int- is not an integer!" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | 184 | ▶ | sub _continued_fraction{# http://www.perlmonks.org/?node_id=41961 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_continued_fraction: called CC=17 SCAR=28.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | 184 | my ( $self, $decimal, $max_iterations, $max_digits ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | ###LogSD $self->get_all_space . '::hidden::_util_function::_continued_fraction', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | ###LogSD "Attempting to build an integer fraction with decimal: $decimal", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | ###LogSD "Using max iterations: $max_iterations", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | ###LogSD "..and max digits: $max_digits", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | 184 | my @continuous_integer_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | 184 | my $start_decimal = $decimal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | 184 | ▶ | confess "Passed bad decimal: $decimal" if !is_Num( $decimal ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | 184 | ▶ | while( $max_iterations > 0 and ($decimal >= 0.00001) ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$max_iterations > 0 and $decimal >= "1e-05"
MC/DC50%1/2
$max_iterations > 0 and $decimal >= "1e-05"
$max_iterations > 0
$decimal >= "1e-05"
Truth table66%2/3
A and B
A= $max_iterations > 0B= $decimal >= "1e-05"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | 424 | $decimal = 1/$decimal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | 424 | ( my $integer, $decimal ) = $self->_integer_and_decimal( $decimal ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | ###LogSD "The integer of the inverse decimal is: $integer", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | ###LogSD "The remaining decimal is: $decimal" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | 424 | ▶ | if($integer > 999 or ($decimal < 0.00001 and $decimal > 1e-10) ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$integer > 999 or $decimal < "1e-05" and $decimal > "1e-10"
$decimal < "1e-05" and $decimal > "1e-10"
MC/DC100%3/3
$integer > 999 or $decimal < "1e-05" and $decimal > "1e-10"
$integer > 999
$decimal < "1e-05"
$decimal > "1e-10"
Truth table100%4/4
A or B and C
A= $integer > 999B= $decimal < "1e-05"C= $decimal > "1e-10"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | ###LogSD "Either I found a large integer: $integer", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | ###LogSD "...or the decimal is small: $decimal" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | 136 | ▶ | if( $integer <= 999 ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | 120 | push @continuous_integer_list, $integer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | 136 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | 288 | push @continuous_integer_list, $integer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | 288 | $max_iterations--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | ###LogSD "Remaining iterations: $max_iterations" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | ###LogSD "The current continuous fraction integer list is:", @continuous_integer_list ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | 184 | my ( $numerator, $denominator ) = $self->_integers_to_fraction( @continuous_integer_list ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | 184 | ▶ | if( !$numerator or ( $denominator and length( $denominator ) > $max_digits ) ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
not $numerator or $denominator and length $denominator > $max_digits
$denominator and length $denominator > $max_digits
MC/DC100%3/3
not $numerator or $denominator and length $denominator > $max_digits
not $numerator
$denominator
length $denominator > $max_digits
Truth table100%4/4
not(A) or B and C
A= not $numeratorB= $denominatorC= length $denominator > $max_digits
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | 40 | my $denom = 9 x $max_digits; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | 40 | my ( $int, $dec ) = $self->_integer_and_decimal( $start_decimal * $denom ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | 40 | $int++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | ###LogSD "Passing through the possibilities with start numerator: $int", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | ###LogSD "..and start denominator: $denom", "Against start decimal: $decimal"] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | 40 | ▶ | my $lowest = ( $start_decimal >= 0.5 ) ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | { delta => (1-$start_decimal), numerator => 1, denominator => 1 } : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | { delta => ($start_decimal-0), numerator => 0, denominator => 1 } ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | 40 | ▶ | while( $int ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | 2322 | my @check_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | 2322 | my $low_int = $int - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | 2322 | my $low_denom = int( $low_int/$start_decimal ) + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | 2322 | push @check_list, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | { delta => abs( $int/$denom - $start_decimal ), numerator => $int, denominator => $denom }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | { delta => abs( $low_int/$denom - $start_decimal ), numerator => $low_int, denominator => $denom }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | { delta => abs( $low_int/$low_denom - $start_decimal ), numerator => $low_int, denominator => $low_denom }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | { delta => abs( $int/$low_denom - $start_decimal ), numerator => $int, denominator => $low_denom }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | 2322 | my @fixed_list = sort { $a->{delta} <=> $b->{delta} } @check_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | ###LogSD $phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | ###LogSD 'Built possible list of lower fractions:', @fixed_list ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | 2322 | ▶ | if( $fixed_list[0]->{delta} < $lowest->{delta} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | 30 | $lowest = $fixed_list[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | ###LogSD 'Updated lowest with:', $lowest ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | 2322 | $int = $low_int; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | 2322 | $denom = $low_denom - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | ###LogSD "Attempting new possibilities with start numerator: $int", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | ###LogSD "..and start denominator: $denom", "Against start decimal: $decimal"] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | 40 | ($numerator, $denominator) = $self->_best_fraction( @$lowest{qw( numerator denominator )} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | ###LogSD (($numerator) ? "Final numerator: $numerator" : undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | ###LogSD (($denominator) ? "Final denominator: $denominator" : undef), ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | 184 | ▶ | if( !$numerator ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | ###LogSD "Fraction is below the finite value - returning undef" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | 16 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | ▶ | }elsif( !$denominator or $denominator == 1 ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
not $denominator or $denominator == 1
MC/DC50%1/2
not $denominator or $denominator == 1
not $denominator
$denominator == 1
Truth table66%2/3
not(A) or B
A= not $denominatorB= $denominator == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | ###LogSD "Rounding up to: $numerator" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | 12 | return( $numerator ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | ###LogSD "The final fraction is: $numerator/$denominator" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | 156 | return $numerator . '/' . $denominator; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | # Takes a list of terms in a continued fraction, and converts them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | # into a fraction. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | 184 | ▶ | sub _integers_to_fraction {# ints_to_frac | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_integers_to_fraction: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | 184 | my ( $self, $numerator, $denominator) = (shift, 0, 1); # Seed with 0 (not all elements read here!) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | ###LogSD $self->get_all_space . '::hidden::_util_function::_integers_to_fraction', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | ###LogSD "Attempting to build an integer fraction with the continuous fraction list: " . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | ###LogSD join( ' - ', @_ ), "With a seed numerator of -0- and seed denominator of -1-" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | 184 | for my $integer( reverse @_ ){# Get remaining elements | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | ###LogSD $phone->talk( level => 'info', message => [ "Now processing: $integer" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | 408 | ($numerator, $denominator) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | ($denominator, $integer * $denominator + $numerator); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | ###LogSD "New numerator: $numerator", "New denominator: $denominator", ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | 184 | ($numerator, $denominator) = $self->_best_fraction($numerator, $denominator); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | ###LogSD "Updated numerator: $numerator", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | ###LogSD (($denominator) ? "..and denominator: $denominator" : undef) ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | 184 | return ( $numerator, $denominator ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | # Takes a numerator and denominator, in scalar context returns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | # the best fraction describing them, in list the numerator and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | # denominator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | 224 | ▶ | sub _best_fraction{#frac_standard | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_best_fraction: called CC=5 SCAR=17.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | 224 | my ($self, $n, $m) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | ###LogSD $self->get_all_space . '::hidden::_util_function::_best_fraction', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | ###LogSD "Finding the best fraction", "Start numerator: $n", "Start denominator: $m" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | 224 | $n = $self->_integer_and_decimal($n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | 224 | $m = $self->_integer_and_decimal($m); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | ###LogSD "Updated numerator and denominator ( $n / $m )" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | 224 | my $k = $self->_gcd($n, $m); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | ###LogSD $phone->talk( level => 'info', message => [ "Greatest common divisor: $k" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | 224 | $n = $n/$k; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | 224 | $m = $m/$k; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | ###LogSD "Reduced numerator and denominator ( $n / $m )" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | 224 | ▶ | if ($m < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | ###LogSD $phone->talk( level => 'info', message => [ "the divisor is less than zero" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | 0 | $n *= -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | 0 | $m *= -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | 224 | ▶ | $m = undef if $m == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | ###LogSD no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | ###LogSD "Final numerator and denominator ( $n / $m )" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | ###LogSD use warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | 224 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | 224 | return ($n, $m); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | }else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | 0 | ▶ | return ( $m ) ? "$n/$m" : $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | # Takes a number, returns the best integer approximation and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | # (in list context) the error. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | 912 | ▶ | sub _integer_and_decimal {# In the future see if this will merge with _split_decimal_integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_integer_and_decimal: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | 912 | my ( $self, $decimal ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1781 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | ###LogSD $self->get_all_space . '::hidden::_util_function::_integer_and_decimal', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | ###LogSD "Splitting integer from decimal for: $decimal" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | 912 | my $integer = int( $decimal ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | ###LogSD $phone->talk( level => 'info', message => [ "Integer: $integer" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | 912 | ▶ | if(wantarray){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | 464 | return($integer, $decimal - $integer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | 448 | return $integer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | # Euclidean algorithm for calculating a GCD. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | # Takes two integers, returns the greatest common divisor. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | 224 | ▶ | sub _gcd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_gcd: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | 224 | my ($self, $n, $m) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | ###LogSD $self->get_all_space . '::hidden::_util_function::_gcd', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | ###LogSD "Finding the greatest common divisor for ( $n and $m )" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | 224 | ▶ | while ($m) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | 576 | my $k = $n % $m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | ###LogSD "Remainder after division: $k" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | 576 | ($n, $m) = ($m, $k); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | ###LogSD "Updated factors ( $n and $m )" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | 224 | return $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | 0 | ▶ | around set_error => sub{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | 0 | my ($orig, $self, $error) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1817 | ###LogSD $self->get_all_space . '::set_error', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | ###LogSD "Recording the error:", $error ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | 0 | ▶ | if( $self->_has_workbook_inst ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | 0 | $self->$orig( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | 0 | print longmess( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | 32 | ▶ | around get_epoch_year => sub{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | 32 | my ($orig, $self, ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | ###LogSD $self->get_all_space . '::get_epoch_year', ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | ###LogSD $phone->talk( level => 'info', message => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | ###LogSD "Looking for the epoch year" ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | 32 | ▶ | if( $self->_has_workbook_inst ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | 16 | return $self->$orig; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | 16 | return $self->_get_alt_epoch_year; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1839 | #########1 Phinish 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1840 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1841 | 2 | ▶ | no Moose::Role; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1843 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1844 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1845 | #########1 Documentation 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1846 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||