| 1 | package Test2::Plugin::UTF8; | ||||||||||||
| 2 | 164 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 164 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | |||||||||||||
| 5 | 164 | our $VERSION = '1.302226'; | |||||||||||
| 6 | |||||||||||||
| 7 | 164 | ▶ | use Carp qw/croak/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | |||||||||||||
| 9 | 164 | ▶ | use Test2::API qw{ | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | test2_add_callback_post_load | ||||||||||||
| 11 | test2_stack | ||||||||||||
| 12 | 164 | }; | |||||||||||
| 13 | |||||||||||||
| 14 | 164 | my $LOADED = 0; | |||||||||||
| 15 | |||||||||||||
| 16 | 317 | ▶ | sub import { | ||||||||||
|
Subroutine
import: called CC=5 SCAR=17.8
| |||||||||||||
| 17 | 317 | my $class = shift; | |||||||||||
| 18 | |||||||||||||
| 19 | 317 | my $import_utf8 = 1; | |||||||||||
| 20 | 317 | ▶ | while ( my $arg = shift @_ ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 21 | 0 | ▶ | croak "Unsupported import argument '$arg'" unless $arg eq 'encoding_only'; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 22 | 0 | $import_utf8 = 0; | |||||||||||
| 23 | } | ||||||||||||
| 24 | |||||||||||||
| 25 | # Load and import UTF8 into the caller. | ||||||||||||
| 26 | 317 | ▶ | if ( $import_utf8 ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 27 | 317 | require utf8; | |||||||||||
| 28 | 317 | utf8->import; | |||||||||||
| 29 | } | ||||||||||||
| 30 | |||||||||||||
| 31 | 317 | ▶ | return if $LOADED++; # do not add multiple hooks | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 32 | |||||||||||||
| 33 | # Set the output formatters to use utf8 | ||||||||||||
| 34 | 164 | ▶ | test2_add_callback_post_load(sub { | ||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.8
| |||||||||||||
| 35 | 164 | my $stack = test2_stack; | |||||||||||
| 36 | 164 | $stack->top; # Make sure we have at least 1 hub | |||||||||||
| 37 | |||||||||||||
| 38 | 164 | my $warned = 0; | |||||||||||
| 39 | 164 | for my $hub ($stack->all) { | |||||||||||
| 40 | 165 | ▶ | my $format = $hub->format || next; | ||||||||||
|
Condition100%2/2
$hub->format || (next)
MC/DC100%1/1
$hub->format || (next)
$hub->format
Truth table100%2/2
A
A= $hub->format
| |||||||||||||
| 41 | |||||||||||||
| 42 | 164 | ▶ | unless ($format->can('encoding')) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 43 | 0 | ▶ | warn "Could not apply UTF8 to unknown formatter ($format)\n" unless $warned++; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 44 | 0 | next; | |||||||||||
| 45 | } | ||||||||||||
| 46 | |||||||||||||
| 47 | 164 | $format->encoding('utf8'); | |||||||||||
| 48 | } | ||||||||||||
| 49 | 164 | }); | |||||||||||
| 50 | } | ||||||||||||
| 51 | |||||||||||||
| 52 | 164 | 1; | |||||||||||
| 53 | |||||||||||||
| 54 | __END__ | ||||||||||||