line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Stack; |
2
|
109
|
|
|
109
|
|
1072
|
use strict; |
|
109
|
|
|
|
|
187
|
|
|
109
|
|
|
|
|
2686
|
|
3
|
109
|
|
|
109
|
|
517
|
use warnings; |
|
109
|
|
|
|
|
170
|
|
|
109
|
|
|
|
|
2740
|
|
4
|
|
|
|
|
|
|
|
5
|
109
|
|
|
109
|
|
65675
|
use Test::Stream::Hub; |
|
109
|
|
|
|
|
273
|
|
|
109
|
|
|
|
|
3118
|
|
6
|
|
|
|
|
|
|
|
7
|
109
|
|
|
109
|
|
677
|
use Carp qw/confess/; |
|
109
|
|
|
|
|
187
|
|
|
109
|
|
|
|
|
43128
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
176
|
|
|
176
|
1
|
362
|
my $class = shift; |
11
|
176
|
|
|
|
|
655
|
return bless [], $class; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new_hub { |
15
|
365
|
|
|
365
|
1
|
653
|
my $self = shift; |
16
|
365
|
|
|
|
|
1150
|
my %params = @_; |
17
|
|
|
|
|
|
|
|
18
|
365
|
|
100
|
|
|
1837
|
my $class = delete $params{class} || 'Test::Stream::Hub'; |
19
|
|
|
|
|
|
|
|
20
|
365
|
|
|
|
|
2837
|
my $hub = $class->new(%params); |
21
|
|
|
|
|
|
|
|
22
|
365
|
100
|
|
|
|
1180
|
if (@$self) { |
23
|
239
|
|
|
|
|
1025
|
$hub->inherit($self->[-1], %params); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
else { |
26
|
|
|
|
|
|
|
$hub->format(Test::Stream::Sync->formatter->new) |
27
|
126
|
50
|
33
|
|
|
728
|
unless $hub->format || exists($params{formatter}); |
28
|
|
|
|
|
|
|
|
29
|
126
|
|
|
|
|
902
|
my $ipc = Test::Stream::Sync->ipc; |
30
|
126
|
50
|
66
|
|
|
1112
|
if ($ipc && !$hub->ipc && !exists($params{ipc})) { |
|
|
|
66
|
|
|
|
|
31
|
112
|
|
|
|
|
1673
|
$hub->set_ipc($ipc); |
32
|
112
|
|
|
|
|
1022
|
$ipc->add_hub($hub->hid); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
365
|
|
|
|
|
1291
|
push @$self => $hub; |
37
|
|
|
|
|
|
|
|
38
|
365
|
|
|
|
|
1414
|
$hub; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub top { |
42
|
2487
|
|
|
2487
|
1
|
4243
|
my $self = shift; |
43
|
2487
|
100
|
|
|
|
6683
|
return $self->new_hub unless @$self; |
44
|
2361
|
|
|
|
|
6979
|
return $self->[-1]; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub peek { |
48
|
2
|
|
|
2
|
1
|
5
|
my $self = shift; |
49
|
2
|
100
|
|
|
|
13
|
return @$self ? $self->[-1] : undef; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub cull { |
53
|
1
|
|
|
1
|
1
|
6
|
my $self = shift; |
54
|
1
|
|
|
|
|
4
|
$_->cull for reverse @$self; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub all { |
58
|
234
|
|
|
234
|
1
|
499
|
my $self = shift; |
59
|
234
|
|
|
|
|
931
|
return @$self; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub clear { |
63
|
2
|
|
|
2
|
1
|
8
|
my $self = shift; |
64
|
2
|
|
|
|
|
7
|
@$self = (); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Do these last without keywords in order to prevent them from getting used |
68
|
|
|
|
|
|
|
# when we want the real push/pop. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
{ |
71
|
109
|
|
|
109
|
|
622
|
no warnings 'once'; |
|
109
|
|
|
|
|
197
|
|
|
109
|
|
|
|
|
21143
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
*push = sub { |
74
|
140
|
|
|
140
|
|
751
|
my $self = shift; |
75
|
140
|
|
|
|
|
238
|
my ($hub) = @_; |
76
|
140
|
100
|
|
|
|
845
|
$hub->inherit($self->[-1]) if @$self; |
77
|
140
|
|
|
|
|
384
|
push @$self => $hub; |
78
|
|
|
|
|
|
|
}; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
*pop = sub { |
81
|
365
|
|
|
365
|
|
1173
|
my $self = shift; |
82
|
365
|
|
|
|
|
748
|
my ($hub) = @_; |
83
|
365
|
100
|
|
|
|
1202
|
confess "No hubs on the stack" |
84
|
|
|
|
|
|
|
unless @$self; |
85
|
364
|
100
|
|
|
|
1151
|
confess "You cannot pop the root hub" |
86
|
|
|
|
|
|
|
if 1 == @$self; |
87
|
363
|
100
|
|
|
|
1357
|
confess "Hub stack mismatch, attempted to pop incorrect hub" |
88
|
|
|
|
|
|
|
unless $self->[-1] == $hub; |
89
|
362
|
|
|
|
|
1069
|
pop @$self; |
90
|
|
|
|
|
|
|
}; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |