rdf_context 0.4.8 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +27 -0
- data/README.rdoc +22 -9
- data/Rakefile +11 -6
- data/VERSION +1 -1
- data/bin/rdf_context +12 -4
- data/lib/rdf_context.rb +3 -1
- data/lib/rdf_context/aggregate_graph.rb +86 -0
- data/lib/rdf_context/array_hacks.rb +53 -0
- data/lib/rdf_context/conjunctive_graph.rb +1 -1
- data/lib/rdf_context/exceptions.rb +9 -7
- data/lib/rdf_context/graph.rb +174 -15
- data/lib/rdf_context/literal.rb +34 -2
- data/lib/rdf_context/n3_grammar.treetop +213 -129
- data/lib/rdf_context/n3parser.rb +281 -57
- data/lib/rdf_context/namespace.rb +23 -12
- data/lib/rdf_context/parser.rb +4 -3
- data/lib/rdf_context/quoted_graph.rb +38 -0
- data/lib/rdf_context/rdfaparser.rb +2 -1
- data/lib/rdf_context/rdfxmlparser.rb +4 -3
- data/lib/rdf_context/store/abstract_sql_store.rb +4 -4
- data/lib/rdf_context/store/abstract_store.rb +5 -1
- data/lib/rdf_context/store/sqlite3_store.rb +10 -8
- data/lib/rdf_context/string_hacks.rb +44 -21
- data/lib/rdf_context/term_utils.rb +73 -4
- data/lib/rdf_context/triple.rb +32 -47
- data/lib/rdf_context/uriref.rb +33 -26
- data/spec/aggregate_graph_spec.rb +59 -0
- data/spec/conjunctive_graph_spec.rb +1 -1
- data/spec/cwm_spec.rb +32 -0
- data/spec/graph_spec.rb +114 -3
- data/spec/literal_spec.rb +107 -5
- data/spec/matchers.rb +104 -51
- data/spec/n3parser_spec.rb +798 -99
- data/spec/namespaces_spec.rb +26 -0
- data/spec/quoted_graph_spec.rb +0 -0
- data/spec/rdf_helper.rb +197 -0
- data/spec/rdfa_helper.rb +15 -11
- data/spec/rdfa_parser_spec.rb +6 -8
- data/spec/rdfxml_spec.rb +21 -28
- data/spec/spec_helper.rb +20 -0
- data/spec/sqlite3_store_spec.rb +6 -5
- data/spec/store_helper.rb +9 -1
- data/spec/string_hacks_spec.rb +14 -0
- data/spec/{rdfxml_helper.rb → swap_helper.rb} +8 -9
- data/spec/swap_spec.rb +77 -0
- data/spec/swap_test/animal.rdf +17 -0
- data/spec/swap_test/anon-prop.n3 +14 -0
- data/spec/swap_test/anonymous_loop.n3 +2 -0
- data/spec/swap_test/contexts.n3 +16 -0
- data/spec/swap_test/daml-pref.n3 +10 -0
- data/spec/swap_test/i18n/hiragana.n3 +22 -0
- data/spec/swap_test/i18n/n3string.n3 +4 -0
- data/spec/swap_test/list/itemType.rdf +12 -0
- data/spec/swap_test/lists-simple.n3 +40 -0
- data/spec/swap_test/lists.n3 +35 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10001.nt +3 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10002.nt +7 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10003.nt +3 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10004.nt +119 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10005.nt +3 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10006.nt +225 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10007.nt +79 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10008.nt +5 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10009.nt +13 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10010.nt +21 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10011.nt +9 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10012.nt +53 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10013.nt +19 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10014.nt +103 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10015.nt +103 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10016.nt +3 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10017.nt +151 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10018.nt +9 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10019.nt +3 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10020.nt +13 -0
- data/spec/swap_test/n3parser.tests +160 -0
- data/spec/swap_test/nodeID/classes.n3 +9 -0
- data/spec/swap_test/nodeID/classes.ref.rdf +15 -0
- data/spec/swap_test/nodeID/ex1.rdf +15 -0
- data/spec/swap_test/norm/fix.rdf +33 -0
- data/spec/swap_test/owl-ex.rdf +150 -0
- data/spec/swap_test/ref/animal.n3 +11 -0
- data/spec/swap_test/ref/anon-prop-1.n3 +8 -0
- data/spec/swap_test/ref/anonymous_loop.ref +7 -0
- data/spec/swap_test/ref/bnode.n3 +6 -0
- data/spec/swap_test/ref/bnode.rdf +16 -0
- data/spec/swap_test/ref/colon-in-uri.n3 +15 -0
- data/spec/swap_test/ref/daml-ex.n3 +103 -0
- data/spec/swap_test/ref/daml-ont.n3 +289 -0
- data/spec/swap_test/ref/djb1a-out.n3 +4 -0
- data/spec/swap_test/ref/dot-dash.n3 +8 -0
- data/spec/swap_test/ref/in-xml-t.n3 +4 -0
- data/spec/swap_test/ref/itemType.n3 +9 -0
- data/spec/swap_test/ref/keywords1.n3 +11 -0
- data/spec/swap_test/ref/keywords2.n3 +11 -0
- data/spec/swap_test/ref/lists-simple-1.rdf +108 -0
- data/spec/swap_test/ref/lists.n3 +43 -0
- data/spec/swap_test/ref/lstring-out.n3 +20 -0
- data/spec/swap_test/ref/n3string.n3 +13 -0
- data/spec/swap_test/ref/no-last-nl.n3 +3 -0
- data/spec/swap_test/ref/numbers.n3 +18 -0
- data/spec/swap_test/ref/path1.n3 +8 -0
- data/spec/swap_test/ref/path2.n3 +39 -0
- data/spec/swap_test/ref/prefix1.rdf +31 -0
- data/spec/swap_test/ref/prefix3.rdf +31 -0
- data/spec/swap_test/ref/rdf-redefine.rdf +11 -0
- data/spec/swap_test/ref/reluri-1.rdf +18 -0
- data/spec/swap_test/ref/strquot.n3 +23 -0
- data/spec/swap_test/ref/strquot_a.n3 +23 -0
- data/spec/swap_test/ref/xml-base3.n3 +5 -0
- data/spec/swap_test/ref/xml-redefine.rdf +20 -0
- data/spec/swap_test/ref/xml-redefine2.rdf +23 -0
- data/spec/swap_test/ref/xml-syntax-basic-serialization.rdf +10 -0
- data/spec/swap_test/ref/xmllit.nt +3 -0
- data/spec/swap_test/regression.n3 +231 -0
- data/spec/swap_test/reluri-1.n3 +10 -0
- data/spec/swap_test/strquot.n3 +23 -0
- data/spec/swap_test/syntax/colon-in-uri.rdf +27 -0
- data/spec/swap_test/syntax/djb1a.n3 +3 -0
- data/spec/swap_test/syntax/dot-dash.n3 +15 -0
- data/spec/swap_test/syntax/equals1.n3 +1 -0
- data/spec/swap_test/syntax/equals2.n3 +1 -0
- data/spec/swap_test/syntax/keywords1.n3 +17 -0
- data/spec/swap_test/syntax/keywords2.n3 +18 -0
- data/spec/swap_test/syntax/lstring.n3 +26 -0
- data/spec/swap_test/syntax/neg-formula-predicate.n3 +1 -0
- data/spec/swap_test/syntax/neg-keywords3.n3 +1 -0
- data/spec/swap_test/syntax/neg-literal-predicate.n3 +1 -0
- data/spec/swap_test/syntax/neg-single-quote.n3 +1 -0
- data/spec/swap_test/syntax/neg-thisadoc.n3 +1 -0
- data/spec/swap_test/syntax/no-last-nl.n3 +2 -0
- data/spec/swap_test/syntax/numbers.n3 +26 -0
- data/spec/swap_test/syntax/path1.n3 +23 -0
- data/spec/swap_test/syntax/path2.n3 +31 -0
- data/spec/swap_test/syntax/qvars1.n3 +19 -0
- data/spec/swap_test/syntax/qvars2.n3 +19 -0
- data/spec/swap_test/syntax/this-quantifiers.n3 +164 -0
- data/spec/swap_test/syntax/this-rules.n3 +43 -0
- data/spec/swap_test/syntax/too-nested.n3 +25 -0
- data/spec/swap_test/syntax/trailing-semicolon.n3 +12 -0
- data/spec/swap_test/syntax/zero-objects.n3 +1 -0
- data/spec/swap_test/syntax/zero-predicates.n3 +3 -0
- data/spec/swap_test/tests-work.txt +25 -0
- data/spec/swap_test/xml-syntax/basic-serialization.n3 +8 -0
- data/spec/swap_test/xml-syntax/in-xml.xml +13 -0
- data/spec/swap_test/xml-syntax/non-ascii-pred.rdf +14 -0
- data/spec/swap_test/xml-syntax/rdf_prefix.n3 +2 -0
- data/spec/swap_test/xml-syntax/xml_prefix.n3 +7 -0
- data/spec/swap_test/xml-syntax/xml_prefix2.n3 +9 -0
- data/spec/swap_test/xml-syntax/xmlbase3.rdf +10 -0
- data/spec/swap_test/xml-syntax/xmllit.rdf +33 -0
- data/spec/triple_spec.rb +90 -46
- data/spec/turtle/README.txt +20 -0
- data/spec/turtle/bad-00.ttl +2 -0
- data/spec/turtle/bad-01.ttl +3 -0
- data/spec/turtle/bad-02.ttl +3 -0
- data/spec/turtle/bad-03.ttl +3 -0
- data/spec/turtle/bad-04.ttl +3 -0
- data/spec/turtle/bad-05.ttl +4 -0
- data/spec/turtle/bad-06.ttl +3 -0
- data/spec/turtle/bad-07.ttl +4 -0
- data/spec/turtle/bad-08.ttl +2 -0
- data/spec/turtle/bad-09.ttl +3 -0
- data/spec/turtle/bad-10.ttl +3 -0
- data/spec/turtle/bad-11.ttl +3 -0
- data/spec/turtle/bad-12.ttl +3 -0
- data/spec/turtle/bad-13.ttl +3 -0
- data/spec/turtle/bad-14.ttl +6 -0
- data/spec/turtle/manifest-bad.ttl +88 -0
- data/spec/turtle/manifest.ttl +215 -0
- data/spec/turtle/rdf-schema.out +126 -0
- data/spec/turtle/rdf-schema.ttl +156 -0
- data/spec/turtle/rdfq-results.out +36 -0
- data/spec/turtle/rdfq-results.ttl +39 -0
- data/spec/turtle/rdfs-namespace.out +131 -0
- data/spec/turtle/rdfs-namespace.ttl +160 -0
- data/spec/turtle/test-00.out +1 -0
- data/spec/turtle/test-00.ttl +2 -0
- data/spec/turtle/test-01.out +3 -0
- data/spec/turtle/test-01.ttl +7 -0
- data/spec/turtle/test-02.out +3 -0
- data/spec/turtle/test-02.ttl +5 -0
- data/spec/turtle/test-03.out +3 -0
- data/spec/turtle/test-03.ttl +5 -0
- data/spec/turtle/test-04.out +2 -0
- data/spec/turtle/test-04.ttl +4 -0
- data/spec/turtle/test-05.out +4 -0
- data/spec/turtle/test-05.ttl +4 -0
- data/spec/turtle/test-06.out +1 -0
- data/spec/turtle/test-06.ttl +3 -0
- data/spec/turtle/test-07.out +5 -0
- data/spec/turtle/test-07.ttl +3 -0
- data/spec/turtle/test-08.out +1 -0
- data/spec/turtle/test-08.ttl +3 -0
- data/spec/turtle/test-09.out +4 -0
- data/spec/turtle/test-09.ttl +10 -0
- data/spec/turtle/test-10.out +5 -0
- data/spec/turtle/test-10.ttl +5 -0
- data/spec/turtle/test-11.out +4 -0
- data/spec/turtle/test-11.ttl +10 -0
- data/spec/turtle/test-12.out +4 -0
- data/spec/turtle/test-12.ttl +9 -0
- data/spec/turtle/test-13.out +2 -0
- data/spec/turtle/test-13.ttl +7 -0
- data/spec/turtle/test-14.out +10000 -0
- data/spec/turtle/test-14.ttl +10002 -0
- data/spec/turtle/test-15.out +10000 -0
- data/spec/turtle/test-15.ttl +3 -0
- data/spec/turtle/test-16.out +10000 -0
- data/spec/turtle/test-16.ttl +10002 -0
- data/spec/turtle/test-17.out +1 -0
- data/spec/turtle/test-17.ttl +6 -0
- data/spec/turtle/test-18.out +2 -0
- data/spec/turtle/test-18.ttl +9 -0
- data/spec/turtle/test-19.out +1 -0
- data/spec/turtle/test-19.ttl +4 -0
- data/spec/turtle/test-20.out +2 -0
- data/spec/turtle/test-20.ttl +6 -0
- data/spec/turtle/test-21.out +3 -0
- data/spec/turtle/test-21.ttl +4 -0
- data/spec/turtle/test-22.out +3 -0
- data/spec/turtle/test-22.ttl +4 -0
- data/spec/turtle/test-23.out +1 -0
- data/spec/turtle/test-23.ttl +3 -0
- data/spec/turtle/test-24.out +2 -0
- data/spec/turtle/test-24.ttl +3 -0
- data/spec/turtle/test-25.out +7 -0
- data/spec/turtle/test-25.ttl +14 -0
- data/spec/turtle/test-26.out +1 -0
- data/spec/turtle/test-26.ttl +4 -0
- data/spec/turtle/test-27.out +1 -0
- data/spec/turtle/test-27.ttl +5 -0
- data/spec/turtle/test-28-out.ttl +6 -0
- data/spec/turtle/test-28.out +22 -0
- data/spec/turtle/test-28.ttl +22 -0
- data/spec/turtle/test-29.out +1 -0
- data/spec/turtle/test-29.ttl +1 -0
- data/spec/turtle/test-30.out +5 -0
- data/spec/turtle/test-30.ttl +12 -0
- data/spec/turtle_spec.rb +64 -0
- data/spec/uriref_spec.rb +74 -34
- data/test/n3_tests/rdflib/n3-writer-teset-26.n3 +31 -0
- data/test/n3_tests/rdflib/n3-writer-teset-26.nt +14 -0
- data/test/rdf_tests/xml-literal-mixed.nt +1 -2
- metadata +278 -39
- data/lib/rdf_context/n3_grammar.rb +0 -2171
- data/test/perf_test/test.rb +0 -11
- data/test/perf_test/tommorris.rdf +0 -2267
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
<rdf:RDF xmlns="http://example.com/swap/test/includes/non-ascii.n3#"
|
5
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
6
|
+
|
7
|
+
<rdf:Description rdf:about="#my">
|
8
|
+
<name>Joerg</name>
|
9
|
+
</rdf:Description>
|
10
|
+
|
11
|
+
<rdf:Description rdf:about="#僕">
|
12
|
+
<名前>ヨーク</名前>
|
13
|
+
</rdf:Description>
|
14
|
+
</rdf:RDF>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<rdf:RDF xml:base="http://example.org/"
|
3
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
4
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
5
|
+
<rdf:Description rdf:about="http://www.w3.org/" xml:base="test1/">
|
6
|
+
<dc:title>World Wide Web Consortium</dc:title>
|
7
|
+
<dc:source rdf:resource="test2/"/>
|
8
|
+
<dc:relation rdf:resource=""/>
|
9
|
+
</rdf:Description>
|
10
|
+
</rdf:RDF>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
|
3
|
+
<!--
|
4
|
+
Copyright World Wide Web Consortium, (Massachusetts Institute of
|
5
|
+
Technology, Institut National de Recherche en Informatique et en
|
6
|
+
Automatique, Keio University).
|
7
|
+
|
8
|
+
All Rights Reserved.
|
9
|
+
|
10
|
+
Please see the full Copyright clause at
|
11
|
+
<http://www.w3.org/Consortium/Legal/copyright-software.html>
|
12
|
+
|
13
|
+
Description: Visibly used namespaces must be included in XML
|
14
|
+
Literal values. Treatment of namespaces that are not
|
15
|
+
visibly used (e.g. rdf: in this example) is implementation
|
16
|
+
dependent. Based on example from Issues List.
|
17
|
+
|
18
|
+
|
19
|
+
$Id: xmllit.rdf,v 1.1 2005-09-01 20:43:01 syosi Exp $
|
20
|
+
|
21
|
+
-->
|
22
|
+
<rdf:RDF xmlns="http://www.w3.org/1999/xhtml"
|
23
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
24
|
+
xmlns:html="http://NoHTML.example.org"
|
25
|
+
xmlns:my="http://my.example.org/">
|
26
|
+
<rdf:Description rdf:ID="John_Smith">
|
27
|
+
<my:Name rdf:parseType="Literal">
|
28
|
+
<html:h1 my:thing="hello">
|
29
|
+
<b><i>John</i></b>
|
30
|
+
</html:h1>
|
31
|
+
</my:Name>
|
32
|
+
</rdf:Description>
|
33
|
+
</rdf:RDF>
|
data/spec/triple_spec.rb
CHANGED
@@ -2,16 +2,86 @@ require File.join(File.dirname(__FILE__), 'spec_helper')
|
|
2
2
|
|
3
3
|
describe "Triples" do
|
4
4
|
before(:all) { @graph = Graph.new(:store => ListStore.new) }
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
|
6
|
+
describe "with subjects" do
|
7
|
+
it "should allow URIRef" do
|
8
|
+
v = URIRef.new("http://foo")
|
9
|
+
Triple.new(v, RDF_TYPE, "obj").subject.should == v
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should allow BNode" do
|
13
|
+
v = BNode.new
|
14
|
+
Triple.new(v, RDF_TYPE, "obj").subject.should == v
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should allow Literal" do
|
18
|
+
v = Literal.untyped("foo")
|
19
|
+
Triple.new(v, RDF_TYPE, "obj").subject.should == v
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should allow Graph" do
|
23
|
+
v = Graph.new
|
24
|
+
Triple.new(v, RDF_TYPE, "obj").subject.should == v
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should allow QuotedGraph" do
|
28
|
+
v = QuotedGraph.new
|
29
|
+
Triple.new(v, RDF_TYPE, "obj").subject.should == v
|
30
|
+
end
|
9
31
|
end
|
10
32
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
33
|
+
describe "with predicates" do
|
34
|
+
it "should allow URIRef" do
|
35
|
+
v = URIRef.new("http://foo")
|
36
|
+
Triple.new(RDF_NS.Seq, v, "obj").predicate.should == v
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should allow BNode" do
|
40
|
+
v = BNode.new
|
41
|
+
Triple.new(RDF_NS.Seq, v, "obj").predicate.should == v
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should not allow Literal" do
|
45
|
+
v = Literal.untyped("foo")
|
46
|
+
lambda {Triple.new(RDF_NS.Seq, v, "obj")}.should raise_error
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should not allow Graph" do
|
50
|
+
v = Graph.new
|
51
|
+
lambda {Triple.new(RDF_NS.Seq, v, "obj")}.should raise_error
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should not allow QuotedGraph" do
|
55
|
+
v = QuotedGraph.new
|
56
|
+
lambda {Triple.new(RDF_NS.Seq, v, "obj")}.should raise_error
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "with objects" do
|
61
|
+
it "should allow URIRef" do
|
62
|
+
v = URIRef.new("http://foo")
|
63
|
+
Triple.new(RDF_NS.Seq, RDF_TYPE, v).object.should == v
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should allow BNode" do
|
67
|
+
v = BNode.new
|
68
|
+
Triple.new(RDF_NS.Seq, RDF_TYPE, v).object.should == v
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should allow Literal" do
|
72
|
+
v = Literal.untyped("foo")
|
73
|
+
Triple.new(RDF_NS.Seq, RDF_TYPE, v).object.should == v
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should allow Graph" do
|
77
|
+
v = Graph.new
|
78
|
+
Triple.new(RDF_NS.Seq, RDF_TYPE, v).object.should == v
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should allow QuotedGraph" do
|
82
|
+
v = QuotedGraph.new
|
83
|
+
Triple.new(RDF_NS.Seq, RDF_TYPE, v).object.should == v
|
84
|
+
end
|
15
85
|
end
|
16
86
|
|
17
87
|
it "should require that the object is a URIRef, BNode, Literal or Typed Literal" do
|
@@ -47,32 +117,6 @@ describe "Triples" do
|
|
47
117
|
end
|
48
118
|
end
|
49
119
|
|
50
|
-
describe "with coerced subject" do
|
51
|
-
it "should accept a URIRef" do
|
52
|
-
ref = URIRef.new('http://localhost/')
|
53
|
-
Triple.coerce_subject(ref).should == ref
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should accept a BNode" do
|
57
|
-
node = BNode.new('a')
|
58
|
-
Triple.coerce_subject(node).should == node
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should accept a uri string and make URIRef" do
|
62
|
-
Triple.coerce_subject('http://localhost/').should == URIRef.new('http://localhost/')
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should accept an Addressable::URI object and make URIRef" do
|
66
|
-
Triple.coerce_subject(Addressable::URI.parse("http://localhost/")).should == URIRef.new("http://localhost/")
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should raise an InvalidSubject exception with any other class argument" do
|
70
|
-
lambda do
|
71
|
-
Triple.coerce_subject(Object.new)
|
72
|
-
end.should raise_error(Triple::InvalidSubject)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
120
|
describe "with coerced predicate" do
|
77
121
|
it "should make a string into a URI ref" do
|
78
122
|
Triple.coerce_predicate("http://localhost/").should == URIRef.new('http://localhost/')
|
@@ -90,47 +134,47 @@ describe "Triples" do
|
|
90
134
|
end
|
91
135
|
end
|
92
136
|
|
93
|
-
describe "with coerced
|
137
|
+
describe "with coerced node" do
|
94
138
|
it 'should make a literal for Integer types' do
|
95
139
|
ref = 5
|
96
|
-
Triple.
|
140
|
+
Triple.coerce_node(ref).should == Literal.build_from(ref)
|
97
141
|
end
|
98
142
|
|
99
143
|
it 'should make a literal for Float types' do
|
100
144
|
ref = 15.4
|
101
|
-
Triple.
|
145
|
+
Triple.coerce_node(ref).should == Literal.build_from(ref)
|
102
146
|
end
|
103
147
|
|
104
148
|
it 'should make a literal for Date types' do
|
105
149
|
ref = Date::civil(2010, 1, 2)
|
106
|
-
Triple.
|
150
|
+
Triple.coerce_node(ref).should == Literal.build_from(ref)
|
107
151
|
end
|
108
152
|
|
109
153
|
it 'should make a literal for DateTime types' do
|
110
154
|
ref = DateTime.parse('2010-01-03T01:02:03')
|
111
|
-
Triple.
|
155
|
+
Triple.coerce_node(ref).should == Literal.build_from(ref)
|
112
156
|
end
|
113
157
|
|
114
158
|
it "should leave URIRefs alone" do
|
115
159
|
ref = URIRef.new("http://localhost/")
|
116
|
-
Triple.
|
160
|
+
Triple.coerce_node(ref).should == ref
|
117
161
|
end
|
118
162
|
|
119
163
|
it "should accept an Addressable::URI object and make URIRef" do
|
120
|
-
Triple.
|
164
|
+
Triple.coerce_node(Addressable::URI.parse("http://localhost/")).should == URIRef.new("http://localhost/")
|
121
165
|
end
|
122
166
|
|
123
167
|
it "should leave BNodes alone" do
|
124
168
|
ref = BNode.new()
|
125
|
-
Triple.
|
169
|
+
Triple.coerce_node(ref).should == ref
|
126
170
|
end
|
127
171
|
|
128
172
|
it "should leave Literals alone" do
|
129
173
|
ref = Literal.untyped('foo')
|
130
|
-
Triple.
|
174
|
+
Triple.coerce_node(ref).should == ref
|
131
175
|
|
132
176
|
typedref = Literal.build_from('foo')
|
133
|
-
Triple.
|
177
|
+
Triple.coerce_node(ref).should == ref
|
134
178
|
end
|
135
179
|
|
136
180
|
end
|
@@ -138,7 +182,7 @@ describe "Triples" do
|
|
138
182
|
describe "with wildcards" do
|
139
183
|
it "should accept nil" do
|
140
184
|
t = Triple.new(nil, nil, nil)
|
141
|
-
t.
|
185
|
+
t.is_pattern?.should be_true
|
142
186
|
end
|
143
187
|
end
|
144
188
|
|
@@ -168,7 +212,7 @@ describe "Triples" do
|
|
168
212
|
end
|
169
213
|
end
|
170
214
|
|
171
|
-
it "should be equal to
|
215
|
+
it "should be equal to patterns" do
|
172
216
|
@test_cases.each do |triple|
|
173
217
|
[
|
174
218
|
Triple.new(triple.subject, triple.predicate, triple.object),
|
@@ -0,0 +1,20 @@
|
|
1
|
+
These are the tests for the Turtle Terse RDF Triple Language
|
2
|
+
that must be passed by conformant systems. See
|
3
|
+
http://www.dajobe.org/2004/01/turtle/
|
4
|
+
for the full conformance information.
|
5
|
+
|
6
|
+
The format is a set of good tests and bad tests.
|
7
|
+
|
8
|
+
Good tests are a pair of files:
|
9
|
+
abc.ttl abc.out
|
10
|
+
which are the input Turtle file and the expected output RDF triples,
|
11
|
+
written in N-Triples.
|
12
|
+
|
13
|
+
bad tests are of the form
|
14
|
+
bad-XX.ttl
|
15
|
+
which must fail.
|
16
|
+
|
17
|
+
The tests should be performed with an assumed base URI
|
18
|
+
of http://www.w3.org/2001/sw/DataAccess/df1/tests/
|
19
|
+
|
20
|
+
Dave
|
@@ -0,0 +1,88 @@
|
|
1
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
2
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
3
|
+
@prefix mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> .
|
4
|
+
@prefix qt: <http://www.w3.org/2001/sw/DataAccess/tests/test-query#> .
|
5
|
+
|
6
|
+
<> rdf:type mf:Manifest ;
|
7
|
+
rdfs:comment "Turtle bad syntax test cases (must fail)" ;
|
8
|
+
mf:entries
|
9
|
+
(
|
10
|
+
|
11
|
+
[ mf:name "bad-00" ;
|
12
|
+
rdfs:comment "prefix name must end in a :" ;
|
13
|
+
mf:action [ qt:data <bad-00.ttl> ] ;
|
14
|
+
]
|
15
|
+
|
16
|
+
[ mf:name "bad-01" ;
|
17
|
+
rdfs:comment "blank predicate forbidden" ;
|
18
|
+
mf:action [ qt:data <bad-01.ttl> ] ;
|
19
|
+
]
|
20
|
+
|
21
|
+
[ mf:name "bad-02" ;
|
22
|
+
rdfs:comment "blank predicate forbidden" ;
|
23
|
+
mf:action [ qt:data <bad-02.ttl> ] ;
|
24
|
+
]
|
25
|
+
|
26
|
+
[ mf:name "bad-03" ;
|
27
|
+
rdfs:comment "a forbidden as subject" ;
|
28
|
+
mf:action [ qt:data <bad-03.ttl> ] ;
|
29
|
+
]
|
30
|
+
|
31
|
+
[ mf:name "bad-04" ;
|
32
|
+
rdfs:comment ", not allowed in collections" ;
|
33
|
+
mf:action [ qt:data <bad-04.ttl> ] ;
|
34
|
+
]
|
35
|
+
|
36
|
+
[ mf:name "bad-05" ;
|
37
|
+
rdfs:comment "{} not allowed in Turtle" ;
|
38
|
+
mf:action [ qt:data <bad-05.ttl> ] ;
|
39
|
+
]
|
40
|
+
|
41
|
+
[ mf:name "bad-06" ;
|
42
|
+
rdfs:comment "is and of not allowed in Turtle" ;
|
43
|
+
mf:action [ qt:data <bad-06.ttl> ] ;
|
44
|
+
]
|
45
|
+
|
46
|
+
[ mf:name "bad-07" ;
|
47
|
+
rdfs:comment "paths not allowed in Turtle" ;
|
48
|
+
mf:action [ qt:data <bad-07.ttl> ] ;
|
49
|
+
]
|
50
|
+
|
51
|
+
[ mf:name "bad-08" ;
|
52
|
+
rdfs:comment "@keywords not allowed in Turtle" ;
|
53
|
+
mf:action [ qt:data <bad-08.ttl> ] ;
|
54
|
+
]
|
55
|
+
|
56
|
+
[ mf:name "bad-09" ;
|
57
|
+
rdfs:comment "=> not allowed in Turtle" ;
|
58
|
+
mf:action [ qt:data <bad-09.ttl> ] ;
|
59
|
+
]
|
60
|
+
|
61
|
+
[ mf:name "bad-10" ;
|
62
|
+
rdfs:comment "= not allowed in Turtle" ;
|
63
|
+
mf:action [ qt:data <bad-10.ttl> ] ;
|
64
|
+
]
|
65
|
+
|
66
|
+
[ mf:name "bad-11" ;
|
67
|
+
rdfs:comment "@forAll not allowed in Turtle" ;
|
68
|
+
mf:action [ qt:data <bad-11.ttl> ] ;
|
69
|
+
]
|
70
|
+
|
71
|
+
[ mf:name "bad-12" ;
|
72
|
+
rdfs:comment "@forSome not allowed in Turtle" ;
|
73
|
+
mf:action [ qt:data <bad-12.ttl> ] ;
|
74
|
+
]
|
75
|
+
|
76
|
+
[ mf:name "bad-13" ;
|
77
|
+
rdfs:comment "<= not allowed in Turtle" ;
|
78
|
+
mf:action [ qt:data <bad-13.ttl> ] ;
|
79
|
+
]
|
80
|
+
|
81
|
+
[ mf:name "bad-14" ;
|
82
|
+
rdfs:comment "long literal with missing end" ;
|
83
|
+
mf:action [ qt:data <bad-14.ttl> ] ;
|
84
|
+
]
|
85
|
+
|
86
|
+
|
87
|
+
# End of tests
|
88
|
+
).
|