Skip to content

Commit 1d56389

Browse files
committed
Tests for id maps and type maps.
Mark error-0021 as being json-ld.1.0 only.
1 parent b9a714b commit 1d56389

29 files changed

+256
-7
lines changed

test-suite/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Tests are defined into _compact_, _expand_, _flatten_, _frame_, _normalize_, and
2323
contained within the _sparql_ document using a SPARQL endpoint. The end result is a
2424
yes/no on whether the expected triples were extracted by the JSON-LD processor.
2525

26+
Unless `processingMode` is set explicitly in a test entry, `processingMode` is compatible with both `json-ld-1.0` and `json-ld-1.1`. Otherwise, a JSON-LD 1.0 processor should not run tests marked `json-ld-1.1` and a JSON-LD 1.1 processor should not run tests marked `json-ld-1.0`.
2627

2728
Contributing
2829
------------

test-suite/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ <h2 id="design" class="span12" style="text-align: center;">Running the test suit
166166
<p>To run the tests, create a test runner which will run through each test manifest
167167
and execute the tests defined within the manifest using the rules associated with
168168
each <code>@type</code> defined for the test case as defined in <a href="vocab">the test vocabulary</a>.</p>
169+
<p>Unless <code>processingMode</code> is set explicitly in a test entry,
170+
<code>processingMode</code> is compatible with both <code>json-ld-1.0</code> and
171+
<code>json-ld-1.1</code>. Otherwise, a JSON-LD 1.0 processor should not run
172+
tests marked <code>json-ld-1.1</code> and a JSON-LD 1.1 processor should not run
173+
tests marked <code>json-ld-1.0</code>. </p>
169174
<p>Note that property values are typed, and those which are typed as <code>@id</code> must
170175
be treated as IRIs relative to the manifest test base. In particular, this means that
171176
<em>input</em>, </em>context</em>, <em>frame</em>, and <em>expandContext</em> are to be
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"idmap": {"@container": "@id"}
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[{
2+
"http://example/idmap": [
3+
{"http://example/label": [{"@value": "Object with @id _:bar"}], "@id": "_:bar"},
4+
{"http://example/label": [{"@value": "Object with @id <foo>"}], "@id": "http://example.org/foo"}
5+
]
6+
}]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"idmap": {"@container": "@id"}
5+
},
6+
"idmap": {
7+
"http://example.org/foo": {"label": "Object with @id <foo>"},
8+
"_:bar": {"label": "Object with @id _:bar"}
9+
}
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"idmap": {"@container": "@id"}
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[{
2+
"http://example/idmap": [
3+
{"@id": "_:foo", "http://example/label": [{"@value": "Object with @id _:bar"}]},
4+
{"@id": "http://example.org/bar", "http://example/label": [{"@value": "Object with @id <foo>"}]}
5+
]
6+
}]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"idmap": {"@container": "@id"}
5+
},
6+
"idmap": {
7+
"_:foo": {"label": "Object with @id _:bar"},
8+
"http://example.org/bar": {"label": "Object with @id <foo>"}
9+
}
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"typemap": {"@container": "@type"}
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[{
2+
"http://example/typemap": [
3+
{"http://example/label": [{"@value": "Object with @type _:bar"}], "@type": ["_:bar"]},
4+
{"http://example/label": [{"@value": "Object with @type <foo>"}], "@type": ["http://example.org/foo"]}
5+
]
6+
}]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"typemap": {"@container": "@type"}
5+
},
6+
"typemap": {
7+
"http://example.org/foo": {"label": "Object with @type <foo>"},
8+
"_:bar": {"label": "Object with @type _:bar"}
9+
}
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"typemap": {"@container": "@type"}
5+
}
6+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[{
2+
"http://example/typemap": [
3+
{
4+
"@type": ["_:bar", "_:foo"],
5+
"http://example/label": [{"@value": "Object with @type _:bar"}]
6+
},
7+
{
8+
"@type": ["http://example.org/foo", "http://example.org/bar"],
9+
"http://example/label": [{"@value": "Object with @type <foo>"}]
10+
}
11+
]
12+
}]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"typemap": {"@container": "@type"}
5+
},
6+
"typemap": {
7+
"http://example.org/foo": {"@type": "http://example.org/bar", "label": "Object with @type <foo>"},
8+
"_:bar": {"@type": "_:foo", "label": "Object with @type _:bar"}
9+
}
10+
}

test-suite/tests/compact-manifest.jsonld

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,38 @@
625625
"input": "compact-c005-in.jsonld",
626626
"context": "compact-c005-context.jsonld",
627627
"expect": "compact-c005-out.jsonld"
628+
}, {
629+
"@id": "#tm001",
630+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
631+
"name": "Indexes to object not having an @id",
632+
"purpose": "Compaction using @container: @id",
633+
"input": "compact-m001-in.jsonld",
634+
"context": "compact-m001-context.jsonld",
635+
"expect": "compact-m001-out.jsonld"
636+
}, {
637+
"@id": "#tm002",
638+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
639+
"name": "Indexes to object already having an @id",
640+
"purpose": "Compaction using @container: @id",
641+
"input": "compact-m002-in.jsonld",
642+
"context": "compact-m002-context.jsonld",
643+
"expect": "compact-m002-out.jsonld"
644+
}, {
645+
"@id": "#tm003",
646+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
647+
"name": "Indexes to object not having an @type",
648+
"purpose": "Compaction using @container: @type",
649+
"input": "compact-m003-in.jsonld",
650+
"context": "compact-m003-context.jsonld",
651+
"expect": "compact-m003-out.jsonld"
652+
}, {
653+
"@id": "#tm004",
654+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
655+
"name": "Indexes to object already having an @type",
656+
"purpose": "Compaction using @container: @type",
657+
"input": "compact-m004-in.jsonld",
658+
"context": "compact-m004-context.jsonld",
659+
"expect": "compact-m004-out.jsonld"
628660
}
629661
]
630662
}

test-suite/tests/error-m021-in.jsonld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"term": {"@id": "http://example/term", "@container": "@context"}
4+
},
5+
"@id": "http://example/test#example"
6+
}

test-suite/tests/error-manifest.jsonld

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@
152152
"name": "Invalid container mapping",
153153
"purpose": "Verifies that an exception is raised on expansion when a invalid container mapping is found",
154154
"input": "error-0021-in.jsonld",
155-
"expect": "invalid container mapping"
155+
"expect": "invalid container mapping",
156+
"option": {
157+
"processingMode": "json-ld-1.0"
158+
}
156159
}, {
157160
"@id": "#t0022",
158161
"@type": [ "jld:NegativeEvaluationTest", "jld:FlattenTest" ],
@@ -309,12 +312,22 @@
309312
"input": "error-0043-in.jsonld",
310313
"expect": "conflicting indexes"
311314
}, {
312-
"@id": "#t1001",
315+
"@id": "#tc001",
313316
"@type": [ "jld:NegativeEvaluationTest", "jld:FlattenTest" ],
314317
"name": "Invalid keyword in term definition",
315318
"purpose": "Verifies that an exception is raised on expansion when a invalid term definition is found",
316319
"input": "error-c001-in.jsonld",
317320
"expect": "invalid term definition"
321+
}, {
322+
"@id": "#tm021",
323+
"@type": [ "jld:NegativeEvaluationTest", "jld:FlattenTest" ],
324+
"name": "Invalid container mapping",
325+
"purpose": "Verifies that an exception is raised on expansion when a invalid container mapping is found",
326+
"input": "error-m021-in.jsonld",
327+
"expect": "invalid container mapping",
328+
"option": {
329+
"processingMode": "json-ld-1.1"
330+
}
318331
}
319332
]
320333
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"idmap": {"@container": "@id"}
5+
},
6+
"idmap": {
7+
"http://example.org/foo": {"label": "Object with @id <foo>"},
8+
"_:bar": {"label": "Object with @id _:bar"}
9+
}
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[{
2+
"http://example/idmap": [
3+
{"http://example/label": [{"@value": "Object with @id _:bar"}], "@id": "_:bar"},
4+
{"http://example/label": [{"@value": "Object with @id <foo>"}], "@id": "http://example.org/foo"}
5+
]
6+
}]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"idmap": {"@container": "@id"}
5+
},
6+
"idmap": {
7+
"http://example.org/foo": {"@id": "http://example.org/bar", "label": "Object with @id <foo>"},
8+
"_:bar": {"@id": "_:foo", "label": "Object with @id _:bar"}
9+
}
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[{
2+
"http://example/idmap": [
3+
{"@id": "_:foo", "http://example/label": [{"@value": "Object with @id _:bar"}]},
4+
{"@id": "http://example.org/bar", "http://example/label": [{"@value": "Object with @id <foo>"}]}
5+
]
6+
}]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"typemap": {"@container": "@type"}
5+
},
6+
"typemap": {
7+
"http://example.org/foo": {"label": "Object with @type <foo>"},
8+
"_:bar": {"label": "Object with @type _:bar"}
9+
}
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[{
2+
"http://example/typemap": [
3+
{"http://example/label": [{"@value": "Object with @type _:bar"}], "@type": ["_:bar"]},
4+
{"http://example/label": [{"@value": "Object with @type <foo>"}], "@type": ["http://example.org/foo"]}
5+
]
6+
}]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"typemap": {"@container": "@type"}
5+
},
6+
"typemap": {
7+
"http://example.org/foo": {"@type": "http://example.org/bar", "label": "Object with @type <foo>"},
8+
"_:bar": {"@type": "_:foo", "label": "Object with @type _:bar"}
9+
}
10+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[{
2+
"http://example/typemap": [
3+
{
4+
"@type": ["_:bar", "_:foo"],
5+
"http://example/label": [{"@value": "Object with @type _:bar"}]
6+
},
7+
{
8+
"@type": ["http://example.org/foo", "http://example.org/bar"],
9+
"http://example/label": [{"@value": "Object with @type <foo>"}]
10+
}
11+
]
12+
}]

test-suite/tests/expand-manifest.jsonld

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,34 @@
593593
"purpose": "Expansion using a scoped context uses term scope for selecting proper term",
594594
"input": "expand-c005-in.jsonld",
595595
"expect": "expand-c005-out.jsonld"
596+
}, {
597+
"@id": "#tm001",
598+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
599+
"name": "Adds @id to object not having an @id",
600+
"purpose": "Expansion using @container: @id",
601+
"input": "expand-m001-in.jsonld",
602+
"expect": "expand-m001-out.jsonld"
603+
}, {
604+
"@id": "#tm002",
605+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
606+
"name": "Retains @id in object already having an @id",
607+
"purpose": "Expansion using @container: @id",
608+
"input": "expand-m002-in.jsonld",
609+
"expect": "expand-m002-out.jsonld"
610+
}, {
611+
"@id": "#tm003",
612+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
613+
"name": "Adds @type to object not having an @type",
614+
"purpose": "Expansion using @container: @type",
615+
"input": "expand-m003-in.jsonld",
616+
"expect": "expand-m003-out.jsonld"
617+
}, {
618+
"@id": "#tm004",
619+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
620+
"name": "Prepends @type in object already having an @type",
621+
"purpose": "Expansion using @container: @type",
622+
"input": "expand-m004-in.jsonld",
623+
"expect": "expand-m004-out.jsonld"
596624
}
597625
]
598626
}

test-suite/vocab.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ <h2 class='span12' id='classes' style='text-align: center;'>
143143
<dd about='jld:NegativeSyntaxTest' property='rdfs:comment'><p>A type of test specifically for syntax testing. Syntax tests are not required to have an associated result, only an action. Negative syntax tests are tests of which the result should be a parser error.</p></dd>
144144
<dt about='jld:NormalizeTest' property='rdfs:label' typeof='rdfs:Class'>Normalization Evaluation Test</dt>
145145
<dd about='jld:NormalizeTest' property='rdfs:comment'><p>A <code>NormalizeTest</code> modifies either a <code>PositiveEvaluationTest</code>, <code>NegativeEvaluationTest</code>, <code>PositiveSyntaxTest</code> or <code>NegativeSyntaxTest</code>. Tests are run using the <a href="http://json-ld.org/spec/latest/rdf-graph-normalization/#normalization-algorithm">Normalization</a> algorithmwith the input argument from <code>mf:action</code> (aliased as &quot;input&quot; in test manifest) referencing an JSON-LD file and optional options from <code>:option</code>. The expected results for a PositiveEvaluationTest are N-Quads serialized in lexographical order and MUST be compared using string comparison.</p></dd>
146-
<dt about='jld:NegativeEvaluationTest' property='rdfs:label' typeof='rdfs:Class'>Positive Evaluation Test</dt>
147-
<dd about='jld:NegativeEvaluationTest' property='rdfs:comment'><p>A Negative Evaluation test is successful when the result of processing the input file specified as <code>mf:action</code> (aliased as &quot;input&quot; in test manifest) results in the error identified by the literal value of <code>mf:result</code> (aliased as &quot;expect&quot; in test manifest). The specifics of invoking test, including the interpretation of options (<code>:option</code>) and other input files are specified through another class.</p></dd>
148146
<dt about='jld:PositiveEvaluationTest' property='rdfs:label' typeof='rdfs:Class'>Positive Evaluation Test</dt>
149147
<dd about='jld:PositiveEvaluationTest' property='rdfs:comment'><p>A Positive Evaluation test is successful when the result of processing the input file specified as <code>mf:action</code> (aliased as &quot;input&quot; in test manifest) exactly matches the output file specified as <code>mf:result</code> (aliased as &quot;expect&quot; in test manifest) using the comparison defined in another class. The specifics of invoking test, including the interpretation of options (<code>:option</code>) and other input files are specified through another class.</p></dd>
148+
<dt about='jld:NegativeEvaluationTest' property='rdfs:label' typeof='rdfs:Class'>Positive Evaluation Test</dt>
149+
<dd about='jld:NegativeEvaluationTest' property='rdfs:comment'><p>A Negative Evaluation test is successful when the result of processing the input file specified as <code>mf:action</code> (aliased as &quot;input&quot; in test manifest) results in the error identified by the literal value of <code>mf:result</code> (aliased as &quot;expect&quot; in test manifest). The specifics of invoking test, including the interpretation of options (<code>:option</code>) and other input files are specified through another class.</p></dd>
150150
<dt about='jld:PositiveSyntaxTest' property='rdfs:label' typeof='rdfs:Class'>Positive Syntax Test</dt>
151151
<dd about='jld:PositiveSyntaxTest' property='rdfs:comment'><p>A type of test specifically for syntax testing. Syntax tests are not required to have an associated result, only an action.</p></dd>
152152
<dt about='jld:Option' property='rdfs:label' typeof='rdfs:Class'>Processor Options</dt>
@@ -301,7 +301,7 @@ <h2 class='span12' id='classes' style='text-align: center;'>
301301
<strong>
302302
domain:
303303
</strong>
304-
<code property='rdfs:domain' resource='jld:Test'>jld:Test</code>
304+
<code property='rdfs:domain' resource='jld:Option'>jld:Option</code>
305305
</div>
306306
<div>
307307
<strong>

test-suite/vocab.jsonld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
"@id": "jld:processingMode",
184184
"@type": "rdf:Property",
185185
"rdfs:comment": "If set to \"json-ld-1.1\", the JSON-LD processor must produce exactly the same results as the algorithms defined in this specification. If set to another value, the JSON-LD processor is allowed to extend or modify the algorithms defined in this specification to enable application-specific optimizations. The definition of such optimizations is beyond the scope of this specification and thus not defined. Consequently, different implementations may implement different optimizations. Developers must not define modes beginning with json-ld as they are reserved for future versions of this specification.",
186-
"rdfs:domain": "jld:Test",
186+
"rdfs:domain": "jld:Option",
187187
"rdfs:label": "processing mode",
188188
"rdfs:range": "xsd:string"
189189
},

test-suite/vocab.ttl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@
224224
Consequently, different implementations may implement different optimizations.
225225
Developers must not define modes beginning with json-ld as they are reserved for future versions of this specification.
226226
""" ;
227-
rdfs:domain :Test ;
227+
rdfs:domain :Option ;
228228
rdfs:range xsd:string .
229229

230230
:produceGeneralizedRdf a rdf:Property ;

0 commit comments

Comments
 (0)