File: algebra-bgp.t

package info (click to toggle)
librdf-query-perl 2.919-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,580 kB
  • sloc: perl: 30,628; javascript: 131; sh: 13; makefile: 2
file content (54 lines) | stat: -rw-r--r-- 1,583 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/env perl
use strict;
use warnings;
no warnings 'redefine';
use utf8;

use Test::More tests => 7;
use Test::Exception;
use Scalar::Util qw(reftype blessed);

use RDF::Query;
use RDF::Query::Node;
use RDF::Query::Algebra;
use RDF::Query::Parser::SPARQL;

my $parser	= RDF::Query::Parser::SPARQL->new();

my $ns		= { foaf => 'http://xmlns.com/foaf/0.1/' };

{
	my ($bgp)	= $parser->parse_pattern('{ ?p a foaf:Person }', undef, $ns)->patterns;
	ok( $bgp->connected, 'single-connected BGP' );
}

{
	my ($bgp)	= $parser->parse_pattern('{ ?p a foaf:Person ; foaf:name ?name }', undef, $ns)->patterns;
	ok( $bgp->connected, 'connected BGP' );
}

{
	my ($bgp)	= $parser->parse_pattern('{ ?a ?b ?c . ?c ?d ?e . ?e ?f ?g . ?g ?h ?i }', undef, $ns)->patterns;
	ok( $bgp->connected, 'connected chain BGP' );
}

{
	my ($bgp)	= $parser->parse_pattern('{ ?a ?b ?c . ?e ?f ?g . ?c ?d ?e . ?g ?h ?a }', undef, $ns)->patterns;
	ok( $bgp->connected, 'connected loop BGP' );
}

{
	my ($bgp)	= $parser->parse_pattern('{ ?p a foaf:Person ; foaf:name ?name ; foaf:knows ?q . ?q a foaf:Person ; foaf:name ?name }', undef, $ns)->patterns;
	ok( $bgp->connected, '(multi-)connected BGP' );
}

{
	my ($bgp)	= $parser->parse_pattern('{ ?p a foaf:Person . ?q a foaf:Person }', undef, $ns)->patterns;
	ok( not($bgp->connected), 'non-connected two-triples BGP' );
}

{
	my ($bgp)	= $parser->parse_pattern('{ ?p a foaf:Person ; foaf:name ?name . ?q a foaf:Person ; foaf:homepage ?h . ?h foaf:isPrimaryTopicOf ?t }', undef, $ns)->patterns;
	ok( not($bgp->connected), 'non-connected two-clusteres BGP' );
}