line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Ika::ExampleGroup; |
2
|
13
|
|
|
13
|
|
69
|
use strict; |
|
13
|
|
|
|
|
27
|
|
|
13
|
|
|
|
|
425
|
|
3
|
13
|
|
|
13
|
|
61
|
use warnings; |
|
13
|
|
|
|
|
24
|
|
|
13
|
|
|
|
|
311
|
|
4
|
13
|
|
|
13
|
|
938
|
use utf8; |
|
13
|
|
|
|
|
32
|
|
|
13
|
|
|
|
|
89
|
|
5
|
13
|
|
|
13
|
|
307
|
use Carp (); |
|
13
|
|
|
|
|
26
|
|
|
13
|
|
|
|
|
26197
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
38
|
|
|
38
|
0
|
77
|
my $class = shift; |
9
|
38
|
50
|
|
|
|
232
|
my %args = @_==1 ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
0
|
|
10
|
38
|
|
33
|
|
|
178
|
my $name = delete $args{name} || Carp::croak "Missing name"; |
11
|
|
|
|
|
|
|
bless { |
12
|
|
|
|
|
|
|
triggers => { |
13
|
|
|
|
|
|
|
before_all => [], |
14
|
|
|
|
|
|
|
before_each => [], |
15
|
|
|
|
|
|
|
after_all => [], |
16
|
|
|
|
|
|
|
after_each => [], |
17
|
|
|
|
|
|
|
}, |
18
|
|
|
|
|
|
|
example_groups => [], |
19
|
|
|
|
|
|
|
examples => [], |
20
|
|
|
|
|
|
|
name => $name, |
21
|
|
|
|
|
|
|
parent => $args{parent}, |
22
|
|
|
|
|
|
|
root => $args{root}, |
23
|
13
|
|
|
13
|
|
45
|
cond => exists $args{cond} ? $args{cond} : sub { 1 }, |
24
|
38
|
100
|
|
|
|
576
|
}, $class; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub add_example_group { |
28
|
25
|
|
|
25
|
0
|
51
|
my ($self, $context) = @_; |
29
|
25
|
|
|
|
|
38
|
push @{$self->{example_groups}}, $context; |
|
25
|
|
|
|
|
106
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub add_example { |
33
|
44
|
|
|
44
|
0
|
69
|
my ($self, $it) = @_; |
34
|
44
|
|
|
|
|
60
|
push @{$self->{examples}}, $it; |
|
44
|
|
|
|
|
235
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub add_trigger { |
38
|
46
|
|
|
46
|
0
|
85
|
my ($self, $trigger_name, $code) = @_; |
39
|
46
|
|
|
|
|
56
|
push @{$self->{triggers}->{$trigger_name}}, $code; |
|
46
|
|
|
|
|
201
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub call_trigger { |
43
|
70
|
|
|
70
|
0
|
109
|
my ($self, $trigger_name) = @_; |
44
|
70
|
|
|
|
|
84
|
for my $trigger (@{$self->{triggers}->{$trigger_name}}) { |
|
70
|
|
|
|
|
268
|
|
45
|
28
|
|
|
|
|
78
|
$trigger->(); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub call_before_each_trigger { |
50
|
96
|
|
|
96
|
0
|
285
|
my ($self, @args) = @_; |
51
|
96
|
100
|
|
|
|
358
|
$self->{parent}->call_before_each_trigger(@args) if $self->{parent}; |
52
|
96
|
|
|
|
|
115
|
for my $trigger (@{$self->{triggers}->{'before_each'}}) { |
|
96
|
|
|
|
|
225
|
|
53
|
20
|
|
|
|
|
66
|
$trigger->(@args); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub call_after_each_trigger { |
58
|
96
|
|
|
96
|
0
|
178
|
my ($self, @args) = @_; |
59
|
96
|
|
|
|
|
97
|
for my $trigger (@{$self->{triggers}->{'after_each'}}) { |
|
96
|
|
|
|
|
228
|
|
60
|
20
|
|
|
|
|
64
|
$trigger->(@args); |
61
|
|
|
|
|
|
|
} |
62
|
96
|
100
|
|
|
|
451
|
$self->{parent}->call_after_each_trigger(@args) if $self->{parent}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub run { |
66
|
38
|
|
|
38
|
0
|
63
|
my ($self) = @_; |
67
|
|
|
|
|
|
|
|
68
|
38
|
100
|
|
|
|
146
|
if (defined $self->{cond}) { |
69
|
18
|
100
|
|
|
|
100
|
my $cond = ref $self->{cond} eq 'CODE' ? $self->{cond}->() : $self->{cond}; |
70
|
18
|
|
|
|
|
42
|
$cond = !!$cond; |
71
|
18
|
100
|
|
|
|
93
|
$self->{skip}++ unless $cond; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
38
|
|
|
|
|
75
|
my $name = $self->{name}; |
75
|
38
|
100
|
|
|
|
132
|
$name .= ' [DISABLED]' if $self->{skip}; |
76
|
38
|
100
|
|
|
|
170
|
my $guard = $self->{root} ? undef : $Test::Ika::REPORTER->describe($name); |
77
|
|
|
|
|
|
|
|
78
|
38
|
100
|
|
|
|
404
|
unless ($self->{skip}) { |
79
|
35
|
|
|
|
|
114
|
$self->call_trigger('before_all'); |
80
|
35
|
|
|
|
|
101
|
for my $stuff (@{$self->{examples}}) { |
|
35
|
|
|
|
|
93
|
|
81
|
41
|
|
|
|
|
130
|
$self->call_before_each_trigger($stuff, $self); |
82
|
41
|
|
|
|
|
249
|
$stuff->run(); |
83
|
41
|
|
|
|
|
785
|
$self->call_after_each_trigger($stuff, $self); |
84
|
|
|
|
|
|
|
} |
85
|
35
|
|
|
|
|
57
|
for my $stuff (@{$self->{example_groups}}) { |
|
35
|
|
|
|
|
81
|
|
86
|
25
|
|
|
|
|
128
|
$stuff->run(); |
87
|
|
|
|
|
|
|
} |
88
|
35
|
|
|
|
|
98
|
$self->call_trigger('after_all'); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
|