Debian Codegraph @

t/model.t

raw
1 #!/usr/bin/env perl
2
3 use strict;
4 use Test::More;
5 use RDF::Trine qw(iri);
6
7 use_ok('RDF::TrineX::Compatibility::Attean');
8
9 use_ok('RDF::Trine::Model');
10
11 can_ok('RDF::Trine::Model', 'get_quads');
12 can_ok('RDF::Trine::Model', 'count_quads');
13
14 my $testmodel = RDF::Trine::Model->temporary_model;
15 my $parser = RDF::Trine::Parser->new( 'turtle' );
16
17 my $testdata = '<http://example.org/foo> a <http://example.org/Bar> ; <http://example.org/title> "Dahut"@fr ; <http://example.org/something> [ <http://example.org/else> "Foo" ; <http://example.org/pi> 3.14 ] .';
18
19 $parser->parse_into_model('http://example.org/', $testdata, $testmodel );
20
21 subtest 'get_quads' => sub {
22 ok(my $iter = $testmodel->get_quads(undef, iri('http://example.org/pi'), undef, undef), 'Query sent ok');
23 isa_ok($iter, 'RDF::Trine::Iterator');
24 ok(my $row = $iter->next, 'Got an element from the iterator');
25 ok(my $lit = $row->object, 'Got the object');
26 is($lit->value, 3.14, 'Value roundtripped');
27 isa_ok($lit->datatype, 'RDF::Trine::Node::Resource');
28 is($lit->datatype->value, 'http://www.w3.org/2001/XMLSchema#decimal', 'datatype roundtripped');
29 };
30
31 subtest 'count_quads' => sub {
32 is($testmodel->count_quads(iri('http://example.org/foo'), undef, undef, undef), 3, 'Correct counts');
33 };
34
35 done_testing;