File Coverage

File:local/lib/perl5/Test/Deep/Stack.pm
Coverage:55.4%

linestmtbrancondsubtimecode
1
6
6
6
13
5
96
use strict;
2
6
6
6
11
3
97
use warnings;
3
4package Test::Deep::Stack;
5
6
6
6
6
10
3
130
use Carp qw( confess );
7
6
6
6
11
4
98
use Scalar::Util;
8
9
6
6
6
734
7
32
use Test::Deep::MM qw( new init Stack Arrow );
10
11sub init
12{
13
54
32
        my $self = shift;
14
15
54
100
        $self->SUPER::init(@_);
16
17
54
74
        $self->setStack([]) unless $self->getStack;
18}
19
20sub push
21{
22
176
93
        my $self = shift;
23
24
176
176
78
187
        push(@{$self->getStack}, @_);
25}
26
27sub pop
28{
29
176
76
        my $self = shift;
30
31
176
176
77
134
        return pop @{$self->getStack};
32}
33
34sub render
35{
36
0
0
        my $self = shift;
37
0
0
        my $var = shift;
38
39
0
0
        my $stack = $self->getStack;
40
41
0
0
        $self->setArrow(0);
42
43
0
0
        foreach my $data (@$stack)
44        {
45
0
0
                my $exp = $data->{exp};
46
0
0
                if (Scalar::Util::blessed($exp) and $exp->isa("Test::Deep::Cmp"))
47                {
48
0
0
                        $var = $exp->render_stack($var, $data);
49
50
0
0
                        $self->setArrow(0) if $exp->reset_arrow;
51                }
52                else
53                {
54
0
0
                        confess "Don't know how to render '$exp'";
55                }
56        }
57
58
0
0
        return $var;
59}
60
61sub getLast
62{
63
22
15
        my $self = shift;
64
65
22
19
        return $self->getStack->[-1];
66}
67
68sub incArrow
69{
70
0
        my $self = shift;
71
72
0
        my $a = $self->getArrow;
73
0
        $self->setArrow($a + 1);
74
75
0
        return $a;
76}
77
78sub length
79{
80
0
        my $self = shift;
81
82
0
0
        return @{$self->getStack} + 0;
83}
84
851;