Test/Attean/MutableQuadStore.pm

filter: Statementstmt 98.1% 103 / 105 Branchbran n/a Conditioncond 33.3% 4 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 100% 11 / 11 Podpod n/a totaltotal 86.7% 118 / 136 CC 8 SCAR 8.4
CC
8
Cov
91%
__ANON__
4.4
__ANON__
3.0
__ANON__
2.0
CRAP 2.3
« Attean/IRI.pm ↑ Summary Attean/Literal.pm »
1 package Test::Attean::MutableQuadStore;
2  
3 1 ▶use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Test::Roo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Test::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Attean;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Attean::RDF;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 requires 'create_store'; # create_store( quads => \@quads )
11 1 with 'Test::Attean::StoreCleanup';
12  
13 1 ▶test 'mutablequadstore add_quad' => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
14 1 my $self = shift;
15 1 my $q1 = quad(iri('s'), iri('p'), iri('o'), iri('g'));
16 1 my $q2 = quad(iri('x'), iri('y'), iri('z'), iri('g'));
17 1 my $q3 = quad(iri('x'), iri('y'), iri('z'), iri('g2'));
18
19 1 my $store = $self->create_store(quads => []);
20 1 my $size = 0;
21 1 for my $q ($q1, $q2, $q3) {
22 3 $store->add_quad($q);
23 3 is($store->size, ++$size, "size $size");
24 }
25 1 $self->cleanup_store($store);
26 1 };
27  
28 1 ▶test 'mutablequadstore remove_quad' => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
29 1 my $self = shift;
30 1 my $q1 = quad(iri('s'), iri('p'), iri('o'), iri('g'));
31 1 my $q2 = quad(iri('x'), iri('y'), iri('z'), iri('g'));
32 1 my $q3 = quad(iri('x'), iri('y'), iri('z'), iri('g2'));
33
34 1 my $store = $self->create_store(quads => [$q3, $q2, $q1]);
35 1 my $size = 3;
36 1 for my $q ($q1, $q2, $q3) {
37 3 is($store->size, $size, "size $size");
38 3 $store->remove_quad($q);
39 3 $size--;
40 }
41 1 $store->remove_quad($q2);
42 1 is($store->size, 0, "size $size");
43 1 $self->cleanup_store($store);
44 1 };
45  
46 1 ▶test 'mutablequadstore create_graph' => sub {
Subroutine __ANON__: called CC=4 SCAR=14.8
47 1 my $self = shift;
48 1 my $store = $self->create_store(quads => []);
49
50 1 my $count = 0;
51 1 foreach my $g (iri('g1'), iri('g2'), iri('g3')) {
52 3 $store->create_graph($g);
53 0 my @graphs = sort map { $_->value } $store->get_graphs->elements;
54 3 my $graphs = scalar(@graphs);
55 3 ▶ ok($graphs == 0 or $graphs == ++$count);
Condition33%1/3
$graphs == 0 || $graphs == ++$count
l!l&&r!l&&!r
300
MC/DC0%0/2
$graphs == 0 || $graphs == ++$count
$graphs == 0 $graphs == ++$count
Truth table33%1/3
A || B
A= $graphs == 0B= $graphs == ++$count
ABresult
1X1
011
000
56 }
57  
58 1 $store->create_graph(iri('g2'));
59 0 my @graphs = sort map { $_->value } $store->get_graphs->elements;
60 1 my $graphs = scalar(@graphs);
61 1 ▶ ok($graphs == 0 or $graphs == $count);
Condition33%1/3
$graphs == 0 || $graphs == $count
l!l&&r!l&&!r
100
MC/DC0%0/2
$graphs == 0 || $graphs == $count
$graphs == 0 $graphs == $count
Truth table33%1/3
A || B
A= $graphs == 0B= $graphs == $count
ABresult
1X1
011
000
62 1 $self->cleanup_store($store);
63 1 };
64  
65 1 ▶test 'mutablequadstore drop_graph' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
66 # drop_graph removes all the quads in a specific graph and removes the
67 # graph from the list of graphs returned as an iterator from
68 # $store->get_graphs
69 1 my $self = shift;
70 1 my $q1 = quad(iri('s'), iri('p'), iri('o'), iri('g'));
71 1 my $q2 = quad(iri('x'), iri('y'), iri('z'), iri('g'));
72 1 my $q3 = quad(iri('x'), iri('y'), iri('z'), iri('g2'));
73
74 {
75 1 my $store = $self->create_store(quads => [$q1, $q2, $q3]);
76 1 $store->drop_graph(iri('g'));
77 1 is($store->size, 1);
78 1 my @graphs = sort map { $_->value } $store->get_graphs->elements;
79 1 is_deeply(\@graphs, ['g2']);
80 1 $self->cleanup_store($store);
81 }
82 {
83 1 my $store = $self->create_store(quads => [$q1, $q2, $q3]);
84 1 $store->drop_graph(iri('g2'));
85 1 is($store->size, 2);
86 1 my @graphs = sort map { $_->value } $store->get_graphs->elements;
87 1 is_deeply(\@graphs, ['g']);
88 1 $self->cleanup_store($store);
89 }
90 1 };
91  
92 1 ▶test 'mutablequadstore clear_graph' => sub {
Subroutine __ANON__: called CC=3 SCAR=11.1
93 # clear_graph removes all the quads in a specific graph
94 # depending on whether the implementation supports empty graphs,
95 # the cleared graph may or may not disappear from the list of graphs
96 # returned as an iterator from $store->get_graphs
97 1 my $self = shift;
98 1 my $q1 = quad(iri('s'), iri('p'), iri('o'), iri('g'));
99 1 my $q2 = quad(iri('x'), iri('y'), iri('z'), iri('g'));
100 1 my $q3 = quad(iri('x'), iri('y'), iri('z'), iri('g2'));
101
102 {
103 1 my $store = $self->create_store(quads => [$q1, $q2, $q3]);
104 1 $store->clear_graph(iri('g'));
105 1 is($store->size, 1);
106 1 my @graphs = sort map { $_->value } $store->get_graphs->elements;
107 1 my $graphs = scalar(@graphs);
108 1 ▶ ok($graphs == 1 or $graphs == 2);
Condition33%1/3
$graphs == 1 || $graphs == 2
l!l&&r!l&&!r
100
MC/DC0%0/2
$graphs == 1 || $graphs == 2
$graphs == 1 $graphs == 2
Truth table33%1/3
A || B
A= $graphs == 1B= $graphs == 2
ABresult
1X1
011
000
109 1 $self->cleanup_store($store);
110 }
111 {
112 1 my $store = $self->create_store(quads => [$q1, $q2, $q3]);
113 1 $store->clear_graph(iri('g2'));
114 1 is($store->size, 2);
115 1 my @graphs = sort map { $_->value } $store->get_graphs->elements;
116 1 my $graphs = scalar(@graphs);
117 1 ▶ ok($graphs == 1 or $graphs == 2);
Condition33%1/3
$graphs == 1 || $graphs == 2
l!l&&r!l&&!r
100
MC/DC0%0/2
$graphs == 1 || $graphs == 2
$graphs == 1 $graphs == 2
Truth table33%1/3
A || B
A= $graphs == 1B= $graphs == 2
ABresult
1X1
011
000
118 1 $self->cleanup_store($store);
119 }
120 1 };
121  
122 1 1;
« Attean/IRI.pm ↑ Summary Attean/Literal.pm »