line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Plugin::UTF8; |
2
|
157
|
|
|
157
|
|
2641
|
use strict; |
|
157
|
|
|
|
|
2881
|
|
|
157
|
|
|
|
|
4710
|
|
3
|
157
|
|
|
157
|
|
923
|
use warnings; |
|
157
|
|
|
|
|
433
|
|
|
157
|
|
|
|
|
6867
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000155'; |
6
|
|
|
|
|
|
|
|
7
|
157
|
|
|
157
|
|
970
|
use Carp qw/croak/; |
|
157
|
|
|
|
|
365
|
|
|
157
|
|
|
|
|
9006
|
|
8
|
|
|
|
|
|
|
|
9
|
157
|
|
|
|
|
46491
|
use Test2::API qw{ |
10
|
|
|
|
|
|
|
test2_add_callback_post_load |
11
|
|
|
|
|
|
|
test2_stack |
12
|
157
|
|
|
157
|
|
2170
|
}; |
|
157
|
|
|
|
|
144838
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $LOADED = 0; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub import { |
17
|
315
|
|
|
315
|
|
761
|
my $class = shift; |
18
|
|
|
|
|
|
|
|
19
|
315
|
|
|
|
|
624
|
my $import_utf8 = 1; |
20
|
315
|
|
|
|
|
1221
|
while ( my $arg = shift @_ ) { |
21
|
0
|
0
|
|
|
|
0
|
croak "Unsupported import argument '$arg'" unless $arg eq 'encoding_only'; |
22
|
0
|
|
|
|
|
0
|
$import_utf8 = 0; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Load and import UTF8 into the caller. |
26
|
315
|
50
|
|
|
|
993
|
if ( $import_utf8 ) { |
27
|
315
|
|
|
|
|
3003
|
require utf8; |
28
|
315
|
|
|
|
|
2002
|
utf8->import; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
315
|
100
|
|
|
|
2161
|
return if $LOADED++; # do not add multiple hooks |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Set the output formatters to use utf8 |
34
|
|
|
|
|
|
|
test2_add_callback_post_load(sub { |
35
|
157
|
|
|
157
|
|
52592
|
my $stack = test2_stack; |
36
|
157
|
|
|
|
|
2532
|
$stack->top; # Make sure we have at least 1 hub |
37
|
|
|
|
|
|
|
|
38
|
157
|
|
|
|
|
3106310
|
my $warned = 0; |
39
|
157
|
|
|
|
|
1328
|
for my $hub ($stack->all) { |
40
|
157
|
|
50
|
|
|
1664
|
my $format = $hub->format || next; |
41
|
|
|
|
|
|
|
|
42
|
157
|
50
|
|
|
|
2774
|
unless ($format->can('encoding')) { |
43
|
0
|
0
|
|
|
|
0
|
warn "Could not apply UTF8 to unknown formatter ($format)\n" unless $warned++; |
44
|
0
|
|
|
|
|
0
|
next; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
157
|
|
|
|
|
989
|
$format->encoding('utf8'); |
48
|
|
|
|
|
|
|
} |
49
|
157
|
|
|
|
|
2087
|
}); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |