Algorithm-Odometer-Tiny
view release on metacpan or search on metacpan
t/algorithm_odometer_tiny.t view on Meta::CPAN
120121122123124125126127128129130131132133134135136137138139140
my
@o1
;
push
@o1
,
$_
while
<
$odo1
>;
is_deeply \
@o1
, [
qw/ a1 a2 1 2 c1 c2 /
],
'::Tiny'
or diag explain \
@o1
;
my
$odo2
= Algorithm::Odometer::Gray->new( [
'a'
,
undef
,
'c'
],[1,2] );
my
@o2
;
push
@o2
,
$_
while
<
$odo2
>;
is_deeply \
@o2
, [
qw/ a1 1 c1 c2 2 a2 /
],
'::Gray'
or diag explain \
@o2
;
} ), 0,
'no uninitialized warnings'
;
};
SKIP: {
skip
"need Perl >= v5.18 for overloaded <> in list context"
,
2
if
$] lt
'5.018'
;
# [perl #47119]
my
$odo1
= Algorithm::Odometer::Tiny->new( [
'foo'
,
'bar'
], [3..5] );
is_deeply [<
$odo1
>], [
"foo3"
,
"foo4"
,
"foo5"
,
"bar3"
,
"bar4"
,
"bar5"
],
'list context <> ::Tiny'
;
my
$odo2
= Algorithm::Odometer::Gray->new( [
'a'
,
'b'
,
'c'
],[1,2] );
is_deeply [<
$odo2
>], [
"a1"
,
"b1"
,
"c1"
,
"c2"
,
"b2"
,
"a2"
],
'list context <> ::Gray'
;
}
subtest
'errors'
=>
sub
{ plan
tests
=>4;
like exception { Algorithm::Odometer::Tiny->new() },
qr/\bno wheels specified\b/
i,
'no wheels specified'
;
like exception { Algorithm::Odometer::Gray->new() },
qr/\bno wheels specified\b/
i,
'no wheels specified ::Gray'
;
like exception { Algorithm::Odometer::Gray->new([
'x'
,
'y'
],[
'z'
]) },
qr/\bat least two positions\b/
i,
'Gray at least two positions 1/2'
;
( run in 0.363 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )