summaryrefslogtreecommitdiff
path: root/ext/arybase/t/aeach.t
blob: f56d39e246dc5f0c0f1ee814d7e1c56bfd835055 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use warnings;
use strict;

BEGIN {
	if("$]" < 5.011) {
		require Test::More;
		Test::More::plan(skip_all => "no array each on this Perl");
	}
}

use Test::More tests => 2;

our @activity;

$[ = 3;

our @t0 = qw(a b c);
@activity = ();
foreach(0..5) {
	push @activity, [ each(@t0) ];
}
is_deeply \@activity, [
	[ 3, "a" ],
	[ 4, "b" ],
	[ 5, "c" ],
	[],
	[ 3, "a" ],
	[ 4, "b" ],
];

our @t1 = qw(a b c);
@activity = ();
foreach(0..5) {
	push @activity, [ scalar each(@t1) ];
}
is_deeply \@activity, [
	[ 3 ],
	[ 4 ],
	[ 5 ],
	[ undef ],
	[ 3 ],
	[ 4 ],
];

1;