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