line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Plugin::Wrap2ndArgumentOfFailedCompareTestWithString; |
2
|
1
|
|
|
1
|
|
1030
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
108
|
|
4
|
1
|
|
|
1
|
|
7
|
use PPIx::Utils qw(parse_arg_list); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
95
|
|
5
|
1
|
|
|
1
|
|
7
|
use PPI; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
109
|
|
6
|
1
|
|
|
|
|
333
|
use Test2::API qw( |
7
|
|
|
|
|
|
|
test2_add_callback_post_load |
8
|
|
|
|
|
|
|
test2_stack |
9
|
1
|
|
|
1
|
|
9
|
); |
|
1
|
|
|
|
|
1
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $loaded = 0; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub import { |
14
|
1
|
|
|
1
|
|
11
|
my ($class) = @_; |
15
|
|
|
|
|
|
|
|
16
|
1
|
50
|
|
|
|
16
|
return if $loaded++; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
test2_add_callback_post_load(sub { |
19
|
1
|
|
|
1
|
|
28
|
my $hub = test2_stack()->top; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
23
|
$hub->listen(\&listener, inherit => 1); |
22
|
1
|
|
|
|
|
7
|
}); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub listener { |
26
|
2
|
|
|
2
|
0
|
1193
|
my ($hub, $event) = @_; |
27
|
|
|
|
|
|
|
|
28
|
2
|
50
|
|
|
|
86
|
return unless $event->causes_fail; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $trace = $event->trace; |
31
|
0
|
|
|
|
|
|
my $file = $trace->file; |
32
|
0
|
|
|
|
|
|
my $line = $trace->line; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $doc = PPI::Document->new($file); |
35
|
|
|
|
|
|
|
my $stmt = $doc->find_first(sub { |
36
|
0
|
|
|
0
|
|
|
my (undef, $elem) = @_; |
37
|
0
|
|
0
|
|
|
|
return $elem->isa('PPI::Statement') && $elem->line_number == $line; |
38
|
0
|
|
|
|
|
|
}); |
39
|
0
|
0
|
|
|
|
|
return unless $stmt; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $second_arg = (parse_arg_list($stmt->first_token))[1]->[0]; |
42
|
0
|
0
|
|
|
|
|
return unless $second_arg; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# A -> string(A) |
45
|
0
|
|
|
|
|
|
$second_arg->insert_before(PPI::Token::Word->new('string')); |
46
|
0
|
|
|
|
|
|
$second_arg->insert_before(PPI::Token::Structure->new('(')); |
47
|
0
|
|
|
|
|
|
$second_arg->insert_after(PPI::Token::Structure->new(')')); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
$doc->save($file); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
__END__ |