File: 40_defval.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 (53 lines) | stat: -rwxr-xr-x 942 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use Test::More tests => 7;

use strict;
use warnings;

use Iterator::Simple qw(:all);

my $itr;

{
	$_ = 'DUMMY';
	
	list(igrep { $_ % 5 } [1..20]);
	
	is($_, 'DUMMY', 'preserve $_ value after igrep');

	list(imap { $_ + 2 } [1..20]);

	is($_, 'DUMMY', 'preserve $_ value after imap');

	$itr = ifilter [1 .. 20], sub {
		if($_ % 5 == 0) {
			return iter([1 .. $_]); #inflate
		}
		elsif($_ % 3 == 0) {
			return; #skip
		}
		else {
			return $_;
		}
	};

	list($itr);

	is($_, 'DUMMY', 'preserve $_ value after ifilter');

	list(izip(['dogs', 'cats', 'pigs'], ['bowow','mew','oink']));

	is($_, 'DUMMY', 'preserve $_ value after izip');

	list(ichain ['blah', 'bla', 'bl'], ['foo', 'bar', 'baz']);

	is($_, 'DUMMY', 'preserve $_ value after ichain');

	list(ienumerate(['foo','bar','baz']));

	is($_, 'DUMMY', 'preserve $_ value after ienumerate');

	list(islice([1..100], 3, 20, 2));

	is($_, 'DUMMY', 'preserve $_ value after islice');
}