line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#line 1 |
2
|
6
|
|
|
6
|
|
42
|
package Test2::API::Stack; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
175
|
|
3
|
6
|
|
|
6
|
|
28
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
218
|
|
4
|
|
|
|
|
|
|
use warnings; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.302073'; |
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
6
|
|
2705
|
|
|
6
|
|
|
|
|
54
|
|
|
6
|
|
|
|
|
161
|
|
9
|
|
|
|
|
|
|
use Test2::Hub(); |
10
|
6
|
|
|
6
|
|
44
|
|
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
2329
|
|
11
|
|
|
|
|
|
|
use Carp qw/confess/; |
12
|
|
|
|
|
|
|
|
13
|
6
|
|
|
6
|
1
|
15
|
sub new { |
14
|
6
|
|
|
|
|
24
|
my $class = shift; |
15
|
|
|
|
|
|
|
return bless [], $class; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
15
|
|
|
15
|
1
|
39
|
sub new_hub { |
19
|
15
|
|
|
|
|
49
|
my $self = shift; |
20
|
|
|
|
|
|
|
my %params = @_; |
21
|
15
|
|
100
|
|
|
88
|
|
22
|
|
|
|
|
|
|
my $class = delete $params{class} || 'Test2::Hub'; |
23
|
15
|
|
|
|
|
123
|
|
24
|
|
|
|
|
|
|
my $hub = $class->new(%params); |
25
|
15
|
100
|
|
|
|
55
|
|
26
|
9
|
|
|
|
|
94
|
if (@$self) { |
27
|
|
|
|
|
|
|
$hub->inherit($self->[-1], %params); |
28
|
|
|
|
|
|
|
} |
29
|
6
|
|
|
|
|
50
|
else { |
30
|
|
|
|
|
|
|
require Test2::API; |
31
|
6
|
50
|
33
|
|
|
33
|
$hub->format(Test2::API::test2_formatter()->new) |
32
|
|
|
|
|
|
|
unless $hub->format || exists($params{formatter}); |
33
|
6
|
|
|
|
|
27
|
|
34
|
6
|
0
|
33
|
|
|
31
|
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
|
15
|
|
|
|
|
50
|
|
41
|
|
|
|
|
|
|
push @$self => $hub; |
42
|
15
|
|
|
|
|
61
|
|
43
|
|
|
|
|
|
|
$hub; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
21
|
|
|
21
|
1
|
44
|
sub top { |
47
|
21
|
100
|
|
|
|
80
|
my $self = shift; |
48
|
15
|
|
|
|
|
42
|
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
|
6
|
|
|
6
|
1
|
15
|
sub all { |
63
|
6
|
|
|
|
|
27
|
my $self = shift; |
64
|
|
|
|
|
|
|
return @$self; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
0
|
1
|
0
|
sub clear { |
68
|
0
|
|
|
|
|
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
|
6
|
|
|
6
|
|
78
|
{ |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
1200
|
|
76
|
|
|
|
|
|
|
no warnings 'once'; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
0
|
|
0
|
*push = sub { |
79
|
0
|
|
|
|
|
0
|
my $self = shift; |
80
|
0
|
0
|
|
|
|
0
|
my ($hub) = @_; |
81
|
0
|
|
|
|
|
0
|
$hub->inherit($self->[-1]) if @$self; |
82
|
|
|
|
|
|
|
push @$self => $hub; |
83
|
|
|
|
|
|
|
}; |
84
|
|
|
|
|
|
|
|
85
|
9
|
|
|
9
|
|
21
|
*pop = sub { |
86
|
9
|
|
|
|
|
31
|
my $self = shift; |
87
|
9
|
50
|
|
|
|
30
|
my ($hub) = @_; |
88
|
|
|
|
|
|
|
confess "No hubs on the stack" |
89
|
9
|
50
|
|
|
|
30
|
unless @$self; |
90
|
|
|
|
|
|
|
confess "You cannot pop the root hub" |
91
|
9
|
50
|
|
|
|
32
|
if 1 == @$self; |
92
|
|
|
|
|
|
|
confess "Hub stack mismatch, attempted to pop incorrect hub" |
93
|
9
|
|
|
|
|
27
|
unless $self->[-1] == $hub; |
94
|
|
|
|
|
|
|
pop @$self; |
95
|
|
|
|
|
|
|
}; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__END__ |