File: are_subgraphs.t

package info (click to toggle)
libtest-rdf-perl 0.26-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 280 kB
  • sloc: perl: 1,642; makefile: 11
file content (137 lines) | stat: -rw-r--r-- 6,680 bytes parent folder | download | duplicates (7)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
use Test::Tester tests => 52;

use Test::RDF;

check_test(
	   sub {
	     my $model1 = RDF::Trine::Model->temporary_model;
	     my $model2 = RDF::Trine::Model->temporary_model;
	     my $parser = RDF::Trine::Parser->new( 'turtle' );
	     $parser->parse_into_model( 'http://example.org', '</foo> <http://www.w3.org/2000/01/rdf-schema#label> "This is a Another test"@en .', $model1);
	     $parser->parse_into_model( 'http://example.org', '</foo> <http://www.w3.org/2000/01/rdf-schema#label> "This is a Another test"@en .', $model2);
	     are_subgraphs($model1, $model2, 'Compare Turtle exact matches' );
	   },
	   {
	    ok => 1,
	    name => 'Compare Turtle exact matches',
	   }
);

check_test(
	   sub {
	     my $model1 = RDF::Trine::Model->temporary_model;
	     my $model2 = RDF::Trine::Model->temporary_model;
	     my $parser = RDF::Trine::Parser->new( 'turtle' );
	     $parser->parse_into_model( 'http://example.org', '</foo> <http://www.w3.org/2000/01/rdf-schema#label> "This is a Another test"@en ; <http://www.w3.org/2000/01/rdf-schema#comment> "With more" .', $model1);
	     $parser->parse_into_model( 'http://example.org', '</foo> <http://www.w3.org/2000/01/rdf-schema#label> "This is a Another test"@en .', $model2);
	     are_subgraphs($model1, $model2, 'Compare Turtle with extra in model1' );
	   },
	   {
	    ok => 0,
	    name => 'Compare Turtle with extra in model1',
	    diag => "Graph not subgraph: invocant had too many blank node statements to be a subgraph of argument\nHint: There are 2 statement(s) in model1 and 1 statement(s) in model2"
	   }
);


check_test(
	   sub {
	     my $model1 = RDF::Trine::Model->temporary_model;
	     my $model2 = RDF::Trine::Model->temporary_model;
	     my $parser = RDF::Trine::Parser->new( 'turtle' );
	     $parser->parse_into_model( 'http://example.org', '</foo> <http://www.w3.org/2000/01/rdf-schema#label> "This is a Another test"@en ; <http://www.w3.org/2000/01/rdf-schema#comment> "With more" .', $model1);
	     $parser->parse_into_model( 'http://example.org', '</foo> <http://www.w3.org/2000/01/rdf-schema#foo> "This is a Another test"@en ; <http://www.w3.org/2000/01/rdf-schema#comment> "With other" .', $model2);

	     are_subgraphs($model1, $model2, 'Compare Turtle with extra in both' );
	   },
	   {
	    ok => 0,
	    name => 'Compare Turtle with extra in both',
	    diag => "Hint: There are 2 statement(s) in model1 and 2 statement(s) in model2"
	   }
);


check_test(
	   sub {
	     my $model1 = RDF::Trine::Model->temporary_model;
	     my $model2 = RDF::Trine::Model->temporary_model;
	     my $parser1 = RDF::Trine::Parser->new( 'turtle' );
	     my $parser2 = RDF::Trine::Parser->new( 'rdfxml' );
	     $parser1->parse_into_model( 'http://example.org', '</foo> <http://www.w3.org/2000/01/rdf-schema#label> "This is a Another test"@en .', $model1);
	     $parser2->parse_into_model( 'http://example.org', '<?xml version="1.0" encoding="utf-8"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="/foo"><ns0:label xmlns:ns0="http://www.w3.org/2000/01/rdf-schema#" xml:lang="en">This is a Another test</ns0:label></rdf:Description></rdf:RDF>', $model2);
	     are_subgraphs($model1, $model2, 'Compare RDF/XML and Turtle');
	   },
	   {
	    ok => 1,
	    name => 'Compare RDF/XML and Turtle',
	   }
);
check_test(
	   sub {
	     my $model1 = RDF::Trine::Model->temporary_model;
	     my $model2 = RDF::Trine::Model->temporary_model;
	     my $parser = RDF::Trine::Parser->new( 'turtle' );
	     $parser->parse_into_model( 'http://example.org', '</foo> <http://www.w3.org/2000/01/rdf-schema#label> "This is a Another test"@en .', $model1);
	     $parser->parse_into_model( 'http://example.org', '</foo> <http://www.w3.org/2000/01/rdf-schema#label> "This is a Another test"@en ; <http://www.w3.org/2000/01/rdf-schema#comment> "With more" .', $model2);
	     are_subgraphs($model1, $model2, 'Compare Turtle with extra in model2' );
	   },
	   {
	    ok => 1,
	    name => 'Compare Turtle with extra in model2',
	   }
);


check_test(
	   sub {
	     my $model1 = RDF::Trine::Model->temporary_model;
	     my $model2 = RDF::Trine::Model->temporary_model;
	     my $parser1 = RDF::Trine::Parser->new( 'turtle' );
	     my $parser2 = RDF::Trine::Parser->new( 'rdfxml' );
	     $parser1->parse_into_model( 'http://example.org', '</foo> <http://www.w3.org/2000/01/rdf-schema#label> "This is a Another test"@en .', $model1);
	     $parser2->parse_into_model( 'http://example.org', '<?xml version="1.0" encoding="utf-8"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="/foo"><ns0:label xmlns:ns0="http://www.w3.org/2000/01/rdf-schema#" xml:lang="en">This is a Another test</ns0:label></rdf:Description></rdf:RDF>', $model2);
	     are_subgraphs($model1, $model2, 'Compare RDF/XML and Turtle');
	   },
	   {
	    ok => 1,
	    name => 'Compare RDF/XML and Turtle',
	   }
);



check_test(
	   sub {
	     my $model1 = RDF::Trine::Model->temporary_model;
	     my $model2 = RDF::Trine::Model->temporary_model;
	     my $parser = RDF::Trine::Parser->new( 'turtle' );
	     $parser->parse_into_model( 'http://example.org', '</foo> <http://www.w3.org/2000/01/rdf-schema#label> "This is a Another test"@en .', $model1);
	     $parser->parse_into_model( 'http://example.org', '</foo> <http://www.w3.org/2000/01/rdf-schema#label> "This is a test"@en .', $model2);
	     are_subgraphs($model1, $model2, 'Compare Turtle exact matches, with error' );
	   },
	   {
	    ok => 0,
	    name => 'Compare Turtle exact matches, with error',
	    diag => "Hint: There are 1 statement(s) in model1 and 1 statement(s) in model2"
	   }
);


check_test(
	   sub {
	     my $model1 = RDF::Trine::Model->temporary_model;
	     my $model2 = RDF::Trine::Model->temporary_model;
	     my $parser1 = RDF::Trine::Parser->new( 'turtle' );
	     my $parser2 = RDF::Trine::Parser->new( 'rdfxml' );
	     $parser1->parse_into_model( 'http://example.org', '</foo> <http://www.w3.org/2000/01/rdf-schema#label> "This is a Another test"@en .', $model1);

	     $parser2->parse_into_model( 'http://example.org', '<?xml version="1.0" encoding="utf-8"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="/foo"><ns0:label xmlns:ns0="http://www.w3.org/2000/01/rdf-schema#" xml:lang="en">This is a test</ns0:label></rdf:Description></rdf:RDF>', $model2);
	     are_subgraphs($model1, $model2, 'Compare RDF/XML and Turtle, with error');
	   },
	   {
	    ok => 0,
	    name => 'Compare RDF/XML and Turtle, with error',
	    diag => "Hint: There are 1 statement(s) in model1 and 1 statement(s) in model2"
	   }
);