Last active
February 6, 2019 17:22
-
-
Save kasei/8e4b1804319b9b15b4c4033961e989b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
subtest 'holds method' => sub { | |
my $graph = Attean::IRI->new('http://example.org/graph'); | |
my $store = Attean->get_store('Memory')->new(); | |
my $parser = Attean->get_parser('turtle')->new(); | |
my $data = <<'END'; | |
@prefix : <http://example.org/> . | |
@prefix foaf: <http://xmlns.com/foaf/> . | |
:alice a foaf:Person ; foaf:name "Alice" ; foaf:knows :bob . | |
:bob a foaf:Person ; foaf:name "Bob" ; foaf:knows :alice . | |
:eve a foaf:Person ; foaf:name "Eve" . | |
END | |
my $iter = $parser->parse_iter_from_bytes($data); | |
my $quads = $iter->as_quads($graph); | |
$store->add_iter($quads); | |
my $model = Attean::MutableQuadModel->new( store => $store ); | |
ok($model->holds(iri('http://example.org/alice')), 'holds(subj)'); | |
ok($model->holds(iri('http://example.org/alice'), iri('http://xmlns.com/foaf/knows')), 'holds(subj, pred)'); | |
ok(!$model->holds(iri('http://example.org/eve'), iri('http://xmlns.com/foaf/knows')), '!holds(subj, pred)'); | |
ok($model->holds(triplepattern(iri('http://example.org/alice'), iri('http://xmlns.com/foaf/name'), variable('name'))), 'holds(triplepattern)'); | |
ok($model->algebra_holds(bgp(triplepattern(iri('http://example.org/alice'), iri('http://xmlns.com/foaf/name'), variable('name')), triplepattern(iri('http://example.org/alice'), iri('http://xmlns.com/foaf/knows'), variable('friend'))), $graph), 'algebra_holds(bgp)'); | |
ok(!$model->algebra_holds(bgp(triplepattern(iri('http://example.org/eve'), iri('http://xmlns.com/foaf/name'), variable('name')), triplepattern(iri('http://example.org/eve'), iri('http://xmlns.com/foaf/knows'), variable('friend'))), $graph), '!algebra_holds(bgp)'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment