Branch Coverage

blib/lib/Thrift/IDL.pm
Criterion Covered Total %
branch 33 48 68.7


line true false branch
102 0 217 unless $class
105 19 198 if ($return->can('setup'))
112 0 217 if $debug
116 0 7 unless my $parser = 'Parse::RecDescent'->new(qq[ document: (comment | header | definition)(s)\n\n comment: (\n /\\/[*] .*? [*]\\//sx\n | /^\\/\\/ .*/x\n | /^[#] .*/x\n )\n { \$Thrift::IDL::wrap->({ class => 'Comment', value => \$item[1] }) }\n\n header: ( include | cpp_include | namespace )\n\n definition: (\n const\n | typedef\n | enum\n | senum\n | struct\n | service\n )\n { \$item[1] }\n\n include:\n 'include' quoted_string\n { \$Thrift::IDL::wrap->({ class => 'Include', value => \$item[2] }) }\n\n cpp_include:\n 'cpp_include' quoted_string\n { \$Thrift::IDL::wrap->({ class => 'CppInclude', value => \$item[2] }) }\n\n namespace:\n 'namespace' (word | '*') word\n { \$Thrift::IDL::wrap->({ class => 'Namespace', scope => \$item[2], value => \$item[3] }) }\n\n const:\n 'const' type name '=' value\n { \$Thrift::IDL::wrap->({ class => 'Constant', type => \$item[2], name => \$item[3], value => \$item[5] }) }\n\n typedef:\n 'typedef' type name\n { \$Thrift::IDL::wrap->({ class => 'TypeDef', type => \$item[2], name => \$item[3] }) }\n\n enum:\n 'enum' name '{' enum_pair(s /,/) '}'\n { \$Thrift::IDL::wrap->({ class => 'Enum', name => \$item[2], values => \$item[4] }) }\n\n senum:\n 'senum' name '{' quoted_string(s /,/) '}'\n { \$Thrift::IDL::wrap->({ class => 'Senum', name => \$item[2], values => \$item[4] }) }\n\n enum_pair:\n name ('=' number)(?)\n { [ \$item[1] => \$item[2][0] ] }\n\n struct:\n ('struct' | 'exception') name '{' field_statement(s /,?/) (',' | '') '}'\n { \$Thrift::IDL::wrap->({ class => \$item[1] eq 'struct' ? 'Struct' : 'Exception', name => \$item[2], children => \$item[4] }) }\n\n field_statement:\n comment | field\n\n field:\n number ':' ('optional')(?) type name ('=' value)(?)\n { \$Thrift::IDL::wrap->({ class => 'Field', id => \$item[1], optional => \$item[3][0] ? 1 : undef, type => \$item[4], name => \$item[5], default_value => \$item[6][0] }) }\n\n service:\n 'service' name ('extends' word)(?) '{' service_statement(s) '}'\n { \$Thrift::IDL::wrap->({ class => 'Service', name => \$item[2], extends => \$item[3][0], children => \$item[5] }) }\n\n service_statement:\n comment | method_statement\n\n method_statement:\n ('oneway')(?) type name '(' field_statement(s? /,?/) (',')(?) ')' (throws)(?) (',')(?)\n #{ print "\$item[0]: ".join(', ', map { "'\$_'" } \@item[1 .. \$#item]) . "\\n" }\n { \$Thrift::IDL::wrap->({\n class => 'Method',\n oneway => \$item[1][0] ? 1 : undef,\n returns => \$item[2],\n name => \$item[3],\n arguments => \$item[5],\n throws => \$item[8][0] ? \$item[8][0] : [],\n }) }\n\n throws:\n 'throws' '(' field_statement(s? /,/) ')'\n #{ print "\$item[0]: ".join(', ', map { "'\$_'" } \@item[1 .. \$#item]) . "\\n" }\n { \$item[3] }\n\n type:\n base_type | container_type | custom_type\n \n base_type:\n ('bool' | 'byte' | 'i16' | 'i32' | 'i64' | 'double' | 'string' | 'binary' | 'slist' | 'void')\n { \$Thrift::IDL::wrap->({ class => 'Type::Base', name => \$item[1] }) }\n\n custom_type:\n name\n { \$Thrift::IDL::wrap->({ class => 'Type::Custom', name => \$item[1] }) }\n\n container_type:\n map_type | set_type | list_type\n\n map_type:\n 'map' cpp_type(?) '<' type ',' type '>'\n { \$Thrift::IDL::wrap->({ class => 'Type::Map', key_type => \$item[4], val_type => \$item[6], cpp_type => \$item[2][0] }) }\n\n set_type:\n 'set' cpp_type(?) '<' type '>'\n { \$Thrift::IDL::wrap->({ class => 'Type::Set', val_type => \$item[4], cpp_type => \$item[2][0] }) }\n\n list_type:\n 'list' '<' type '>' cpp_type(?)\n { \$Thrift::IDL::wrap->({ class => 'Type::List', val_type => \$item[3], cpp_type => \$item[5][0] }) }\n\n cpp_type:\n 'cpp_type' quoted_string\n { \$item[2] }\n\n name:\n /[A-Za-z_][A-Za-z0-9_.]*/\n { if (\$Thrift::IDL::reserved_keywords{\$item[1]}) { warn "Cannot use reserved language keyword: \$item[1]\\n"; return undef } \$item[1] }\n #{ print "\$item[0]: ".join(', ', map { "'\$_'" } \@item[1 .. \$#item]) . "\\n"; \$return = \$item[1]; }\n\n word:\n /(\\w|[.])+/\n #{ print "\$item[0]: ".join(', ', map { "'\$_'" } \@item[1 .. \$#item]) . "\\n"; \$return = \$item[1]; }\n\n value:\n number | value_map\n\n value_map:\n '{' value_map_pair(s /,/) '}'\n { { map { \@\$_ } \@{ \$item[2] } } }\n\n value_map_pair:\n quoted_string ':' quoted_string\n { [ \$item[1] => \$item[3] ] }\n\n number:\n /[0-9]+/\n\n quoted_string:\n single_quoted_string | double_quoted_string\n\n double_quoted_string:\n '"' /[^"]+/ '"' \n { \$item[3] }\n\n single_quoted_string:\n "'" /[^']+/ "'"\n { \$item[3] }\n])
289 0 7 if (defined $input_fn and $$state{'_parse_input_fn_processed'}{$input_fn}++)
296 2 5 if ($input_fn)
299 0 2 unless open my $in, '<', $input_fn
307 2 5 if ($input_fn)
309 2 0 if defined $basename
316 0 7 if $input_fn and $debug
318 0 7 unless my $parsed = $class->parser($debug)->document(\$data)
320 0 7 unless ($data =~ /^\s*$/s)
323 0 0 int @lines > 20 ? :
329 0 0 if ($cropped)
340 2 5 if ($input_fn)
353 28 40 if ($child->isa('Thrift::IDL::Comment')) { }
27 13 elsif (not $child->isa('Thrift::IDL::Header')) { }
362 1 12 if ($child->isa('Thrift::IDL::Include')) { }
12 0 elsif ($child->isa('Thrift::IDL::Namespace')) { }
366 0 1 unless (-f $include_fn)
393 11 63 if $child->isa('Thrift::IDL::Method')
396 12 62 if ($child->isa('Thrift::IDL::Comment')) { }
9 53 elsif (@comments) { }
406 15 59 if ($$child{'children'})