aboutsummaryrefslogtreecommitdiff
path: root/challenge-095/james-smith/perl/ch-2.pl
blob: f953417ba77ec72a2986559718c11e19388fc0b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/local/bin/perl

use strict;

use warnings;
use feature qw(say);
use Test::More;
use lib q(.);
use Stack;

## Look at the Stack module for implementation

#                        return value  stack after op
my $stack = Stack->new;    # $stack    [          ]
$stack->push(2);           # $stack    [ 2        ]
$stack->push(-1);          # $stack    [ 2, -1    ]
$stack->push(0);           # $stack    [ 2, -1, 0 ]
$stack->pop;               # 0         [ 2, -1    ]
is( $stack->top, -1 );     # -1        [ 2, -1    ]
$stack->push(0);           # $stack    [ 2, -1, 0 ]
is( $stack->min, -1 );     # -1        [ 2, -1, 0 ]
$stack->pop;               # 0         [ 2, -1    ]
$stack->pop;               # -1        [ 2        ]
is( $stack->pop, 2 );      # 2         [          ]
is( $stack->top, undef );  # undef     [          ]

done_testing();