tlib/Test_Compiletime_Hints.pm

filter: Statementstmt 100% 23 / 23 Branchbran 100% 2 / 2 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 3 totaltotal 92.3% 36 / 39 CC 3 SCAR 3.4
CC
3
Cov
100%
import
2.0
verify_hint_is
2.0
BEGIN
1.0
CRAP 1.4
« tlib/Test_Renaming.pm ↑ Summary tlib/Test_Manual_Hints.pm »
1 package Test_Compiletime_Hints;
2  
3 4 ▶use 5.010; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Lexical::Hints;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # Initialize module's hints...
8 13 ▶sub import {
Subroutine import: called CC=2 SCAR=6.9
9 13 my ($package, $hint_value) = @_;
10 13 ▶ if (defined $hint_value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $hint_value) 12 1 13
11 12 set_hint(cth => $hint_value);
12 }
13 }
14  
15 # Test hints are set...
16 20 ▶sub verify_hint_is {
Subroutine verify_hint_is: called CC=2 SCAR=6.9
Pod undocumented
17 20 my ($hint_value) = @_;
18 20 ▶ is get_hint('cth'), $hint_value => "Verifying value is now: " . ($hint_value//'undef');
Condition100%2/2
$hint_value // "undef"
l!l
191
MC/DC100%1/1
$hint_value // "undef"
$hint_value
Truth table100%2/2
A
A= $hint_value
Aresult
11
00
19 }
20  
21 # Set hints...
22 2 ▶sub set_hint_to {
Subroutine set_hint_to: called CC=1 SCAR=0.0
Pod undocumented
23 2 my ($hint_value) = @_;
24 2 set_hint('cth' => $hint_value);
25 }
26  
27 # Attempt to create a new hint...
28 1 ▶sub set_new_hint_to {
Subroutine set_new_hint_to: called CC=1 SCAR=0.0
Pod undocumented
29 1 my ($hint_value) = @_;
30 1 is eval{ set_hint('new_cth' => $hint_value); }, undef() => 'Runtime autovivification failed';
31 1 like $@, qr{^Cannot autovivify hint 'new_cth' at runtime for Test_Compiletime_Hints}
32 => 'Correct error message';
33 }
34  
35 4 1; # Magic true value required at end of module
« tlib/Test_Renaming.pm ↑ Summary tlib/Test_Manual_Hints.pm »