Skip to content

Add protected term redefinition tests. #92

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 3 commits into from
Jun 13, 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
37 changes: 22 additions & 15 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1307,19 +1307,11 @@ <h3>Algorithm</h3>
error has been detected and processing is aborted.</li>
<li class="changed">Set <var>previous definition</var> to any existing
<a>term definition</a> for <var>term</var> in <var>active context</var>.</li>
<li class="changed">If <var>from property</var> is <code>false</code>
and <var>previous definition</var> exists and is protected,
a <a data-link-for="JsonLdErrorCode">protected term redefinition</a> error has been detected,
and processing is aborted.</li>
<li>Otherwise, remove any <var>previous definition</var> from
<var>active context</var>.</li>
<li>If <var>value</var> is <code>null</code> or <var>value</var>
is a <a class="changed">dictionary</a> containing the key-value pair
<code>@id</code>-<code>null</code>, set the
<a>term definition</a> in <var>active context</var> to
<code>null</code>,
and set the value associated with <var>defined</var>'s
<a>member</a> <var>term</var> to <code>true</code>, and return.</li>
<li class="changed">If <var>value</var> is <code>null</code>,
convert it to a <a class="changed">dictionary</a> consisting of a single <a>member</a> whose
key is <code>@id</code> and whose value is <code>null</code>.</li>
<li>Otherwise, if <var>value</var> is a <a>string</a>, convert it
to a <a class="changed">dictionary</a> consisting of a single <a>member</a> whose
key is <code>@id</code> and whose value is <var>value</var>.
Expand Down Expand Up @@ -1391,7 +1383,10 @@ <h3>Algorithm</h3>
<li>If <var>value</var> contains the <a>member</a> <code>@id</code> and its value
does not equal <var>term</var>:
<ol>
<li>If the value associated with the <code>@id</code> <a>member</a> is not a <a>string</a>, an
<li>If <var>value</var> contains the <code>@id</code> <a>member</a>
is <code>null</code>, the term is not used for IRI expansion, but is
retained to be able to detect future redefinitions of this term.</li>
<li>Otherwise, if the value associated with the <code>@id</code> <a>member</a> is not a <a>string</a>, an
<a data-link-for="JsonLdErrorCode">invalid IRI mapping</a>
error has been detected and processing is aborted.</li>
<li>Otherwise, set the <a>IRI mapping</a> of <var>definition</var> to the
Expand Down Expand Up @@ -1555,6 +1550,17 @@ <h3>Algorithm</h3>
<code class="changed">@prefix</code>, or <code>@type</code>, an
<a data-link-for="JsonLdErrorCode">invalid term definition</a> error has
been detected and processing is aborted.</li>
<li class="changed">If <var>from property</var> is <code>false</code>
and <var>previous definition</var> exists and is protected;
<ol>
<li>If <var>definition</var> is not the same as <var>previous definition</var>
(other than the value of <a>protected</a>),
a <a data-link-for="JsonLdErrorCode">protected term redefinition</a> error has been detected,
and processing is aborted.</li>
<li>Set <var>definition</var> to <var>previous definition</var> to retain the value
of <a>protected</a>.</li>
</ol>
</li>
<li>Set the <a>term definition</a> of <var>term</var> in
<var>active context</var> to <var>definition</var> and set the value
associated with <var>defined</var>'s <a>member</a> <var>term</var> to
Expand Down Expand Up @@ -1663,9 +1669,10 @@ <h3>Algorithm</h3>
in <var>active context</var> during
<a href="#context-processing-algorithm">Context Processing</a>.</li>
<li>If <var>active context</var> contains a <a>term definition</a>
for <var>prefix</var>, return the result of concatenating
the <a>IRI mapping</a> associated with <var>prefix</var> and
<var>suffix</var>.</li>
for <var>prefix</var>
<span class="changed">having a non-<code>null</code> <a>IRI mapping</a></span>,
return the result of concatenating the <a>IRI mapping</a>
associated with <var>prefix</var> and <var>suffix</var>.</li>
<li><span class="changed">If <var>value</var> has the form of an <a>absolute IRI</a></span>,
return <var>value</var>.</li>
</ol>
Expand Down
48 changes: 48 additions & 0 deletions tests/expand-manifest.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -2298,6 +2298,54 @@
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr22-in.jsonld",
"expect": "expand/pr22-out.jsonld"
}, {
"@id": "#tpr23",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Allows redefinition of protected alias term with same definition.",
"purpose": "Allows redefinition of protected alias term with same definition.",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr23-in.jsonld",
"expect": "expand/pr23-out.jsonld"
}, {
"@id": "#tpr24",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Allows redefinition of protected prefix term with same definition.",
"purpose": "Allows redefinition of protected prefix term with same definition.",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr24-in.jsonld",
"expect": "expand/pr24-out.jsonld"
}, {
"@id": "#tpr25",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Allows redefinition of terms with scoped contexts using same definitions.",
"purpose": "Allows redefinition of terms with scoped contexts using same definitions.",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr25-in.jsonld",
"expect": "expand/pr25-out.jsonld"
}, {
"@id": "#tpr26",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
"name": "Fails on redefinition of terms with scoped contexts using different definitions.",
"purpose": "Fails on redefinition of terms with scoped contexts using different definitions.",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr26-in.jsonld",
"expect": "protected term redefinition"
}, {
"@id": "#tpr27",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
"name": "Allows redefinition of protected alias term with same definition modulo protected flag.",
"purpose": "Allows redefinition of protected alias term with same definition modulo protected flag.",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr27-in.jsonld",
"expect": "expand/pr27-out.jsonld"
}, {
"@id": "#tpr28",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
"name": "Fails if trying to redefine a protected null term.",
"purpose": "A protected term with a null IRI mapping cannot be redefined.",
"option": {"specVersion": "json-ld-1.1"},
"input": "expand/pr28-in.jsonld",
"expect": "protected term redefinition"
}, {
"@id": "#ttn01",
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
Expand Down
15 changes: 15 additions & 0 deletions tests/expand/pr23-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"@context": [{
"@version": 1.1,
"@protected": true,
"id": "@id",
"type": "@type"
}, {
"@version": 1.1,
"@protected": true,
"id": "@id",
"type": "@type"
}],
"id": "http://example/id",
"type": "http://example/type"
}
9 changes: 9 additions & 0 deletions tests/expand/pr23-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
{
"@id": "http://example/id",
"@type": [
"http://example/type"
]
}
]

12 changes: 12 additions & 0 deletions tests/expand/pr24-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"@context": [{
"@version": 1.1,
"@protected": true,
"foo": "http://example/foo#"
}, {
"@version": 1.1,
"@protected": true,
"foo": "http://example/foo#"
}],
"foo:bar": "foobar"
}
8 changes: 8 additions & 0 deletions tests/expand/pr24-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"http://example/foo#bar": [{
"@value": "foobar"
}]
}
]

141 changes: 141 additions & 0 deletions tests/expand/pr25-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
{
"@context": [{
"@version": 1.1,
"@protected": true,
"id": "@id",
"type": "@type",
"foo": {
"@id": "http://example/foo",
"@container": ["@graph", "@set"]
},
"bar": {
"@id": "http://example/bar",
"@type": "@id",
"@context": {
"@version": 1.1,
"@protected": true,
"bar-1": {
"@id": "http://example/bar-1",
"@context": {
"@version": 1.1,
"@protected": true,
"bar-2": "http://example/bar-2",
"Foo": {
"@id": "http://example/Foo",
"@context": {
"@version": 1.1,
"@protected": true,
"bar-2": "http://example/bar-2"
}
}
}
}
}
},
"Bar": {
"@id": "http://example/Bar",
"@context": {
"@version": 1.1,
"@protected": true,
"bar-1": {
"@id": "http://example/bar-1",
"@context": {
"@version": 1.1,
"@protected": true,
"bar-2": "http://example/bar-2",
"Foo": {
"@id": "http://example/Foo",
"@context": {
"@version": 1.1,
"@protected": true,
"bar-2": "http://example/bar-2"
}
}
}
}
}
},
"Foo": {
"@id": "http://example/Foo",
"@context": {
"@version": 1.1,
"@protected": true,
"bar-2": "http://example/bar-2"
}
}
}, {
"@version": 1.1,
"@protected": true,
"id": "@id",
"type": "@type",
"foo": {
"@id": "http://example/foo",
"@container": ["@graph", "@set"]
},
"bar": {
"@id": "http://example/bar",
"@type": "@id",
"@context": {
"@version": 1.1,
"@protected": true,
"bar-1": {
"@id": "http://example/bar-1",
"@context": {
"@version": 1.1,
"@protected": true,
"bar-2": "http://example/bar-2",
"Foo": {
"@id": "http://example/Foo",
"@context": {
"@version": 1.1,
"@protected": true,
"bar-2": "http://example/bar-2"
}
}
}
}
}
},
"Bar": {
"@id": "http://example/Bar",
"@context": {
"@version": 1.1,
"@protected": true,
"bar-1": {
"@id": "http://example/bar-1",
"@context": {
"@version": 1.1,
"@protected": true,
"bar-2": "http://example/bar-2",
"Foo": {
"@id": "http://example/Foo",
"@context": {
"@version": 1.1,
"@protected": true,
"bar-2": "http://example/bar-2"
}
}
}
}
}
},
"Foo": {
"@id": "http://example/Foo",
"@context": {
"@version": 1.1,
"@protected": true,
"bar-2": "http://example/bar-2"
}
}
}],
"type": "Bar",
"foo": [{
"bar": "http://example/"
}],
"bar-1": {
"bar-2": {
"type": "Foo",
"bar-2": "bar-2"
}
}
}
23 changes: 23 additions & 0 deletions tests/expand/pr25-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"@type": [
"http://example/Bar"
],
"http://example/foo": [{
"@graph": [{
"http://example/bar": [{
"@id": "http://example/"
}]
}]
}],
"http://example/bar-1": [{
"http://example/bar-2": [{
"@type": ["http://example/Foo"],
"http://example/bar-2": [{
"@value": "bar-2"
}]
}]
}]
}
]

Loading