line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Differences::Color; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
56822
|
use Sub::Override; |
|
1
|
|
|
|
|
3004
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
19554
|
use Term::ANSIColor qw(:constants); |
|
1
|
|
|
|
|
19703
|
|
|
1
|
|
|
|
|
850
|
|
5
|
|
|
|
|
|
|
#$Term::ANSIColor::AUTORESET = 1; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
12
|
use Exporter 'import'; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
543
|
|
8
|
|
|
|
|
|
|
our @EXPORT = qw(eq_or_diff); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Test::Differences::Color - colorize the result of Test::Differences |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Version 0.06 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use Test::More tests => 1; |
25
|
|
|
|
|
|
|
use Test::Differences::Color; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
eq_or_diff(\%hash1, \@hash2); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 EXPORT |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 eq_or_diff |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 FUNCTIONS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 eq_or_diff |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
see L |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub eq_or_diff { |
42
|
0
|
|
|
0
|
1
|
|
my (@args) = @_; |
43
|
0
|
|
|
|
|
|
my(undef, $file, $line_num) = caller; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my $override = Sub::Override->new(); |
46
|
|
|
|
|
|
|
$override->replace('Test::Builder::_print_to_fh', |
47
|
|
|
|
|
|
|
sub { |
48
|
0
|
|
|
0
|
|
|
my( $self, $fh, @msgs ) = @_; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Prevent printing headers when only compiling. Mostly for when |
51
|
|
|
|
|
|
|
# tests are deparsed with B::Deparse |
52
|
0
|
0
|
|
|
|
|
return if $^C; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my $msg = join '', @msgs; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
local( $\, $", $, ) = ( undef, ' ', '' ); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Escape each line after the first with a # so we don't |
59
|
|
|
|
|
|
|
# confuse Test::Harness. |
60
|
0
|
|
|
|
|
|
$msg =~ s{\n(?!\z)}{\n# }sg; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Stick a newline on the end if it needs it. |
63
|
0
|
0
|
|
|
|
|
$msg .= "\n" unless $msg =~ /\n\z/; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my @lines = split /\n/, $msg; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
foreach my $line (@lines) { |
68
|
0
|
|
|
|
|
|
my $match_start = $line =~ /^# \*/; |
69
|
0
|
|
|
|
|
|
my $match_end = $line =~ /\*$/; |
70
|
|
|
|
|
|
|
|
71
|
0
|
0
|
0
|
|
|
|
if ($match_start && $match_end) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
print $fh ON_RED, $line, RESET, "\n"; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
elsif ($match_start) { |
75
|
0
|
|
|
|
|
|
print $fh ON_BLUE, $line, RESET, "\n"; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
elsif ($match_end) { |
78
|
0
|
|
|
|
|
|
print $fh ON_GREEN, $line, RESET, "\n"; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
else { |
81
|
0
|
|
|
|
|
|
print $fh $line, "\n"; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
return; |
86
|
|
|
|
|
|
|
}, |
87
|
0
|
|
|
|
|
|
); |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
require Test::Differences; |
90
|
0
|
|
|
|
|
|
my $return = Test::Differences::eq_or_diff(@args); |
91
|
0
|
|
|
|
|
|
$override->restore(); |
92
|
0
|
|
|
|
|
|
return $return; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 SEE ALSO |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
L |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 AUTHOR |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Alec Chen, C<< >> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 BUGS |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 SUPPORT |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
perldoc Test::Differences::Color |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
You can also look for information at: |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=over 4 |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
L |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
L |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item * CPAN Ratings |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
L |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item * Search CPAN |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
L |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=back |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Copyright 2008 Alec Chen, all rights reserved. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
140
|
|
|
|
|
|
|
under the same terms as Perl itself. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
1; # End of Test::Differences::Color |