line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Plugin::UTF8; |
2
|
156
|
|
|
156
|
|
2590
|
use strict; |
|
156
|
|
|
|
|
2693
|
|
|
156
|
|
|
|
|
4448
|
|
3
|
156
|
|
|
156
|
|
810
|
use warnings; |
|
156
|
|
|
|
|
340
|
|
|
156
|
|
|
|
|
6357
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000153'; |
6
|
|
|
|
|
|
|
|
7
|
156
|
|
|
156
|
|
900
|
use Carp qw/croak/; |
|
156
|
|
|
|
|
379
|
|
|
156
|
|
|
|
|
8341
|
|
8
|
|
|
|
|
|
|
|
9
|
156
|
|
|
|
|
41889
|
use Test2::API qw{ |
10
|
|
|
|
|
|
|
test2_add_callback_post_load |
11
|
|
|
|
|
|
|
test2_stack |
12
|
156
|
|
|
156
|
|
2126
|
}; |
|
156
|
|
|
|
|
145269
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $LOADED = 0; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub import { |
17
|
314
|
|
|
314
|
|
673
|
my $class = shift; |
18
|
|
|
|
|
|
|
|
19
|
314
|
|
|
|
|
602
|
my $import_utf8 = 1; |
20
|
314
|
|
|
|
|
1265
|
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
|
314
|
50
|
|
|
|
1005
|
if ( $import_utf8 ) { |
27
|
314
|
|
|
|
|
2883
|
require utf8; |
28
|
314
|
|
|
|
|
1858
|
utf8->import; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
314
|
100
|
|
|
|
2090
|
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
|
156
|
|
|
156
|
|
50092
|
my $stack = test2_stack; |
36
|
156
|
|
|
|
|
2305
|
$stack->top; # Make sure we have at least 1 hub |
37
|
|
|
|
|
|
|
|
38
|
156
|
|
|
|
|
2805505
|
my $warned = 0; |
39
|
156
|
|
|
|
|
1123
|
for my $hub ($stack->all) { |
40
|
156
|
|
50
|
|
|
1482
|
my $format = $hub->format || next; |
41
|
|
|
|
|
|
|
|
42
|
156
|
50
|
|
|
|
2510
|
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
|
156
|
|
|
|
|
793
|
$format->encoding('utf8'); |
48
|
|
|
|
|
|
|
} |
49
|
156
|
|
|
|
|
1796
|
}); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |