File: 02dbi.t

package info (click to toggle)
librdf-trin3-perl 0.206-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 440 kB
  • sloc: perl: 5,047; makefile: 13
file content (43 lines) | stat: -rw-r--r-- 1,040 bytes parent folder | download | duplicates (6)
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
use Test::More tests => 7;
BEGIN { use_ok('RDF::TriN3') };

my $store = RDF::Trine::Store::DBI->temporary_store;
$store->clear_restrictions;
my $model = RDF::Trine::Model->new($store);
ok($model, "RDF::Trine autoloaded");

my $n3 = <<NOTATION3;
\@prefix foaf: <http://xmlns.com/foaf/0.1/> .

#comment

{
	?person a foaf:Person .
} =>
	{
		?person a foaf:Agent .
	} .

NOTATION3

my $parser = RDF::Trine::Parser::Notation3->new();
ok($parser, "Created parser");

$parser->parse_into_model('http://example.com/', $n3, $model);

is($model->count_statements, 1, "Got exactly one statement.");

my $iter = $model->get_statements(undef, undef, undef, undef);
my $f;
while (my $st = $iter->next)
{
	ok($st, "Retrieved the statement");

	is($st->subject->as_ntriples,
		'"?person <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .\n"^^<http://open.vocab.org/terms/Formula>',
		'Statement looks good.');

	$f = $st->subject;
}

ok($f->pattern->[0]->isa('RDF::Trine::Statement'), 'Formulae can be introspected.');