line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::API::Stack; |
2
|
57
|
|
|
57
|
|
186
|
use strict; |
|
57
|
|
|
|
|
62
|
|
|
57
|
|
|
|
|
1284
|
|
3
|
57
|
|
|
57
|
|
159
|
use warnings; |
|
57
|
|
|
|
|
46
|
|
|
57
|
|
|
|
|
1840
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000044'; |
6
|
|
|
|
|
|
|
|
7
|
57
|
|
|
57
|
|
19428
|
use Test2::Hub(); |
|
57
|
|
|
|
|
78
|
|
|
57
|
|
|
|
|
1142
|
|
8
|
|
|
|
|
|
|
|
9
|
57
|
|
|
57
|
|
274
|
use Carp qw/confess/; |
|
57
|
|
|
|
|
60
|
|
|
57
|
|
|
|
|
15941
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
155
|
|
|
155
|
1
|
192
|
my $class = shift; |
13
|
155
|
|
|
|
|
891
|
return bless [], $class; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new_hub { |
17
|
135
|
|
|
135
|
1
|
169
|
my $self = shift; |
18
|
135
|
|
|
|
|
266
|
my %params = @_; |
19
|
|
|
|
|
|
|
|
20
|
135
|
|
100
|
|
|
529
|
my $class = delete $params{class} || 'Test2::Hub'; |
21
|
|
|
|
|
|
|
|
22
|
135
|
|
|
|
|
758
|
my $hub = $class->new(%params); |
23
|
|
|
|
|
|
|
|
24
|
135
|
100
|
|
|
|
296
|
if (@$self) { |
25
|
59
|
|
|
|
|
172
|
$hub->inherit($self->[-1], %params); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
else { |
28
|
76
|
|
|
|
|
445
|
require Test2::API; |
29
|
|
|
|
|
|
|
$hub->format(Test2::API::test2_formatter()->new) |
30
|
76
|
50
|
33
|
|
|
283
|
unless $hub->format || exists($params{formatter}); |
31
|
|
|
|
|
|
|
|
32
|
76
|
|
|
|
|
266
|
my $ipc = Test2::API::test2_ipc(); |
33
|
76
|
50
|
66
|
|
|
367
|
if ($ipc && !$hub->ipc && !exists($params{ipc})) { |
|
|
|
66
|
|
|
|
|
34
|
41
|
|
|
|
|
130
|
$hub->set_ipc($ipc); |
35
|
41
|
|
|
|
|
123
|
$ipc->add_hub($hub->hid); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
135
|
|
|
|
|
252
|
push @$self => $hub; |
40
|
|
|
|
|
|
|
|
41
|
135
|
|
|
|
|
427
|
$hub; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub top { |
45
|
136
|
|
|
136
|
1
|
193
|
my $self = shift; |
46
|
136
|
100
|
|
|
|
450
|
return $self->new_hub unless @$self; |
47
|
60
|
|
|
|
|
142
|
return $self->[-1]; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub peek { |
51
|
2
|
|
|
2
|
1
|
5
|
my $self = shift; |
52
|
2
|
100
|
|
|
|
13
|
return @$self ? $self->[-1] : undef; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub cull { |
56
|
1
|
|
|
1
|
1
|
16
|
my $self = shift; |
57
|
1
|
|
|
|
|
4
|
$_->cull for reverse @$self; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub all { |
61
|
79
|
|
|
79
|
1
|
150
|
my $self = shift; |
62
|
79
|
|
|
|
|
230
|
return @$self; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub clear { |
66
|
2
|
|
|
2
|
1
|
21
|
my $self = shift; |
67
|
2
|
|
|
|
|
6
|
@$self = (); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Do these last without keywords in order to prevent them from getting used |
71
|
|
|
|
|
|
|
# when we want the real push/pop. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
{ |
74
|
57
|
|
|
57
|
|
291
|
no warnings 'once'; |
|
57
|
|
|
|
|
64
|
|
|
57
|
|
|
|
|
7767
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
*push = sub { |
77
|
15
|
|
|
15
|
|
26
|
my $self = shift; |
78
|
15
|
|
|
|
|
17
|
my ($hub) = @_; |
79
|
15
|
100
|
|
|
|
65
|
$hub->inherit($self->[-1]) if @$self; |
80
|
15
|
|
|
|
|
24
|
push @$self => $hub; |
81
|
|
|
|
|
|
|
}; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
*pop = sub { |
84
|
60
|
|
|
60
|
|
108
|
my $self = shift; |
85
|
60
|
|
|
|
|
76
|
my ($hub) = @_; |
86
|
60
|
100
|
|
|
|
329
|
confess "No hubs on the stack" |
87
|
|
|
|
|
|
|
unless @$self; |
88
|
59
|
100
|
|
|
|
262
|
confess "You cannot pop the root hub" |
89
|
|
|
|
|
|
|
if 1 == @$self; |
90
|
58
|
100
|
|
|
|
240
|
confess "Hub stack mismatch, attempted to pop incorrect hub" |
91
|
|
|
|
|
|
|
unless $self->[-1] == $hub; |
92
|
57
|
|
|
|
|
117
|
pop @$self; |
93
|
|
|
|
|
|
|
}; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |