File: 21_mapgrep.t

package info (click to toggle)
libiterator-simple-perl 0.07-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 180 kB
  • sloc: perl: 1,116; makefile: 2
file content (33 lines) | stat: -rwxr-xr-x 674 bytes parent folder | download | duplicates (2)
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
33
use Test::More tests=>7;

use strict;
use warnings;

use Iterator::Simple qw(:all);

my $itr;

#1
ok($itr = iarray ['foo','bar','bazz','fizz'] );


#2-3
{
	$itr = iarray ['foo','bar','bazz','fizz'];
	ok(($itr = imap { $_ . '_' } $itr ), 'imap creation');
	is_deeply(list($itr), [qw(foo_ bar_ bazz_ fizz_)], 'imap result');
}

#4-5
{
	$itr = iarray ['foo','bar','bazz','fizz'];
	ok(($itr = igrep { /^b/ } $itr ), 'igrep creation');
	is_deeply(list($itr), [qw(bar bazz)], 'igrep result');
}

#6-7
{
	$itr = iarray ['foo','bar','bazz','fizz'];
	ok(($itr = igrep { /^_b/ } imap { '_' . $_ } $itr ), 'chain creation');
	is_deeply(list($itr), [qw(_bar _bazz)], 'chain result');
}