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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
use Test::More tests => 10;
use Test::Exception;
use FindBin qw($Bin);
use File::Spec;
use Data::Dumper;
use utf8;
use strict;
use warnings;
binmode( \*STDOUT, ':utf8' );
binmode( \*STDERR, ':utf8' );
use RDF::Trine qw(iri blank literal);
use RDF::Trine::Parser;
my $parser = RDF::Trine::Parser::NTriples->new();
isa_ok( $parser, 'RDF::Trine::Parser::NTriples' );
{
my $model = RDF::Trine::Model->temporary_model;
my $ntriples = <<"END";
<a> <a> <a> .
<a> <b> <c> .
<a> <b> _:a .
<a> <d> "D" .
<c> <b> <a> .
END
$parser->parse_into_model(undef, $ntriples, $model);
my $iter = $model->bounded_description( iri('a') );
isa_ok( $iter, 'RDF::Trine::Iterator::Graph' );
my @st = $iter->get_all;
is( scalar(@st), 5, 'expected triple count' );
my @expect = (
'(triple <a> <a> <a>)',
'(triple <a> <b> <c>)',
'(triple <a> <b> _:a)',
'(triple <a> <d> "D")',
'(triple <c> <b> <a>)',
);
my @seen = sort map { $_->as_string } @st;
is_deeply( \@seen, \@expect, 'BD with 0-outdegree bnode' );
}
{
my $model = RDF::Trine::Model->temporary_model;
my $ntriples = <<"END";
<a> <a> <a> .
<a> <b> <c> .
<a> <b> _:a .
_:a <c> "C" .
END
$parser->parse_into_model(undef, $ntriples, $model);
my $iter = $model->bounded_description( iri('a') );
isa_ok( $iter, 'RDF::Trine::Iterator::Graph' );
my @st = $iter->get_all;
is( scalar(@st), 4, 'expected triple count' );
my @expect = (
'(triple <a> <a> <a>)',
'(triple <a> <b> <c>)',
'(triple <a> <b> _:a)',
'(triple _:a <c> "C")'
);
my @seen = sort map { $_->as_string } @st;
is_deeply( \@seen, \@expect, 'BD with 1-outdegree bnode' );
}
{
my $model = RDF::Trine::Model->temporary_model;
my $ntriples = <<"END";
<a> <a> <a> .
<a> <b> <c> .
<a> <b> _:a .
_:a <c> _:c .
_:c <d> "D" .
END
$parser->parse_into_model(undef, $ntriples, $model);
my $iter = $model->bounded_description( iri('a') );
isa_ok( $iter, 'RDF::Trine::Iterator::Graph' );
my @st = $iter->get_all;
is( scalar(@st), 5, 'expected triple count' );
my @expect = (
'(triple <a> <a> <a>)',
'(triple <a> <b> <c>)',
'(triple <a> <b> _:a)',
'(triple _:a <c> _:c)',
'(triple _:c <d> "D")'
);
my @seen = sort map { $_->as_string } @st;
is_deeply( \@seen, \@expect, 'BD with 1-outdegree bnode chain' );
}
|