/usr/share/perl5/Test/Attean/QuadStore.pm is in libattean-perl 0.012-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | package Test::Attean::QuadStore;
use v5.14;
use warnings;
use Test::Roo::Role;
use Test::Moose;
use Attean;
use Attean::RDF;
requires 'create_store'; # create_store( quads => \@quads )
test 'quadstore roles' => sub {
my $self = shift;
my $store = $self->create_store(quads => []);
ok $store->does('Attean::API::Store');
ok $store->does('Attean::API::QuadStore');
my $qiter = $store->get_quads();
ok $qiter->does('Attean::API::Iterator');
is($qiter->item_type, 'Attean::API::Quad');
my $giter = $store->get_graphs;
ok $giter->does('Attean::API::Iterator');
is($giter->item_type, 'Attean::API::Term');
};
test 'quadstore get_quads empty' => sub {
my $self = shift;
my $store = $self->create_store(quads => []);
{
my $iter = $store->get_quads();
my @elements = $iter->elements;
is(scalar(@elements), 0);
}
{
my $iter = $store->get_quads(iri('s'), iri('p'));
my @elements = $iter->elements;
is(scalar(@elements), 0);
}
};
test 'quadstore get_quads with quads' => sub {
my $self = shift;
my $q1 = quad(iri('s'), iri('p'), iri('o'), iri('g'));
my $q2 = quad(iri('x'), iri('y'), iri('z'), iri('g'));
my $store = $self->create_store(quads => [$q1, $q2]);
{
my $iter = $store->get_quads();
my @elements = $iter->elements;
is(scalar(@elements), 2);
}
{
my $iter = $store->get_quads(iri('s'));
my @elements = $iter->elements;
is(scalar(@elements), 1);
}
{
my $iter = $store->get_quads(variable('s'), undef, undef, iri('g'));
my @elements = $iter->elements;
is(scalar(@elements), 2);
}
{
my $iter = $store->get_quads(iri('abc'));
my @elements = $iter->elements;
is(scalar(@elements), 0);
}
};
test 'count_quads' => sub {
my $self = shift;
my $q1 = quad(iri('s'), iri('p'), iri('o'), iri('g'));
my $q2 = quad(iri('x'), iri('y'), iri('z'), iri('g'));
my $store = $self->create_store(quads => [$q1, $q2]);
is($store->count_quads(), 2);
is($store->count_quads(iri('s')), 1);
is($store->count_quads(variable('s'), undef, undef, iri('g')), 2);
is($store->count_quads(iri('abc')), 0);
};
# test 'count_quads_estimate' => sub {};
test 'size' => sub {
my $self = shift;
my $q1 = quad(iri('s'), iri('p'), iri('o'), iri('g'));
my $q2 = quad(iri('x'), iri('y'), iri('z'), iri('g'));
my $q3 = quad(iri('x'), iri('y'), iri('z'), iri('g2'));
my $store = $self->create_store(quads => [$q1, $q2, $q3]);
is($store->size(), 3);
};
test 'get_graphs' => sub {
my $self = shift;
my $q1 = quad(iri('s'), iri('p'), iri('o'), iri('g'));
my $q2 = quad(iri('x'), iri('y'), iri('z'), iri('g'));
my $q3 = quad(iri('x'), iri('y'), iri('z'), iri('g2'));
my $store = $self->create_store(quads => [$q1, $q2, $q3]);
my $iter = $store->get_graphs;
my @graphs = sort map { $_->value } $iter->elements;
is_deeply(\@graphs, ['g', 'g2']);
};
1;
|