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
|
#!/usr/bin/env perl
use strict;
use warnings;
no warnings 'redefine';
use Test::More;
use lib qw(. t);
require "models.pl";
my @files = map { "data/$_" } qw(about.xrdf foaf.xrdf);
my @models = test_models( @files );
my $tests = 1 + (scalar(@models) * 6);
plan tests => $tests;
use_ok( 'RDF::Query' );
foreach my $model (@models) {
print "\n#################################\n";
print "### Using model: $model\n\n";
{
my $query = new RDF::Query ( <<"END" );
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
SELECT ?name
WHERE {
[ a geo:Point; foaf:name ?name ]
}
END
my $stream = $query->execute( $model );
isa_ok( $stream, 'RDF::Trine::Iterator', 'stream' );
my $count;
while (not $stream->finished) {
my ($node) = $stream->binding_value( 0 );
my $name = $node->as_string;
ok( $name, $name );
} continue {
last if ++$count >= 100;
$stream->next_result;
};
}
{
my $query = new RDF::Query ( <<"END" );
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
SELECT ?name
WHERE {
[ a geo:Point; foaf:name ?name ]
}
END
my $stream = $query->execute( $model );
isa_ok( $stream, 'RDF::Trine::Iterator', 'stream' );
my $count;
while (my $row = $stream->next) {
my ($node) = $row->{name};
my $name = $node->as_string;
ok( $name, $name );
} continue { last if ++$count >= 100 };
}
}
|