DR-Tarantool
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
t/040-tuple.t view on Meta::CPAN
is $tp->next->raw(0), 'bb', 'tuple[0]';
is $tp->next->next->raw(0), 'cc', 'tuple[0]';
$tp = DR::Tarantool::Tuple->unpack(
[ pack("L$LE", 10), pack("L$LE", 20) ], $s->space('test')
);
isa_ok $tp => 'DR::Tarantool::Tuple';
is $tp->raw(0), 10, 'raw(0)';
is $tp->raw(1), 20, 'raw(1)';
$tp = new DR::Tarantool::Tuple( [ [ 'aa' ], [ 'bb' ], ], $s->space('test') );
isa_ok $tp => 'DR::Tarantool::Tuple';
is $tp->iter->count, 2, 'create tuple list';
my $iter = $tp->iter;
isa_ok $iter => 'DR::Tarantool::Iterator', 'iterator';
isa_ok $iter->next => 'DR::Tarantool::Tuple', 'no iterator class';
$iter = $tp->iter('TestItem', 'new1');
isa_ok $iter => 'DR::Tarantool::Iterator', 'iterator with TestItem';
$tp = $iter->next;
isa_ok $tp => 'TestItem';
isa_ok $tp->{tuple} => 'DR::Tarantool::Tuple';
is $tp->{tuple}->raw(0), 'aa', 'tuple(0).raw(0)';
is $iter->next->{tuple}->raw(0), 'bb', 'tuple(1).raw(0)';
$tp = DR::Tarantool::Tuple->new([ [ 'aa' ], [ 'bb' ], ], $s->space('test'));
$iter = $tp->iter;
undef $tp;
is $iter->count, 2, 'iterator saves tuple ref';
# You have to use external tool to watch memory
while($ENV{LEAK_TEST}) {
$tp = DR::Tarantool::Tuple->new([ [ 'aa' ], [ 'bb' ], ], $s->space('test'));
$tp = $tp->iter('TestItem', 'new1')->next;
}
$tp = DR::Tarantool::Tuple->new([ [ 'bb' ], [ 'cc' ], ], $s->space('test'));
$iter = $tp->iter('TestItem');
is_deeply $iter->next, bless([ 'bb' ] => 'TestItem'),
'iter without constructor name';
is_deeply $iter->next, bless([ 'cc' ] => 'TestItem'),
'iter without constructor name';
is_deeply $iter->item(1), bless([ 'cc' ] => 'TestItem'),
'iter without constructor name';
is_deeply $iter->item(-1), bless([ 'cc' ] => 'TestItem'),
'iter without constructor name';
isa_ok $iter->{items}[0] => 'ARRAY', "item[0] isn't blessed";
isa_ok $iter->{items}[1] => 'ARRAY', "item[1] isn't blessed";
$tp = DR::Tarantool::Tuple->new([ qw(a b c d e f g h i) ], $s->space('test'));
is_deeply $tp->raw, [ qw(a b c d e f g h i) ], 'tuple->raw';
is_deeply $tp->tail, [ qw(g h i) ], 'tuple->tail';
package TestItem;
sub new1 {
my ($class, $tuple) = @_;
return bless { tuple => $tuple } => $class;
}
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.277 second using v1.00-cache-2.02-grep-82fe00e-cpan-9e6bc14194b6 )