« lib/Perl/ToPerl6/Transformer/Variables/QuoteHashKeys.pm
↑ Summary
lib/Test/Perl/ToPerl6/Transformer.pm »
| 1 | package Perl::ToPerl6::TransformerParameter::Behavior::Integer; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 23 | ▶ | use 5.006001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 23 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 23 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 23 | ▶ | use Perl::ToPerl6::Utils qw{ :characters }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 23 | ▶ | use base qw{ Perl::ToPerl6::TransformerParameter::Behavior }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 5 | ▶ | sub initialize_parameter { | ||||||||||||||||||||||||||
|
Subroutine
initialize_parameter: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 14 | 5 | my ($self, $parameter, $specification) = @_; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 5 | my $minimum = $specification->{integer_minimum}; | |||||||||||||||||||||||||||
| 17 | 5 | my $maximum = $specification->{integer_maximum}; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 5 | $parameter->_get_behavior_values()->{minimum} = $minimum; | |||||||||||||||||||||||||||
| 20 | 5 | $parameter->_get_behavior_values()->{maximum} = $maximum; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | $parameter->_set_parser( | ||||||||||||||||||||||||||||
| 23 | 22 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||
| 24 | # Normally bad thing, obscuring a variable in a outer scope | ||||||||||||||||||||||||||||
| 25 | # with a variable with the same name is being done here in | ||||||||||||||||||||||||||||
| 26 | # order to remain consistent with the parser function interface. | ||||||||||||||||||||||||||||
| 27 | 22 | my ($transformer, $parameter, $config_string) = @_; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 22 | my $value_string = $parameter->get_default_string(); | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 22 | ▶ | if (defined $config_string) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 20 | $value_string = $config_string; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 22 | my $value; | |||||||||||||||||||||||||||
| 36 | 22 | ▶ | if ( defined $value_string ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 21 | ▶ | if ( | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $value_string =~ / \A [-+]? [1-9] [\d_]* \z /msx and $value_string ne 0
MC/DC100%2/2
not $value_string =~ / \A [-+]? [1-9] [\d_]* \z /msx and $value_string ne 0
not $value_string =~ / \A [-+]? [1-9] [\d_]* \z /msx
$value_string ne 0
Truth table100%3/3
not(A) and B
A= not $value_string =~ / \A [-+]? [1-9] [\d_]* \z /msxB= $value_string ne 0
| |||||||||||||||||||||||||||||
| 38 | $value_string !~ m/ \A [-+]? [1-9] [\d_]* \z /xms | ||||||||||||||||||||||||||||
| 39 | and $value_string ne '0' | ||||||||||||||||||||||||||||
| 40 | ) { | ||||||||||||||||||||||||||||
| 41 | 1 | $transformer->throw_parameter_value_exception( | |||||||||||||||||||||||||||
| 42 | $parameter->get_name(), | ||||||||||||||||||||||||||||
| 43 | $value_string, | ||||||||||||||||||||||||||||
| 44 | undef, | ||||||||||||||||||||||||||||
| 45 | 'does not look like an integer.', | ||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 20 | $value_string =~ tr/_//d; | |||||||||||||||||||||||||||
| 50 | 20 | $value = $value_string + 0; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 20 | ▶ | if ( defined $minimum and $minimum > $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $minimum and $minimum > $value
MC/DC100%2/2
defined $minimum and $minimum > $value
defined $minimum
$minimum > $value
Truth table100%3/3
A and B
A= defined $minimumB= $minimum > $value
| |||||||||||||||||||||||||||||
| 53 | 2 | $transformer->throw_parameter_value_exception( | |||||||||||||||||||||||||||
| 54 | $parameter->get_name(), | ||||||||||||||||||||||||||||
| 55 | $value_string, | ||||||||||||||||||||||||||||
| 56 | undef, | ||||||||||||||||||||||||||||
| 57 | qq{is less than $minimum.}, | ||||||||||||||||||||||||||||
| 58 | ); | ||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 18 | ▶ | if ( defined $maximum and $maximum < $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $maximum and $maximum < $value
MC/DC100%2/2
defined $maximum and $maximum < $value
defined $maximum
$maximum < $value
Truth table100%3/3
A and B
A= defined $maximumB= $maximum < $value
| |||||||||||||||||||||||||||||
| 62 | 2 | $transformer->throw_parameter_value_exception( | |||||||||||||||||||||||||||
| 63 | $parameter->get_name(), | ||||||||||||||||||||||||||||
| 64 | $value_string, | ||||||||||||||||||||||||||||
| 65 | undef, | ||||||||||||||||||||||||||||
| 66 | qq{is greater than $maximum.}, | ||||||||||||||||||||||||||||
| 67 | ); | ||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 17 | $transformer->__set_parameter_value($parameter, $value); | |||||||||||||||||||||||||||
| 72 | 17 | return; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | 5 | ); | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 5 | return; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | sub generate_parameter_description { | ||||||||||||||||||||||||||
|
Subroutine
generate_parameter_description: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 82 | 0 | my ($self, $parameter) = @_; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | my $minimum = $parameter->_get_behavior_values()->{minimum}; | |||||||||||||||||||||||||||
| 85 | 0 | my $maximum = $parameter->_get_behavior_values()->{maximum}; | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | my $description = $parameter->_get_description_with_trailing_period(); | |||||||||||||||||||||||||||
| 88 | 0 | ▶ | if ( $description ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | 0 | $description .= qq{\n}; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if (defined $minimum or defined $maximum) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $minimum or defined $maximum
MC/DC0%0/2
defined $minimum or defined $maximum
defined $minimum
defined $maximum
Truth table0%0/3
A or B
A= defined $minimumB= defined $maximum
| |||||||||||||||||||||||||||||
| 93 | 0 | ▶ | if (defined $minimum) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | 0 | $description .= "Minimum value $minimum. "; | |||||||||||||||||||||||||||
| 95 | } else { | ||||||||||||||||||||||||||||
| 96 | 0 | $description .= 'No minimum. '; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if (defined $maximum) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | 0 | $description .= "Maximum value $maximum."; | |||||||||||||||||||||||||||
| 101 | } else { | ||||||||||||||||||||||||||||
| 102 | 0 | $description .= 'No maximum.'; | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | } else { | ||||||||||||||||||||||||||||
| 105 | 0 | $description .= 'No limits.'; | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | return $description; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 23 | 1; | |||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | __END__ | ||||||||||||||||||||||||||||