#!/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 };
}
}