line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Ika::Example; |
2
|
13
|
|
|
13
|
|
60
|
use strict; |
|
13
|
|
|
|
|
20
|
|
|
13
|
|
|
|
|
403
|
|
3
|
13
|
|
|
13
|
|
88
|
use warnings; |
|
13
|
|
|
|
|
35
|
|
|
13
|
|
|
|
|
326
|
|
4
|
13
|
|
|
13
|
|
57
|
use utf8; |
|
13
|
|
|
|
|
22
|
|
|
13
|
|
|
|
|
68
|
|
5
|
|
|
|
|
|
|
|
6
|
13
|
|
|
13
|
|
240
|
use Carp (); |
|
13
|
|
|
|
|
19
|
|
|
13
|
|
|
|
|
182
|
|
7
|
13
|
|
|
13
|
|
12083
|
use Try::Tiny; |
|
13
|
|
|
|
|
20957
|
|
|
13
|
|
|
|
|
697
|
|
8
|
13
|
|
|
13
|
|
81
|
use Test::Builder; |
|
13
|
|
|
|
|
27
|
|
|
13
|
|
|
|
|
4905
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
{ # accessor |
11
|
8
|
|
|
8
|
0
|
8924
|
sub name { $_[0]->{name} } |
12
|
4
|
|
|
4
|
0
|
22
|
sub skip { $_[0]->{skip} > 0 } |
13
|
4
|
|
|
4
|
0
|
22
|
sub result { $_[0]->{result} } |
14
|
4
|
|
|
4
|
0
|
22
|
sub output { $_[0]->{output} } |
15
|
4
|
|
|
4
|
0
|
19
|
sub error { $_[0]->{error} } |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
19
|
44
|
|
|
44
|
0
|
73
|
my $class = shift; |
20
|
44
|
50
|
|
|
|
224
|
my %args = @_==1 ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
0
|
|
21
|
|
|
|
|
|
|
|
22
|
44
|
|
33
|
|
|
138
|
my $name = delete $args{name} || Carp::croak "Missing name"; |
23
|
44
|
|
|
|
|
104
|
my $code = delete $args{code}; # allow specification only |
24
|
|
|
|
|
|
|
|
25
|
44
|
50
|
|
0
|
|
144
|
my $cond = exists $args{cond} ? delete $args{cond} : sub { 1 }; |
|
0
|
|
|
|
|
0
|
|
26
|
44
|
100
|
|
|
|
157
|
my $skip = exists $args{skip} ? delete $args{skip} : (!$code ? 1 : 0); # xit |
|
|
100
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
44
|
|
|
|
|
268
|
bless { |
29
|
|
|
|
|
|
|
name => $name, |
30
|
|
|
|
|
|
|
code => $code, |
31
|
|
|
|
|
|
|
cond => $cond, |
32
|
|
|
|
|
|
|
skip => $skip, |
33
|
|
|
|
|
|
|
}, $class; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub run { |
37
|
41
|
|
|
41
|
0
|
55
|
my $self = shift; |
38
|
|
|
|
|
|
|
|
39
|
41
|
|
|
|
|
50
|
my $error; |
40
|
|
|
|
|
|
|
my $ok; |
41
|
41
|
|
|
|
|
64
|
my $output = ""; |
42
|
|
|
|
|
|
|
|
43
|
41
|
100
|
66
|
|
|
231
|
if (defined $self->{cond} && defined $self->{code}) { |
44
|
4
|
100
|
|
|
|
18
|
my $cond = ref $self->{cond} eq 'CODE' ? $self->{cond}->() : $self->{cond}; |
45
|
4
|
|
|
|
|
13
|
$cond = !!$cond; |
46
|
4
|
100
|
|
|
|
12
|
$self->{skip}++ unless $cond; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
try { |
50
|
41
|
|
|
41
|
|
2469
|
open my $fh, '>', \$output; |
|
12
|
|
|
12
|
|
126
|
|
|
12
|
|
|
|
|
60
|
|
|
12
|
|
|
|
|
130
|
|
51
|
41
|
|
|
|
|
18010
|
$ok = do { |
52
|
13
|
|
|
13
|
|
80
|
no warnings 'redefine'; |
|
13
|
|
|
|
|
31
|
|
|
13
|
|
|
|
|
3984
|
|
53
|
41
|
|
|
|
|
236
|
my $builder = Test::Builder->create(); |
54
|
41
|
|
|
|
|
9539
|
local $Test::Builder::Test = $builder; |
55
|
41
|
|
|
|
|
148
|
$builder->no_header(1); |
56
|
41
|
|
|
|
|
318
|
$builder->no_ending(1); |
57
|
41
|
|
|
|
|
255
|
$builder->output($fh); |
58
|
41
|
|
|
|
|
590
|
$builder->failure_output($fh); |
59
|
41
|
|
|
|
|
539
|
$builder->todo_output($fh); |
60
|
|
|
|
|
|
|
|
61
|
41
|
100
|
|
|
|
575
|
if ($self->{skip}) { |
62
|
14
|
|
|
|
|
51
|
$builder->skip; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
else { |
65
|
27
|
|
|
|
|
93
|
$self->{code}->(); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
40
|
|
|
|
|
3993
|
$builder->finalize(); |
69
|
40
|
|
|
|
|
285
|
$builder->is_passing(); |
70
|
|
|
|
|
|
|
}; |
71
|
|
|
|
|
|
|
} catch { |
72
|
1
|
|
|
1
|
|
32
|
$error = "$_"; |
73
|
|
|
|
|
|
|
} finally { |
74
|
41
|
|
|
41
|
|
1537
|
my $name = $self->{name}; |
75
|
41
|
100
|
|
|
|
118
|
if ($self->{skip}) { |
76
|
14
|
100
|
|
|
|
50
|
$name .= $self->{code} ? ' [DISABLED]' : ' [NOT IMPLEMENTED]'; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
41
|
100
|
|
|
|
119
|
my $test = $self->{skip} ? -1 : !!$ok; |
80
|
|
|
|
|
|
|
|
81
|
41
|
|
|
|
|
90
|
$self->{result} = $test; |
82
|
41
|
|
|
|
|
79
|
$self->{output} = $output; |
83
|
41
|
|
|
|
|
71
|
$self->{error} = $error; |
84
|
|
|
|
|
|
|
|
85
|
41
|
|
|
|
|
164
|
$Test::Ika::REPORTER->it($name, $test, $output, $error); |
86
|
41
|
|
|
|
|
439
|
}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |