aboutsummaryrefslogtreecommitdiff
path: root/t/List-Gather-Simple.t
blob: 5ed72d6f7c34f95016969bf1f0b154e9abc5dfc1 (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
#!/usr/bin/perl

use strict;
use warnings;

use Test::More;
BEGIN { use_ok('List::Gather::Simple') };

is_deeply [gather { take 1; take 2 }], [1,2], "double take";
is_deeply [gather { take for (1,2) }], [1,2], "take implicit argument";
is_deeply [gather { take for gather { take 1 } }], [1], "nested gather";
is_deeply [gather {
	@gathered = (1);
	take 2;
	push @gathered, 3;
}], [1,2,3], "@gathered";
is_deeply [gather {
	@gathered = (1);
	take gather {
		@gathered = (0);
	};
	take 2;
	push @gathered, 3;
}], [1,0,2,3], "nested @gathered";
is_deeply [gather { take 1 }, @gathered], [1], "localized @gathered";

done_testing;