blib/lib/Test/CodeGen/Protection.pm

filter: Statementstmt 90.2% 37 / 41 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 89.2% 50 / 56 CC 4 SCAR 6.5
CC
4
Cov
87%
is_protected_file_ok
3.4
is_protected_document_ok
2.0
BEGIN
1.0
CRAP 1.9
« lib/CodeGen/Protection/Format/Perl.pm ↑ Summary lib/CodeGen/Protection.pm »
1 package Test::CodeGen::Protection;
2  
3 # ABSTRACT: Test functions for generated files
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Test::Builder::Module;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use CodeGen::Protection qw(rewrite_code);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Module::Runtime qw(use_module);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 our @ISA = qw(Test::Builder::Module);
12 1 our @EXPORT = qw(
13 is_protected_document_ok
14 is_protected_file_ok
15 );
16  
17  
18 4 ▶sub is_protected_document_ok ($$;$) {
Subroutine is_protected_document_ok: called CC=2 SCAR=6.9
Pod documented
19 4 my ( $format, $code, $message ) = @_;
20 4 my $tb = Test::CodeGen::Protection->builder;
21 4 eval {
22 4 rewrite_code(
23 type => $format,
24 existing_code => $code,
25 protected_code => 'my $x = 1;',
26 );
27 1 1;
28 };
29 4 ▶ if ( my $error = $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $error = $@) 3 1 4
30 3 $tb->ok( 0, $message );
31 3 $tb->diag($error);
32 3 return;
33 }
34 1 $tb->ok( 1, $message );
35 }
36  
37  
38 1 ▶sub is_protected_file_ok ($$;$) {
Subroutine is_protected_file_ok: called CC=3 SCAR=12.2
Pod documented
39 1 my ( $format, $file, $message ) = @_;
40 1 my $tb = Test::CodeGen::Protection->builder;
41 1 my $code;
42 1 eval {
43 1 ▶ open my $fh, '<', $file or die "Cannot open '$file' for reading: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $file or die "Cannot open '${file}' for reading: $!" 0 1 1
44 0 $code = do { local $/; <$fh> };
45 };
46 1 ▶ if ( my $error = $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $error = $@) 1 0 1
47 1 $tb->ok( 0, $message );
48 1 $tb->diag($error);
49 1 return;
50 }
51 0 is_protected_document_ok $format, $code, $message;
52 }
53  
54 1 1;
55  
56 __END__
« lib/CodeGen/Protection/Format/Perl.pm ↑ Summary lib/CodeGen/Protection.pm »