| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::Ika::Reporter::Spec; |
|
2
|
1
|
|
|
1
|
|
21717
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
36
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
26
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use utf8; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
5
|
1
|
|
|
1
|
|
836
|
use Scope::Guard (); |
|
|
1
|
|
|
|
|
406
|
|
|
|
1
|
|
|
|
|
24
|
|
|
6
|
1
|
|
|
1
|
|
1067
|
use Term::ANSIColor qw/colored/; |
|
|
1
|
|
|
|
|
9008
|
|
|
|
1
|
|
|
|
|
386
|
|
|
7
|
1
|
|
|
1
|
|
961
|
use Term::Encoding (); |
|
|
1
|
|
|
|
|
748
|
|
|
|
1
|
|
|
|
|
715
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
|
10
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
11
|
0
|
|
|
|
|
|
my $args = shift; |
|
12
|
|
|
|
|
|
|
|
|
13
|
0
|
|
|
|
|
|
$|++; |
|
14
|
0
|
|
|
|
|
|
my $term_encoding = Term::Encoding::term_encoding(); |
|
15
|
0
|
|
|
|
|
|
binmode *STDOUT, ":encoding($term_encoding)"; |
|
16
|
0
|
|
|
|
|
|
binmode *STDERR, ":encoding($term_encoding)"; |
|
17
|
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
print "\n"; |
|
19
|
|
|
|
|
|
|
|
|
20
|
0
|
0
|
|
|
|
|
return bless { |
|
21
|
|
|
|
|
|
|
failed => 0, |
|
22
|
|
|
|
|
|
|
describe => [], |
|
23
|
|
|
|
|
|
|
results => [], |
|
24
|
|
|
|
|
|
|
color => (exists $args->{color} ? $args->{color} : 1), |
|
25
|
|
|
|
|
|
|
}, $class; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub color { |
|
29
|
0
|
|
|
0
|
0
|
|
my ($self, $color, @args) = @_; |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
|
return @args unless $self->{color}; |
|
32
|
0
|
|
|
|
|
|
return Term::ANSIColor::colored($color, @args); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub describe { |
|
36
|
0
|
|
|
0
|
0
|
|
my ($self, $name) = @_; |
|
37
|
0
|
|
|
|
|
|
push @{$self->{describe}}, $name; |
|
|
0
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
print((' ' x @{$self->{describe}}) . "$name\n"); |
|
|
0
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
return Scope::Guard->new(sub { |
|
40
|
0
|
|
|
0
|
|
|
pop @{$self->{describe}}; |
|
|
0
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
}); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub it { |
|
45
|
0
|
|
|
0
|
0
|
|
my ($self, $name, $test, $results, $exception) = @_; |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
print (' ' x (@{$self->{describe}}+1)); |
|
|
0
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
if ($test > 0) { |
|
|
|
0
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
print( $self->color( ['green'], "\x{2713} " ) ); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
elsif ($test < 0) { |
|
52
|
0
|
|
|
|
|
|
print( $self->color( ['yellow'], "\x{2713} " ) ); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
else { |
|
55
|
|
|
|
|
|
|
# not ok |
|
56
|
0
|
|
|
|
|
|
print( $self->color( ['red'], "\x{2716} " ) ); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
0
|
|
|
|
|
|
print( $self->color( ["BRIGHT_BLACK"], $name ) ); |
|
59
|
0
|
0
|
|
|
|
|
if (!$test) { |
|
60
|
0
|
|
|
|
|
|
my $failed = ++$self->{failed}; |
|
61
|
0
|
|
|
|
|
|
printf(" (FAILED - %d)", $failed); |
|
62
|
0
|
|
|
|
|
|
push @{$self->{results}}, [$results, $exception]; |
|
|
0
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} |
|
64
|
0
|
|
|
|
|
|
print("\n"); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub finalize { |
|
68
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
69
|
0
|
0
|
|
|
|
|
if ($self->{finalized}++) { |
|
70
|
0
|
|
|
|
|
|
die "Do not finalize twice."; |
|
71
|
|
|
|
|
|
|
} else { |
|
72
|
0
|
|
|
|
|
|
print "\n"; |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
for my $i (0..$self->{failed}-1) { |
|
75
|
0
|
|
|
|
|
|
printf " %s)\n", $i+1; |
|
76
|
0
|
|
|
|
|
|
my $indent = ' ' x 4; |
|
77
|
0
|
0
|
|
|
|
|
if (defined(my $msg = $self->{results}->[$i]->[0])) { |
|
78
|
0
|
|
|
|
|
|
$msg =~ s{\n(?!\z)}{\n$indent}sg; |
|
79
|
0
|
|
|
|
|
|
print $indent . $msg; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
0
|
0
|
|
|
|
|
if (defined(my $err = $self->{results}->[$i]->[1])) { |
|
82
|
0
|
|
|
|
|
|
$err =~ s{\n(?!\z)}{\n$indent}sg; |
|
83
|
0
|
|
|
|
|
|
print $indent . $self->color(['red', 'bold'], 'Exception: ') . $self->color(['red'], $err); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
} |
|
86
|
0
|
|
|
|
|
|
print "\n"; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
|
91
|
|
|
|
|
|
|
__END__ |