| 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
| |||||||||||||
| 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"
MC/DC100%1/1
$hint_value // "undef"
$hint_value
Truth table100%2/2
A
A= $hint_value
| |||||||||||||
| 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 | |||||||||||