/
10_parse.t
38 lines (26 loc) · 900 Bytes
/
10_parse.t
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
use strict;
use warnings;
use Test::More;
use RDF::Lazy;
my $data = join('',<DATA>);
my $rdf = RDF::Lazy->new($data);
is( $rdf->size, 4, 'rdf data as first parameter' );
$rdf = RDF::Lazy->new( rdf => $data );
is( "$rdf", "4 triples", 'rdf data with named parameter' );
my $s = $rdf->uri('"hello"');
is( $s->str, "hello", 'parse plain literal' );
$s = $rdf->uri('"hello"@en');
is( $s->lang, "en", 'parse literal with language' );
$s = $rdf->uri('true');
is( $s->str, "true", 'parse plain true' );
# ...
# Turtle
like ( $rdf->ttlpre, qr/^<pre/ );
done_testing;
__DATA__
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
<http://example.org/alice> foaf:knows <http://example.org/bob> .
<http://example.org/bob> foaf:knows <http://example.org/alice> .
<http://example.org/alice> foaf:name "Alice" .
<http://example.org/bob> foaf:name "Bob" .