line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of TAP-SimpleOutput |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2012 by Chris Weyl. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The GNU Lesser General Public License, Version 2.1, February 1999 |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
package TAP::SimpleOutput; |
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:RSRCHBOY'; |
12
|
|
|
|
|
|
|
# git description: 0.007-1-g6755323 |
13
|
|
|
|
|
|
|
$TAP::SimpleOutput::VERSION = '0.008'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# ABSTRACT: Simple closure-driven TAP generator |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
18478
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
18
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
45
|
|
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
10
|
use Sub::Exporter::Progressive -setup => { |
21
|
|
|
|
|
|
|
exports => [ qw{ |
22
|
|
|
|
|
|
|
counters counters_and_levelset counters_as_hashref |
23
|
|
|
|
|
|
|
subtest_header subtest_header_needed |
24
|
|
|
|
|
|
|
} ], |
25
|
|
|
|
|
|
|
groups => { |
26
|
|
|
|
|
|
|
default => [ 'counters' ], |
27
|
|
|
|
|
|
|
subtest => [ qw{ counters subtest_header subtest_header_needed } ], |
28
|
|
|
|
|
|
|
}, |
29
|
1
|
|
|
1
|
|
498
|
}; |
|
1
|
|
|
|
|
870
|
|
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
1
|
|
131
|
use Carp 'croak'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
64
|
|
32
|
1
|
|
|
1
|
|
481
|
use Class::Load 'try_load_class'; |
|
1
|
|
|
|
|
17669
|
|
|
1
|
|
|
|
|
563
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub counters { |
36
|
6
|
|
|
6
|
1
|
19
|
my $level = shift @_; |
37
|
|
|
|
|
|
|
|
38
|
6
|
100
|
|
|
|
17
|
return { _build_counters($level) } |
39
|
|
|
|
|
|
|
unless wantarray; |
40
|
|
|
|
|
|
|
|
41
|
4
|
|
|
|
|
5
|
my $i = 0; |
42
|
|
|
|
|
|
|
my @counters = |
43
|
4
|
|
|
|
|
9
|
grep { $i++ % 2 } |
|
56
|
|
|
|
|
53
|
|
44
|
|
|
|
|
|
|
_build_counters($level) |
45
|
|
|
|
|
|
|
; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# ditch levelset |
48
|
4
|
|
|
|
|
9
|
pop @counters; |
49
|
|
|
|
|
|
|
|
50
|
4
|
|
|
|
|
21
|
return @counters; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
1
|
1
|
4
|
sub counters_as_hashref { scalar counters } |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
0
|
1
|
0
|
sub counters_and_levelset { goto \&_build_counters } |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _build_counters { |
60
|
6
|
|
100
|
6
|
|
25
|
my $level = shift @_ || 0; |
61
|
6
|
|
|
|
|
7
|
$level *= 4; |
62
|
6
|
|
|
|
|
7
|
my $i = 0; |
63
|
|
|
|
|
|
|
|
64
|
6
|
100
|
|
|
|
16
|
my $indent = !$level ? q{} : (' ' x $level); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
return ( |
67
|
19
|
|
|
19
|
|
101
|
ok => sub { $indent . 'ok ' . ++$i . " - $_[0]" }, |
68
|
5
|
|
|
5
|
|
18
|
nok => sub { $indent . 'not ok ' . ++$i . " - $_[0]" }, |
69
|
5
|
|
|
5
|
|
22
|
skip => sub { $indent . 'ok ' . ++$i . " # skip $_[0]" }, |
70
|
5
|
|
|
5
|
|
20
|
plan => sub { $indent . "1..$i" }, |
71
|
5
|
|
|
5
|
|
11
|
todo => sub { "$_[0] # TODO $_[1]" }, |
72
|
4
|
|
|
4
|
|
13
|
freeform => sub { $indent . "$_[0]" }, |
73
|
|
|
|
|
|
|
levelset => sub { |
74
|
|
|
|
|
|
|
# if we're called with a new level, set $level and $indent |
75
|
|
|
|
|
|
|
# appropriately |
76
|
0
|
0
|
|
0
|
|
|
do { $level = $_[0] * 4; $indent = !$level ? q{} : (' ' x $level) } |
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
if defined $_[0]; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# return our new/set level regardless, in the form we passed it in |
80
|
0
|
|
|
|
|
|
return $level / 4; |
81
|
|
|
|
|
|
|
}, |
82
|
6
|
|
|
|
|
76
|
); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $_subtest_header_needed; |
87
|
|
|
|
|
|
|
sub subtest_header_needed { |
88
|
|
|
|
|
|
|
|
89
|
0
|
0
|
|
0
|
1
|
|
return $_subtest_header_needed |
90
|
|
|
|
|
|
|
if defined $_subtest_header_needed; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
do { |
93
|
0
|
|
|
|
|
|
my ($success, $error) = try_load_class $_; |
94
|
0
|
0
|
|
|
|
|
croak __PACKAGE__ . " needs $_, but can't find it: $error" |
95
|
|
|
|
|
|
|
unless $success; |
96
|
0
|
|
|
|
|
|
} for qw{ Perl::Version Test::More }; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
return $_subtest_header_needed |
99
|
|
|
|
|
|
|
= Perl::Version->new(Test::More->VERSION) >= Perl::Version->new('0.98_05'); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
0
|
0
|
|
0
|
|
|
sub _subtest_header_indent { $INC{'Test/Stream.pm'} ? q{} : (' ' x 4) } |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub subtest_header { |
106
|
0
|
|
|
0
|
1
|
|
my ($out, $name) = @_; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
$out = $out->{freeform} |
109
|
0
|
0
|
0
|
|
|
|
if ref $out && ref $out eq 'HASH'; |
110
|
|
|
|
|
|
|
|
111
|
0
|
0
|
|
|
|
|
return subtest_header_needed() |
112
|
|
|
|
|
|
|
? $out->(_subtest_header_indent . "# Subtest: $name") |
113
|
|
|
|
|
|
|
: q{} |
114
|
|
|
|
|
|
|
; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
!!42; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
__END__ |