blib/lib/Babble/Plugin/SKT.pm

filter: Statementstmt 100% 18 / 18 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 2 totaltotal 92.3% 24 / 26 CC 2 SCAR 3.4
CC
2
Cov
100%
__ANON__
2.0
BEGIN
1.0
extend_grammar
1.0
CRAP 1.4
« blib/lib/Babble/SubMatch.pm ↑ Summary blib/lib/Babble/SymbolGenerator.pm »
1 package Babble::Plugin::SKT;
2  
3 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 sub extend_grammar {
6 1 ▶ my ($self, $g) = @_;
Subroutine extend_grammar: called CC=1 SCAR=0.0
Pod undocumented
7 1 $g->add_rule(TryCatch =>
8 'try(?&PerlOWS)(?&PerlBlock)'
9 .'(?:(?&PerlOWS)catch(?&PerlOWS)(?&PerlBlock))?+'
10 );
11 1 $g->augment_rule(Statement => '(?&PerlTryCatch)');
12 }
13  
14 sub transform_to_plain {
15 3 ▶ my ($self, $top) = @_;
Subroutine transform_to_plain: called CC=1 SCAR=0.0
Pod undocumented
16 3 $top->remove_use_statement('Syntax::Keyword::Try');
17 $top->each_match_within(TryCatch => [
18 'try(?&PerlOWS)', [ try_block => '(?&PerlBlock)' ],
19 '(?:(?&PerlOWS)catch(?&PerlOWS)', [ catch_block => '(?&PerlBlock)' ], ')?+'
20 ] => sub {
21 3 ▶ my ($m) = @_;
Subroutine __ANON__: called CC=2 SCAR=6.9
22 3 my ($try, $catch) = $m->subtexts(qw(try_block catch_block));
23 3 my $text = do {
24 3 ▶ if ($catch) {
Branch: 1 branch
BranchTrueFalseTotal
if ($catch) { } 1 2 3
25 1 $try =~ s/\s*}$/; 1 }/;
26 1 'unless (eval '.$try.') '.$catch;
27 } else {
28 2 'eval '.$try;
29 }
30 };
31 3 $m->replace_text('{ local $@; '.$text.' }');
32 3 });
33 }
34  
35 1 1;
« blib/lib/Babble/SubMatch.pm ↑ Summary blib/lib/Babble/SymbolGenerator.pm »