| 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.005-1-g84db602 |
|
13
|
|
|
|
|
|
|
$TAP::SimpleOutput::VERSION = '0.006'; # TRIAL |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# ABSTRACT: Simple closure-driven TAP generator |
|
16
|
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
13773
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
38
|
|
|
18
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
59
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
16
|
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 => [], |
|
27
|
|
|
|
|
|
|
subtest => [ qw{ subtest_header subtest_header_needed } ], |
|
28
|
|
|
|
|
|
|
}, |
|
29
|
1
|
|
|
1
|
|
565
|
}; |
|
|
1
|
|
|
|
|
1257
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
1
|
|
|
1
|
|
144
|
use Carp 'croak'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
94
|
|
|
32
|
1
|
|
|
1
|
|
573
|
use Class::Load 'try_load_class'; |
|
|
1
|
|
|
|
|
15855
|
|
|
|
1
|
|
|
|
|
456
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub counters { |
|
36
|
4
|
|
|
4
|
1
|
528
|
my @counters = _build_counters(@_); |
|
37
|
4
|
|
|
|
|
5
|
pop @counters; |
|
38
|
4
|
|
|
|
|
21
|
return @counters; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub counters_as_hashref { |
|
43
|
1
|
|
|
1
|
1
|
3
|
my @counters = _build_counters(@_); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
return { |
|
46
|
1
|
|
|
|
|
10
|
ok => shift @counters, |
|
47
|
|
|
|
|
|
|
nok => shift @counters, |
|
48
|
|
|
|
|
|
|
skip => shift @counters, |
|
49
|
|
|
|
|
|
|
plan => shift @counters, |
|
50
|
|
|
|
|
|
|
todo => shift @counters, |
|
51
|
|
|
|
|
|
|
freeform => shift @counters, |
|
52
|
|
|
|
|
|
|
}; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
0
|
1
|
0
|
sub counters_and_levelset { goto \&_build_counters } |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _build_counters { |
|
59
|
5
|
|
100
|
5
|
|
18
|
my $level = shift @_ || 0; |
|
60
|
5
|
|
|
|
|
5
|
$level *= 4; |
|
61
|
5
|
|
|
|
|
6
|
my $i = 0; |
|
62
|
|
|
|
|
|
|
|
|
63
|
5
|
100
|
|
|
|
12
|
my $indent = !$level ? q{} : (' ' x $level); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
return ( |
|
66
|
16
|
|
|
16
|
|
71
|
sub { $indent . 'ok ' . ++$i . " - $_[0]" }, # ok |
|
67
|
4
|
|
|
4
|
|
14
|
sub { $indent . 'not ok ' . ++$i . " - $_[0]" }, # nok |
|
68
|
4
|
|
|
4
|
|
13
|
sub { $indent . 'ok ' . ++$i . " # skip $_[0]" }, # skip |
|
69
|
4
|
|
|
4
|
|
14
|
sub { $indent . "1..$i" }, # plan |
|
70
|
4
|
|
|
4
|
|
6
|
sub { "$_[0] # TODO $_[1]" }, # todo |
|
71
|
3
|
|
|
3
|
|
10
|
sub { $indent . "$_[0]" }, # freeform |
|
72
|
|
|
|
|
|
|
sub { |
|
73
|
|
|
|
|
|
|
# if we're called with a new level, set $level and $indent |
|
74
|
|
|
|
|
|
|
# appropriately |
|
75
|
0
|
0
|
|
0
|
|
|
do { $level = $_[0] * 4; $indent = !$level ? q{} : (' ' x $level) } |
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
if defined $_[0]; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# return our new/set level regardless, in the form we passed it in |
|
79
|
0
|
|
|
|
|
|
return $level / 4; |
|
80
|
|
|
|
|
|
|
}, |
|
81
|
5
|
|
|
|
|
64
|
); |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my $_subtest_header_needed; |
|
86
|
|
|
|
|
|
|
sub subtest_header_needed { |
|
87
|
|
|
|
|
|
|
|
|
88
|
0
|
0
|
|
0
|
1
|
|
return $_subtest_header_needed |
|
89
|
|
|
|
|
|
|
if defined $_subtest_header_needed; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
do { |
|
92
|
0
|
|
|
|
|
|
my ($success, $error) = try_load_class $_; |
|
93
|
0
|
0
|
|
|
|
|
croak __PACKAGE__ . " needs $_, but can't find it: $error" |
|
94
|
|
|
|
|
|
|
unless $success; |
|
95
|
0
|
|
|
|
|
|
} for qw{ Perl::Version Test::More }; |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
return $_subtest_header_needed |
|
98
|
|
|
|
|
|
|
= Perl::Version->new(Test::More->VERSION) >= Perl::Version->new('0.98_05'); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
0
|
0
|
|
0
|
|
|
sub _subtest_header_indent { $INC{'Test/Stream.pm'} ? q{} : (' ' x 4) } |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub subtest_header { |
|
105
|
0
|
|
|
0
|
1
|
|
my ($out, $name) = @_; |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
$out = $out->{freeform} |
|
108
|
0
|
0
|
0
|
|
|
|
if ref $out && ref $out eq 'HASH'; |
|
109
|
|
|
|
|
|
|
|
|
110
|
0
|
0
|
|
|
|
|
return subtest_header_needed() |
|
111
|
|
|
|
|
|
|
? $out->(_subtest_header_indent . "# Subtest: $name") |
|
112
|
|
|
|
|
|
|
: q{} |
|
113
|
|
|
|
|
|
|
; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
!!42; |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
__END__ |