Skip to content

Add tests to check for keyword redefinition allowing @protected. #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1365,8 +1365,10 @@ <h3>Algorithm</h3>
<li class="changed">If <a>processing mode</a>
is <code>json-ld-1.1</code>
and <var>term</var> is <code>@type</code>, <var>value</var>
MUST be a <a>map</a> with the entry <code>@container</code>
and value <code>@set</code>. Any other value means that a
MUST be a <a>map</a> with only the entry <code>@container</code>
and value <code>@set</code>
and optional entry `@protected`.
Any other value means that a
<a data-link-for="JsonLdErrorCode">keyword redefinition</a> error has
been detected and processing is aborted.</li>
<li><span class="changed">Otherwise</span>, since <a>keywords</a> cannot be overridden,
Expand Down
84 changes: 84 additions & 0 deletions tests/expand-manifest.html
Original file line number Diff line number Diff line change
Expand Up @@ -8128,6 +8128,90 @@ <h2>
</dd>
</dl>
</dd>
<dt id='tpr30'>
Test tpr30 Keywords may be protected.
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tpr30</dd>
<dt>Type</dt>
<dd>jld:PositiveEvaluationTest, jld:ExpandTest</dd>
<dt>Purpose</dt>
<dd>Keywords may not be redefined other than to protect them.</dd>
<dt>input</dt>
<dd>
<a href='expand/pr30-in.jsonld'>expand/pr30-in.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
<a href='expand/pr30-out.jsonld'>expand/pr30-out.jsonld</a>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tpr31'>
Test tpr31 Protected keyword aliases cannot be overridden.
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tpr31</dd>
<dt>Type</dt>
<dd>jld:NegativeEvaluationTest, jld:ExpandTest</dd>
<dt>Purpose</dt>
<dd>Keywords may not be redefined other than to protect them.</dd>
<dt>input</dt>
<dd>
<a href='expand/pr31-in.jsonld'>expand/pr31-in.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
protected term redefinition
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tpr32'>
Test tpr32 Protected @type cannot be overridden.
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tpr32</dd>
<dt>Type</dt>
<dd>jld:NegativeEvaluationTest, jld:ExpandTest</dd>
<dt>Purpose</dt>
<dd>Keywords may not be redefined other than to protect them.</dd>
<dt>input</dt>
<dd>
<a href='expand/pr32-in.jsonld'>expand/pr32-in.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
protected term redefinition
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tpr33'>
Test tpr33 Fails if trying to declare a keyword alias as prefix.
</dt>
Expand Down
24 changes: 24 additions & 0 deletions tests/expand-manifest.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -2368,6 +2368,30 @@
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr29-in.jsonld",
"expect": "expand/pr29-out.jsonld"
}, {
"@id": "#tpr30",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Keywords may be protected.",
"purpose": "Keywords may not be redefined other than to protect them.",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr30-in.jsonld",
"expect": "expand/pr30-out.jsonld"
}, {
"@id": "#tpr31",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
"name": "Protected keyword aliases cannot be overridden.",
"purpose": "Keywords may not be redefined other than to protect them.",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr31-in.jsonld",
"expect": "protected term redefinition"
}, {
"@id": "#tpr32",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
"name": "Protected @type cannot be overridden.",
"purpose": "Keywords may not be redefined other than to protect them.",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr32-in.jsonld",
"expect": "protected term redefinition"
}, {
"@id": "#tpr33",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
Expand Down
11 changes: 11 additions & 0 deletions tests/expand/pr30-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"@context": {
"@version": 1.1,
"id": {"@id": "@id", "@protected": true},
"type": {"@id" : "@type", "@container": "@set", "@protected" : true},
"@type": {"@container": "@set", "@protected": true}
},
"id": "http://example.com/1",
"type": "http://example.org/ns/Foo",
"@type": "http://example.org/ns/Bar"
}
9 changes: 9 additions & 0 deletions tests/expand/pr30-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
{
"@id": "http://example.com/1",
"@type": [
"http://example.org/ns/Bar",
"http://example.org/ns/Foo"
]
}
]
13 changes: 13 additions & 0 deletions tests/expand/pr31-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"@context": [{
"@version": 1.1,
"id": {"@id": "@id", "@protected": true},
"type": {"@id" : "@type", "@container": "@set", "@protected" : true},
"@type": {"@container": "@set", "@protected": true}
}, {
"@version": 1.1,
"id": "http://example.com/id"
}],
"id": "http://example.com/1",
"type": ["http://example.org/ns/Foo"]
}
13 changes: 13 additions & 0 deletions tests/expand/pr32-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"@context": [{
"@version": 1.1,
"id": {"@id": "@id", "@protected": true},
"type": {"@id" : "@type", "@container": "@set", "@protected" : true},
"@type": {"@container": "@set", "@protected": true}
}, {
"@version": 1.1,
"@type": {"@protected": true}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it considered as an attempt to override @type?
Is it because it implies the opposite of "@container": "@set"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes,
Because it would change the container association with @type. But, this might not be important, because it wouldn’t change the interpretation when expanding, but could create an alternate representation when compacting.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to @gkellogg -- and better not to have subtle surprises like that.

}],
"id": "http://example.com/1",
"type": ["http://example.org/ns/Foo"]
}
84 changes: 84 additions & 0 deletions tests/toRdf-manifest.html
Original file line number Diff line number Diff line change
Expand Up @@ -7066,6 +7066,90 @@ <h2>
</dd>
</dl>
</dd>
<dt id='tpr30'>
Test tpr30 Keywords may be protected.
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tpr30</dd>
<dt>Type</dt>
<dd>jld:PositiveEvaluationTest, jld:ToRDFTest</dd>
<dt>Purpose</dt>
<dd>Keywords may not be redefined other than to protect them.</dd>
<dt>input</dt>
<dd>
<a href='toRdf/pr30-in.jsonld'>toRdf/pr30-in.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
<a href='toRdf/pr30-out.nq'>toRdf/pr30-out.nq</a>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tpr31'>
Test tpr31 Protected keyword aliases cannot be overridden.
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tpr31</dd>
<dt>Type</dt>
<dd>jld:NegativeEvaluationTest, jld:ToRDFTest</dd>
<dt>Purpose</dt>
<dd>Keywords may not be redefined other than to protect them.</dd>
<dt>input</dt>
<dd>
<a href='toRdf/pr31-in.jsonld'>toRdf/pr31-in.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
term redefinition
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tpr32'>
Test tpr32 Protected @type cannot be overridden.
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#tpr32</dd>
<dt>Type</dt>
<dd>jld:NegativeEvaluationTest, jld:ToRDFTest</dd>
<dt>Purpose</dt>
<dd>Keywords may not be redefined other than to protect them.</dd>
<dt>input</dt>
<dd>
<a href='toRdf/pr32-in.jsonld'>toRdf/pr32-in.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
protected term redefinition
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tpr33'>
Test tpr33 Fails if trying to declare a keyword alias as prefix.
</dt>
Expand Down
24 changes: 24 additions & 0 deletions tests/toRdf-manifest.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -2110,6 +2110,30 @@
"option": {"specVersion": "json-ld-1.1"},
"input": "toRdf/pr29-in.jsonld",
"expect": "toRdf/pr29-out.nq"
}, {
"@id": "#tpr30",
"@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"],
"name": "Keywords may be protected.",
"purpose": "Keywords may not be redefined other than to protect them.",
"option": {"specVersion": "json-ld-1.1"},
"input": "toRdf/pr30-in.jsonld",
"expect": "toRdf/pr30-out.nq"
}, {
"@id": "#tpr31",
"@type": ["jld:NegativeEvaluationTest", "jld:ToRDFTest"],
"name": "Protected keyword aliases cannot be overridden.",
"purpose": "Keywords may not be redefined other than to protect them.",
"option": {"specVersion": "json-ld-1.1"},
"input": "toRdf/pr31-in.jsonld",
"expect": "term redefinition"
}, {
"@id": "#tpr32",
"@type": ["jld:NegativeEvaluationTest", "jld:ToRDFTest"],
"name": "Protected @type cannot be overridden.",
"purpose": "Keywords may not be redefined other than to protect them.",
"option": {"specVersion": "json-ld-1.1"},
"input": "toRdf/pr32-in.jsonld",
"expect": "protected term redefinition"
}, {
"@id": "#tpr33",
"@type": ["jld:NegativeEvaluationTest", "jld:ToRDFTest"],
Expand Down
11 changes: 11 additions & 0 deletions tests/toRdf/pr30-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"@context": {
"@version": 1.1,
"id": {"@id": "@id", "@protected": true},
"type": {"@id" : "@type", "@container": "@set", "@protected" : true},
"@type": {"@container": "@set", "@protected": true}
},
"id": "http://example.com/1",
"type": "http://example.org/ns/Foo",
"@type": "http://example.org/ns/Bar"
}
2 changes: 2 additions & 0 deletions tests/toRdf/pr30-out.nq
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<http://example.com/1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/ns/Bar> .
<http://example.com/1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/ns/Foo> .
13 changes: 13 additions & 0 deletions tests/toRdf/pr31-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"@context": [{
"@version": 1.1,
"id": {"@id": "@id", "@protected": true},
"type": {"@id" : "@type", "@container": "@set", "@protected" : true},
"@type": {"@container": "@set", "@protected": true}
}, {
"@version": 1.1,
"id": "http://example.com/id"
}],
"id": "http://example.com/1",
"type": ["http://example.org/ns/Foo"]
}
13 changes: 13 additions & 0 deletions tests/toRdf/pr32-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"@context": [{
"@version": 1.1,
"id": {"@id": "@id", "@protected": true},
"type": {"@id" : "@type", "@container": "@set", "@protected" : true},
"@type": {"@container": "@set", "@protected": true}
}, {
"@version": 1.1,
"@type": {"@protected": true}
}],
"id": "http://example.com/1",
"type": ["http://example.org/ns/Foo"]
}