Skip to content

Add API support for lists containing lists #16

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
Aug 11, 2018
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
131 changes: 57 additions & 74 deletions index.html

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@ Tests are defined into _compact_, _expand_, _flatten_, _remote-doc_, _fromRdf_,
* _httpStatus_: The HTTP status code to return, defaults to `200`.
* _redirectTo_: The HTTP _Content-Location_ header value.
* _httpLink_: The HTTP _Link_ header value.
* _fromRdf_ tests have _input_ and _expected_ documents. The _expected_ results can be compared using [RDF Dataset Isomorphism](https://www.w3.org/TR/rdf11-concepts/#dfn-dataset-isomorphism).
* _toRdf_ tests have _input_ and _expected_ documents. The _expected_ results can be compared using JSON object comparison with the processor output.
* _fromRdf_ tests have _input_ and _expected_ documents. The _expected_ results can be compared using JSON object comparison with the processor output. Note that comparison of JSON Arrays should consider the fact that statements in an RDF Dataset are unordered, and therefore, properties with multiple values, and the value of `@graph` may not be ordered as in the _expected_ document and blank node labels may not be preserved.
* _toRdf_ tests have _input_ and _expected_ documents. The _expected_ results can be compared using [RDF Dataset Isomorphism](https://www.w3.org/TR/rdf11-concepts/#dfn-dataset-isomorphism).

Unless `processingMode` is set explicitly in a test entry, `processingMode` is compatible with both `json-ld-1.0` and `json-ld-1.1`.

Test results that include a context input presume that the context is provided locally, and not from the referenced location, thus the results will include the content of the context file, rather than a reference.

# Running tests
Implementations create their own infrastructure for running the test suite. In particular, the following should be considered:

* _remote-doc_ tests will likely not return expected HTTP headers, so the _options_ should be used to determine what headers are associated with the input document.
* Some algorithms, particularly _fromRdf_, may not preserve the order of statements listed in the input document, and provision should be taken for performing unordered array comparison, for arrays other than values of `@list`. (This may be difficult for compacted results, where array value ordering is dependent on the associated term definition).
* Some implementations may choose an alternative Blank Node Label algorithm, the comparison between documents containing blank node labels should take this into consideration. (One way to do this may be to reduce both results and _expected_ to datsets to extract a bijective mapping of blank node labels between the two datasets as described in [RDF Dataset Isomorphism](https://www.w3.org/TR/rdf11-concepts/#dfn-dataset-isomorphism)).
# Contributing

If you would like to contribute a new test or a fix to an existing test,
Expand Down
46 changes: 46 additions & 0 deletions tests/compact-manifest.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,7 @@
"@type": [ "jld:NegativeEvaluationTest", "jld:CompactTest" ],
"name": "Compaction to list of lists",
"purpose": "Verifies that an exception is raised in Compaction when attempting to compact a list of lists",
"option": {"specVersion": "json-ld-1.0"},
"input": "compact/e001-in.jsonld",
"context": "compact/e001-context.jsonld",
"expect": "compaction to list of lists"
Expand Down Expand Up @@ -1474,6 +1475,51 @@
"context": "compact/s002-context.jsonld",
"expect": "compact/s002-out.jsonld",
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
}, {
"@id": "#tli01",
"@type": [ "jld:PositiveEvaluationTest", "jld:CompactTest" ],
"name": "coerced @list containing an empty list",
"purpose": "Lists of Lists",
"input": "compact/li01-in.jsonld",
"context": "compact/li01-context.jsonld",
"expect": "compact/li01-out.jsonld",
"option": {"specVersion": "json-ld-1.1"}
}, {
"@id": "#tli02",
"@type": [ "jld:PositiveEvaluationTest", "jld:CompactTest" ],
"name": "coerced @list containing a list",
"purpose": "Lists of Lists",
"input": "compact/li02-in.jsonld",
"context": "compact/li02-context.jsonld",
"expect": "compact/li02-out.jsonld",
"option": {"specVersion": "json-ld-1.1"}
}, {
"@id": "#tli03",
"@type": [ "jld:PositiveEvaluationTest", "jld:CompactTest" ],
"name": "coerced @list containing an deep list",
"purpose": "Lists of Lists",
"input": "compact/li03-in.jsonld",
"context": "compact/li03-context.jsonld",
"expect": "compact/li03-out.jsonld",
"option": {"specVersion": "json-ld-1.1"}
}, {
"@id": "#tli04",
"@type": [ "jld:PositiveEvaluationTest", "jld:CompactTest" ],
"name": "coerced @list containing multiple lists",
"purpose": "Lists of Lists",
"input": "compact/li04-in.jsonld",
"context": "compact/li04-context.jsonld",
"expect": "compact/li04-out.jsonld",
"option": {"specVersion": "json-ld-1.1"}
}, {
"@id": "#tli05",
"@type": [ "jld:PositiveEvaluationTest", "jld:CompactTest" ],
"name": "coerced @list containing mixed list values",
"purpose": "Lists of Lists",
"input": "compact/li05-in.jsonld",
"context": "compact/li05-context.jsonld",
"expect": "compact/li05-out.jsonld",
"option": {"specVersion": "json-ld-1.1"}
}
]
}
3 changes: 3 additions & 0 deletions tests/compact/li01-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"@context": {"foo": {"@id": "http://example.com/foo", "@container": "@list"}}
}
3 changes: 3 additions & 0 deletions tests/compact/li01-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[{
"http://example.com/foo": [{"@list": [{"@list": []}]}]
}]
4 changes: 4 additions & 0 deletions tests/compact/li01-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"@context": {"foo": {"@id": "http://example.com/foo", "@container": "@list"}},
"foo": [[]]
}
3 changes: 3 additions & 0 deletions tests/compact/li02-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"@context": {"foo": {"@id": "http://example.com/foo", "@container": "@list"}}
}
3 changes: 3 additions & 0 deletions tests/compact/li02-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[{
"http://example.com/foo": [{"@list": [{"@list": [{"@value": "baz"}]}]}]
}]
4 changes: 4 additions & 0 deletions tests/compact/li02-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"@context": {"foo": {"@id": "http://example.com/foo", "@container": "@list"}},
"foo": [["baz"]]
}
3 changes: 3 additions & 0 deletions tests/compact/li03-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"@context": {"foo": {"@id": "http://example.com/foo", "@container": "@list"}}
}
3 changes: 3 additions & 0 deletions tests/compact/li03-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[{
"http://example.com/foo": [{"@list": [{"@list": [{"@list": [{"@value": "baz"}]}]}]}]
}]
4 changes: 4 additions & 0 deletions tests/compact/li03-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"@context": {"foo": {"@id": "http://example.com/foo", "@container": "@list"}},
"foo": [[["baz"]]]
}
3 changes: 3 additions & 0 deletions tests/compact/li04-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"@context": {"foo": {"@id": "http://example.com/foo", "@container": "@list"}}
}
6 changes: 6 additions & 0 deletions tests/compact/li04-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[{
"http://example.com/foo": [{"@list": [
{"@list": [{"@value": "a"}]},
{"@list": [{"@value": "b"}]}
]}]
}]
4 changes: 4 additions & 0 deletions tests/compact/li04-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"@context": {"foo": {"@id": "http://example.com/foo", "@container": "@list"}},
"foo": [["a"], ["b"]]
}
3 changes: 3 additions & 0 deletions tests/compact/li05-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"@context": {"foo": {"@id": "http://example.com/foo", "@container": "@list"}}
}
6 changes: 6 additions & 0 deletions tests/compact/li05-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"http://example.com/foo": [{"@list": [
{"@list": [{"@value": "a"}]},
{"@value": "b"}
]}]
}
4 changes: 4 additions & 0 deletions tests/compact/li05-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"@context": {"foo": {"@id": "http://example.com/foo", "@container": "@list"}},
"foo": [["a"], "b"]
}
Loading