File: 02data.t

package info (click to toggle)
libhtml-embedded-turtle-perl 0.404-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 348 kB
  • sloc: perl: 3,090; makefile: 7; sh: 1
file content (82 lines) | stat: -rw-r--r-- 2,296 bytes parent folder | download | duplicates (2)
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
=pod

=encoding utf-8

=head1 PURPOSE

Test that data can be extracted using HTML::Embedded::Turtle.

=head1 AUTHOR

Toby Inkster E<lt>tobyink@cpan.orgE<gt>.

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2010-2011, 2013 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut

use strict;
use warnings;
use Test::More tests => 10;
use Test::RDF 0.23;
use HTML::Embedded::Turtle;
use RDF::Trine qw[statement iri literal blank variable];
use RDF::Trine::Namespace 'rdf';
my $foaf = RDF::Trine::Namespace->new('http://xmlns.com/foaf/0.1/');

my $het = HTML::Embedded::Turtle->new(<<'MARKUP', 'http://example.net/');
	<title property="http://purl.org/dc/terms/title">Test</title>
	<link rel=meta href="#endorsed">
	<script language=Turtle>
		@prefix foaf: <http://xmlns.com/foaf/0.1/> .
		[] a foaf:Person ; foaf:name "Joe Bloggs" .
	</script>
	<script type="text/turtle" id=endorsed>
		@prefix foaf: <http://xmlns.com/foaf/0.1/> .
		[] a foaf:Person ; foaf:name "Alice Smith" .
	</script>
	<script type="TEXT/TURTLE" id=unendorsed>
		@prefix foaf: <http://xmlns.com/foaf/0.1/> .
		[] a foaf:Person ; foaf:name "Bob Smith" .
	</script>
	<p>Hello</p>
MARKUP

pattern_target($het->union_graph);

pattern_ok(
	statement(variable('x'), $rdf->type, $foaf->Person),
	statement(variable('x'), $foaf->name, literal('Joe Bloggs')),
	);

pattern_ok(
	statement(variable('x'), $rdf->type, $foaf->Person),
	statement(variable('x'), $foaf->name, literal('Alice Smith')),
	);

pattern_ok(
	statement(variable('x'), $rdf->type, $foaf->Person),
	statement(variable('x'), $foaf->name, literal('Bob Smith')),
	);

is_deeply([ $het->endorsements ], ['http://example.net/#endorsed'], 'endorsed graph list is sensible');

pattern_target($het->endorsed_union_graph);

pattern_ok(
	statement(variable('x'), $rdf->type, $foaf->Person),
	statement(variable('x'), $foaf->name, literal('Alice Smith')),
	'second graph is endorsed'
	);

is($het->endorsed_union_graph->count_statements(undef, undef, literal('Joe Bloggs')),
	0, 'first graph is not endorsed');

is($het->endorsed_union_graph->count_statements(undef, undef, literal('Bob Smith')),
	0, 'third graph is not endorsed');

isa_ok($het->dom, 'XML::LibXML::Document');