line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Stack; |
2
|
109
|
|
|
109
|
|
1029
|
use strict; |
|
109
|
|
|
|
|
182
|
|
|
109
|
|
|
|
|
2763
|
|
3
|
109
|
|
|
109
|
|
517
|
use warnings; |
|
109
|
|
|
|
|
173
|
|
|
109
|
|
|
|
|
2687
|
|
4
|
|
|
|
|
|
|
|
5
|
109
|
|
|
109
|
|
64188
|
use Test::Stream::Hub; |
|
109
|
|
|
|
|
301
|
|
|
109
|
|
|
|
|
3099
|
|
6
|
|
|
|
|
|
|
|
7
|
109
|
|
|
109
|
|
685
|
use Carp qw/confess/; |
|
109
|
|
|
|
|
183
|
|
|
109
|
|
|
|
|
42299
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
176
|
|
|
176
|
1
|
346
|
my $class = shift; |
11
|
176
|
|
|
|
|
655
|
return bless [], $class; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new_hub { |
15
|
365
|
|
|
365
|
1
|
629
|
my $self = shift; |
16
|
365
|
|
|
|
|
1018
|
my %params = @_; |
17
|
|
|
|
|
|
|
|
18
|
365
|
|
100
|
|
|
1826
|
my $class = delete $params{class} || 'Test::Stream::Hub'; |
19
|
|
|
|
|
|
|
|
20
|
365
|
|
|
|
|
2650
|
my $hub = $class->new(%params); |
21
|
|
|
|
|
|
|
|
22
|
365
|
100
|
|
|
|
1137
|
if (@$self) { |
23
|
239
|
|
|
|
|
1031
|
$hub->inherit($self->[-1], %params); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
else { |
26
|
|
|
|
|
|
|
$hub->format(Test::Stream::Sync->formatter->new) |
27
|
126
|
50
|
33
|
|
|
722
|
unless $hub->format || exists($params{formatter}); |
28
|
|
|
|
|
|
|
|
29
|
126
|
|
|
|
|
926
|
my $ipc = Test::Stream::Sync->ipc; |
30
|
126
|
50
|
66
|
|
|
1080
|
if ($ipc && !$hub->ipc && !exists($params{ipc})) { |
|
|
|
66
|
|
|
|
|
31
|
112
|
|
|
|
|
1703
|
$hub->set_ipc($ipc); |
32
|
112
|
|
|
|
|
915
|
$ipc->add_hub($hub->hid); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
365
|
|
|
|
|
1673
|
push @$self => $hub; |
37
|
|
|
|
|
|
|
|
38
|
365
|
|
|
|
|
1521
|
$hub; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub top { |
42
|
2487
|
|
|
2487
|
1
|
4221
|
my $self = shift; |
43
|
2487
|
100
|
|
|
|
6157
|
return $self->new_hub unless @$self; |
44
|
2361
|
|
|
|
|
6489
|
return $self->[-1]; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub peek { |
48
|
2
|
|
|
2
|
1
|
4
|
my $self = shift; |
49
|
2
|
100
|
|
|
|
11
|
return @$self ? $self->[-1] : undef; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub cull { |
53
|
1
|
|
|
1
|
1
|
7
|
my $self = shift; |
54
|
1
|
|
|
|
|
4
|
$_->cull for reverse @$self; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub all { |
58
|
234
|
|
|
234
|
1
|
570
|
my $self = shift; |
59
|
234
|
|
|
|
|
920
|
return @$self; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub clear { |
63
|
2
|
|
|
2
|
1
|
7
|
my $self = shift; |
64
|
2
|
|
|
|
|
5
|
@$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
|
|
612
|
no warnings 'once'; |
|
109
|
|
|
|
|
196
|
|
|
109
|
|
|
|
|
21263
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
*push = sub { |
74
|
140
|
|
|
140
|
|
644
|
my $self = shift; |
75
|
140
|
|
|
|
|
246
|
my ($hub) = @_; |
76
|
140
|
100
|
|
|
|
1003
|
$hub->inherit($self->[-1]) if @$self; |
77
|
140
|
|
|
|
|
424
|
push @$self => $hub; |
78
|
|
|
|
|
|
|
}; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
*pop = sub { |
81
|
365
|
|
|
365
|
|
1185
|
my $self = shift; |
82
|
365
|
|
|
|
|
656
|
my ($hub) = @_; |
83
|
365
|
100
|
|
|
|
1247
|
confess "No hubs on the stack" |
84
|
|
|
|
|
|
|
unless @$self; |
85
|
364
|
100
|
|
|
|
1178
|
confess "You cannot pop the root hub" |
86
|
|
|
|
|
|
|
if 1 == @$self; |
87
|
363
|
100
|
|
|
|
1450
|
confess "Hub stack mismatch, attempted to pop incorrect hub" |
88
|
|
|
|
|
|
|
unless $self->[-1] == $hub; |
89
|
362
|
|
|
|
|
1011
|
pop @$self; |
90
|
|
|
|
|
|
|
}; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |