File Coverage

blib/lib/RPerl/Operation/Expression/Operator/Compare/EqualNotEqual.pm
Criterion Covered Total %
statement 28 54 51.8
branch 2 16 12.5
condition 14 18 77.7
subroutine 6 8 75.0
pod n/a
total 50 96 52.0


line stmt bran cond sub pod time code
1             # [[[ HEADER ]]]
2             package RPerl::Operation::Expression::Operator::Compare::EqualNotEqual;
3 4     4   22 use strict;
  4         7  
  4         94  
4 4     4   18 use warnings;
  4         6  
  4         79  
5 4     4   18 use RPerl::AfterSubclass;
  4         9  
  4         544  
6             our $VERSION = 0.003_000;
7              
8             # [[[ OO INHERITANCE ]]]
9 4     4   25 use parent qw(RPerl::Operation::Expression::Operator::Compare);
  4         8  
  4         21  
10 4     4   139 use RPerl::Operation::Expression::Operator::Compare;
  4         8  
  4         1925  
11              
12             # [[[ CRITICS ]]]
13             ## no critic qw(ProhibitUselessNoCritic ProhibitMagicNumbers RequireCheckedSyscalls) # USER DEFAULT 1: allow numeric values & print operator
14             ## no critic qw(RequireInterpolationOfMetachars) # USER DEFAULT 2: allow single-quoted control characters & sigils
15              
16             # [[[ OO PROPERTIES ]]]
17             our hashref $properties = {};
18              
19             # [[[ SUBROUTINES & OO METHODS ]]]
20              
21             sub ast_to_rperl__generate {
22 22     22   44 { my string_hashref::method $RETURN_TYPE };
  22         42  
23 22         51 ( my object $self, my string_hashref $modes) = @ARG;
24 22         57 my string_hashref $rperl_source_group = { PMC => q{} };
25              
26             # RPerl::diag( 'in Operator::Compare::EqualNotEqual->ast_to_rperl__generate(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
27              
28 22         52 my string $self_class = ref $self;
29 22 50       62 if ( $self_class eq 'Operator_113' ) { # Operator -> SubExpression OP12_COMPARE_EQ_NE SubExpression
30 22 50 100     254 if ( ( $self->{children}->[1] ne '==' )
      100        
      100        
      100        
      66        
31             and ( $self->{children}->[1] ne '!=' )
32             and ( $self->{children}->[1] ne '<=>' )
33             and ( $self->{children}->[1] ne 'eq' )
34             and ( $self->{children}->[1] ne 'ne' )
35             and ( $self->{children}->[1] ne 'cmp' ) )
36             {
37             die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASRP29, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: comparison operator '
38 0         0 . $self->{children}->[1]
39             . ' found where ==, !=, <=>, eq, ne, or cmp expected, dying' )
40             . "\n";
41             }
42              
43 22         440 my string_hashref $rperl_source_subgroup = $self->{children}->[0]->ast_to_rperl__generate($modes);
44 22         419 RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
45 22         66 $rperl_source_group->{PMC} .= q{ } . $self->{children}->[1] . q{ };
46 22         432 $rperl_source_subgroup = $self->{children}->[2]->ast_to_rperl__generate($modes);
47 22         431 RPerl::Generator::source_group_append( $rperl_source_group, $rperl_source_subgroup );
48             }
49             else {
50 0         0 die RPerl::Parser::rperl_rule__replace(
51             'ERROR ECOGEASRP00, CODE GENERATOR, ABSTRACT SYNTAX TO RPERL: Grammar rule ' . $self_class . ' found where Operator_113 expected, dying' )
52             . "\n";
53             }
54 22         96 return $rperl_source_group;
55             }
56              
57             sub ast_to_cpp__generate__CPPOPS_PERLTYPES {
58 0     0     { my string_hashref::method $RETURN_TYPE };
  0            
59 0           ( my object $self, my string_hashref $modes) = @ARG;
60 0           my string_hashref $cpp_source_group = { CPP => q{// <<< RP::O::E::O::C::ENE __DUMMY_SOURCE_CODE CPPOPS_PERLTYPES >>>} . "\n" };
61              
62             #...
63 0           return $cpp_source_group;
64             }
65              
66             sub ast_to_cpp__generate__CPPOPS_CPPTYPES {
67 0     0     { my string_hashref::method $RETURN_TYPE };
  0            
68 0           ( my object $self, my string_hashref $modes) = @ARG;
69 0           my string_hashref $cpp_source_group = { CPP => q{} };
70              
71             # RPerl::diag( 'in Operator::Compare::EqualNotEqual->ast_to_cpp__generate__CPPOPS_CPPTYPES(), received $self = ' . "\n" . RPerl::Parser::rperl_ast__dump($self) . "\n" );
72              
73 0           my string $self_class = ref $self;
74 0 0         if ( $self_class eq 'Operator_113' ) { # Operator -> SubExpression OP12_COMPARE_EQ_NE SubExpression
75 0           my string_hashref $cpp_source_subgroup = $self->{children}->[0]->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
76 0           RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup );
77 0 0 0       if ( ( $self->{children}->[1] eq '==' ) or ( $self->{children}->[1] eq '!=' ) ) {
    0          
    0          
    0          
    0          
78 0           $cpp_source_group->{CPP} .= q{ } . $self->{children}->[1] . q{ };
79             }
80             elsif ( $self->{children}->[1] eq '<=>' ) {
81 0           $cpp_source_group->{CPP} .= ' DUMMY_THREE_WAY_COMPARISON_NUMERIC ';
82             }
83             elsif ( $self->{children}->[1] eq 'eq' ) {
84 0           $cpp_source_group->{CPP} .= ' == '; # DEV NOTE: '==' is an overload for std::string::compare()
85             }
86             elsif ( $self->{children}->[1] eq 'ne' ) {
87 0           $cpp_source_group->{CPP} .= ' != '; # DEV NOTE: '!=' is an overload for not(std::string::compare())
88             }
89             elsif ( $self->{children}->[1] eq 'cmp' ) {
90 0           $cpp_source_group->{CPP} .= ' DUMMY_THREE_WAY_COMPARISON_STRING ';
91             }
92             else {
93             die RPerl::Parser::rperl_rule__replace( 'ERROR ECOGEASCP29, CODE GENERATOR, ABSTRACT SYNTAX TO C++: comparison operator '
94 0           . $self->{children}->[1]
95             . ' found where ==, !=, <=>, eq, ne, or cmp expected, dying' )
96             . "\n";
97             }
98 0           $cpp_source_subgroup = $self->{children}->[2]->ast_to_cpp__generate__CPPOPS_CPPTYPES($modes);
99 0           RPerl::Generator::source_group_append( $cpp_source_group, $cpp_source_subgroup );
100             }
101             else {
102 0           die RPerl::Parser::rperl_rule__replace(
103             'ERROR ECOGEASCP00, CODE GENERATOR, ABSTRACT SYNTAX TO C++: Grammar rule ' . $self_class . ' found where Operator_113 expected, dying' )
104             . "\n";
105             }
106 0           return $cpp_source_group;
107             }
108              
109             1; # end of class