File Coverage

tlib/Test_Compiletime_Hints.pm
Criterion Covered Total %
statement 23 23 100.0
branch 2 2 100.0
condition 2 2 100.0
subroutine 8 8 100.0
pod 0 3 0.0
total 35 38 92.1


line stmt bran cond sub pod time code
1             package Test_Compiletime_Hints;
2              
3 4     4   167826 use 5.010; use warnings;
  4     4   15  
  4         261  
  4         23  
  4         9  
  4         751  
4 4     4   2155 use Lexical::Hints;
  4         9  
  4         26  
5 4     4   25 use Test::More;
  4         6  
  4         31  
6              
7             # Initialize module's hints...
8             sub import {
9 13     13   5224 my ($package, $hint_value) = @_;
10 13 100       94 if (defined $hint_value) {
11 12         40 set_hint(cth => $hint_value);
12             }
13             }
14              
15             # Test hints are set...
16             sub verify_hint_is {
17 20     20 0 21313 my ($hint_value) = @_;
18 20   100     78 is get_hint('cth'), $hint_value => "Verifying value is now: " . ($hint_value//'undef');
19             }
20              
21             # Set hints...
22             sub set_hint_to {
23 2     2 0 1106 my ($hint_value) = @_;
24 2         10 set_hint('cth' => $hint_value);
25             }
26              
27             # Attempt to create a new hint...
28             sub set_new_hint_to {
29 1     1 0 440 my ($hint_value) = @_;
30 1         7 is eval{ set_hint('new_cth' => $hint_value); }, undef() => 'Runtime autovivification failed';
  1         13  
31 1         308 like $@, qr{^Cannot autovivify hint 'new_cth' at runtime for Test_Compiletime_Hints}
32             => 'Correct error message';
33             }
34              
35             1; # Magic true value required at end of module