File: reusable.t

package info (click to toggle)
libarray-iterator-perl 0.135-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 240 kB
  • sloc: perl: 730; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 648 bytes parent folder | download | duplicates (5)
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
29
30
31
32
#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 12;

BEGIN {
    use_ok('Array::Iterator::Reusable')
};

can_ok("Array::Iterator::Reusable", 'new');

my $i = Array::Iterator::Reusable->new(1 .. 5);
isa_ok($i, 'Array::Iterator::Reusable');
isa_ok($i, 'Array::Iterator');

can_ok($i, 'getNext');
can_ok($i, 'get_next');
# exhaust our iterator
1 while $i->getNext();

can_ok($i, 'hasNext');
can_ok($i, 'has_next');
ok(!$i->hasNext(), '... our iterator is exhausted');

can_ok($i, 'reset');
$i->reset();

ok($i->hasNext(), '... our iterator has been reset');

cmp_ok($i->currentIndex(), '==', 0, '... we are back to the begining');