File: 1_nodes.t

package info (click to toggle)
librdf-helper-perl 2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 336 kB
  • sloc: perl: 1,827; makefile: 11
file content (67 lines) | stat: -rw-r--r-- 1,706 bytes parent folder | download
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
use Test::More;

use strict;
use warnings;
use Data::Dumper;

use RDF::Helper;

use constant URI1 => 'http://example.org/one';
use constant XSD_INT => 'http://www.w3.org/2001/XMLSchema#int';

#----------------------------------------------------------------------
# RDF::Redland
#----------------------------------------------------------------------
SKIP: {
  eval { require RDF::Redland };
  skip "RDF::Redland not installed", 6 if $@;

  my $rdf = RDF::Helper->new(
      BaseInterface => 'RDF::Redland',
      namespaces => {
		     xsd => 'http://www.w3.org/2001/XMLSchema#',
		    },
      ExpandQNames => 1,
      BaseURI => 'http://totalcinema.com/NS/test#'
  );
  
  test( $rdf );

}

#----------------------------------------------------------------------
# RDF::Trine
#----------------------------------------------------------------------
SKIP: {
  eval { require RDF::Trine };
  skip "RDF::Redland not installed", 6 if $@;

  my $rdf = RDF::Helper->new(
      BaseInterface => 'RDF::Trine',
      namespaces => {
		     xsd => 'http://www.w3.org/2001/XMLSchema#',
		    },
      ExpandQNames => 1,
      BaseURI => 'http://totalcinema.com/NS/test#'
  );

  test( $rdf );

}

sub test {
  my $rdf = shift;
  ok( $rdf->new_resource(URI1) );
  ok( $rdf->new_literal('A Value') );
  ok( $rdf->new_bnode );

  my $typed = $rdf->new_literal('15', undef, XSD_INT);
  my $typed2 = $rdf->new_literal('42.17', undef, 'xsd:decimal');
  my $langed = $rdf->new_literal('Speek Amurrican', 'en-US');

  is($typed->literal_datatype->as_string, XSD_INT);
  is($typed2->literal_datatype->as_string, 'http://www.w3.org/2001/XMLSchema#decimal');
  is($langed->literal_value_language, 'en-US');
}

done_testing();