Algorithm-Odometer-Tiny
view release on metacpan or search on metacpan
t/algorithm_odometer_tiny.t view on Meta::CPAN
0022 0023 0024 0025 0026 0027 0028 0029 002a 002b 002c 002d 002e
002f 002g 002h 002i 002j 002k 002l 002m 002n 002o 002p 002q 002r /],
'longer list';
}
{
my @wheels = ( ['foo','bar'], [3..6], ['quz','baz'] );
my $odo = Algorithm::Odometer::Gray->new(@wheels);
# note the following generates two "used only once" warnings on Perls 5.8 thru 5.18, that's ok
my $exp_len = reduce { $a * $b } map {0+@$_} @wheels; # product() was added in List::Util 1.35
is $exp_len, 16, 'expected length calc is correct';
my @c = $odo->();
is_deeply \@c, ['foo','3','quz'], 'basic ::Gray test 1/2';
my @o;
while (<$odo>) { push @o, $_ }
is_deeply \@o, [qw/ bar3quz bar4quz foo4quz foo5quz bar5quz bar6quz foo6quz
foo6baz bar6baz bar5baz foo5baz foo4baz bar4baz bar3baz foo3baz /],
'basic ::Gray test 2/2' or diag explain \@o;
is $odo->(), 'foo3quz', "re-start 1/2";
is $odo->(), 'bar3quz', "re-start 2/2";
}
( run in 0.631 second using v1.01-cache-2.11-cpan-65fba6d93b7 )