Skip to content

Commit 45abde9

Browse files
committed
Add API support for lists containing lists. Affects expansion, compaction, flattening and to/from RDF conversion. Also adds tests.
For w3c/json-ld-syntax#36.
1 parent a0dd7a8 commit 45abde9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+543
-3423
lines changed

index.html

Lines changed: 57 additions & 74 deletions
Large diffs are not rendered by default.

tests/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,19 @@ Tests are defined into _compact_, _expand_, _flatten_, _remote-doc_, _fromRdf_,
1616
* _httpStatus_: The HTTP status code to return, defaults to `200`.
1717
* _redirectTo_: The HTTP _Content-Location_ header value.
1818
* _httpLink_: The HTTP _Link_ header value.
19-
* _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).
20-
* _toRdf_ tests have _input_ and _expected_ documents. The _expected_ results can be compared using JSON object comparison with the processor output.
19+
* _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.
20+
* _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).
2121

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

2424
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.
2525

26+
# Running tests
27+
Implementations create their own infrastructure for running the test suite. In particular, the following should be considered:
28+
29+
* _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.
30+
* 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).
31+
* Some implementations may chose 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 bijection mapping blank node labels between the two datasets as described in [RDF Dataset Isomorphism](https://www.w3.org/TR/rdf11-concepts/#dfn-dataset-isomorphism)).
2632
# Contributing
2733

2834
If you would like to contribute a new test or a fix to an existing test,

tests/compact-manifest.jsonld

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@
982982
"@type": [ "jld:NegativeEvaluationTest", "jld:CompactTest" ],
983983
"name": "Compaction to list of lists",
984984
"purpose": "Verifies that an exception is raised in Compaction when attempting to compact a list of lists",
985+
"option": {"specVersion": "json-ld-1.0"},
985986
"input": "compact/e001-in.jsonld",
986987
"context": "compact/e001-context.jsonld",
987988
"expect": "compaction to list of lists"
@@ -1474,6 +1475,51 @@
14741475
"context": "compact/s002-context.jsonld",
14751476
"expect": "compact/s002-out.jsonld",
14761477
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
1478+
}, {
1479+
"@id": "#tli01",
1480+
"@type": [ "jld:PositiveEvaluationTest", "jld:CompactTest" ],
1481+
"name": "coerced @list containing an empty list",
1482+
"purpose": "Lists of Lists",
1483+
"input": "compact/li01-in.jsonld",
1484+
"context": "compact/li01-context.jsonld",
1485+
"expect": "compact/li01-out.jsonld",
1486+
"option": {"specVersion": "json-ld-1.1"}
1487+
}, {
1488+
"@id": "#tli02",
1489+
"@type": [ "jld:PositiveEvaluationTest", "jld:CompactTest" ],
1490+
"name": "coerced @list containing a list",
1491+
"purpose": "Lists of Lists",
1492+
"input": "compact/li02-in.jsonld",
1493+
"context": "compact/li02-context.jsonld",
1494+
"expect": "compact/li02-out.jsonld",
1495+
"option": {"specVersion": "json-ld-1.1"}
1496+
}, {
1497+
"@id": "#tli03",
1498+
"@type": [ "jld:PositiveEvaluationTest", "jld:CompactTest" ],
1499+
"name": "coerced @list containing an deep list",
1500+
"purpose": "Lists of Lists",
1501+
"input": "compact/li03-in.jsonld",
1502+
"context": "compact/li03-context.jsonld",
1503+
"expect": "compact/li03-out.jsonld",
1504+
"option": {"specVersion": "json-ld-1.1"}
1505+
}, {
1506+
"@id": "#tli04",
1507+
"@type": [ "jld:PositiveEvaluationTest", "jld:CompactTest" ],
1508+
"name": "coerced @list containing multiple lists",
1509+
"purpose": "Lists of Lists",
1510+
"input": "compact/li04-in.jsonld",
1511+
"context": "compact/li04-context.jsonld",
1512+
"expect": "compact/li04-out.jsonld",
1513+
"option": {"specVersion": "json-ld-1.1"}
1514+
}, {
1515+
"@id": "#tli05",
1516+
"@type": [ "jld:PositiveEvaluationTest", "jld:CompactTest" ],
1517+
"name": "coerced @list containing mixed list values",
1518+
"purpose": "Lists of Lists",
1519+
"input": "compact/li05-in.jsonld",
1520+
"context": "compact/li05-context.jsonld",
1521+
"expect": "compact/li05-out.jsonld",
1522+
"option": {"specVersion": "json-ld-1.1"}
14771523
}
14781524
]
14791525
}

tests/compact/li01-context.jsonld

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"@context": {"foo": {"@id": "http://example.com/foo", "@container": "@list"}}
3+
}

tests/compact/li01-in.jsonld

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[{
2+
"http://example.com/foo": [{"@list": [{"@list": []}]}]
3+
}]

tests/compact/li01-out.jsonld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"@context": {"foo": {"@id": "http://example.com/foo", "@container": "@list"}},
3+
"foo": [[]]
4+
}

tests/compact/li02-context.jsonld

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"@context": {"foo": {"@id": "http://example.com/foo", "@container": "@list"}}
3+
}

tests/compact/li02-in.jsonld

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[{
2+
"http://example.com/foo": [{"@list": [{"@list": [{"@value": "baz"}]}]}]
3+
}]

tests/compact/li02-out.jsonld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"@context": {"foo": {"@id": "http://example.com/foo", "@container": "@list"}},
3+
"foo": [["baz"]]
4+
}

tests/compact/li03-context.jsonld

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"@context": {"foo": {"@id": "http://example.com/foo", "@container": "@list"}}
3+
}

tests/compact/li03-in.jsonld

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[{
2+
"http://example.com/foo": [{"@list": [{"@list": [{"@list": [{"@value": "baz"}]}]}]}]
3+
}]

tests/compact/li03-out.jsonld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"@context": {"foo": {"@id": "http://example.com/foo", "@container": "@list"}},
3+
"foo": [[["baz"]]]
4+
}

tests/compact/li04-context.jsonld

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"@context": {"foo": {"@id": "http://example.com/foo", "@container": "@list"}}
3+
}

tests/compact/li04-in.jsonld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[{
2+
"http://example.com/foo": [{"@list": [
3+
{"@list": [{"@value": "a"}]},
4+
{"@list": [{"@value": "b"}]}
5+
]}]
6+
}]

tests/compact/li04-out.jsonld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"@context": {"foo": {"@id": "http://example.com/foo", "@container": "@list"}},
3+
"foo": [["a"], ["b"]]
4+
}

tests/compact/li05-context.jsonld

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"@context": {"foo": {"@id": "http://example.com/foo", "@container": "@list"}}
3+
}

tests/compact/li05-in.jsonld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"http://example.com/foo": [{"@list": [
3+
{"@list": [{"@value": "a"}]},
4+
{"@value": "b"}
5+
]}]
6+
}

tests/compact/li05-out.jsonld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"@context": {"foo": {"@id": "http://example.com/foo", "@container": "@list"}},
3+
"foo": [["a"], "b"]
4+
}

0 commit comments

Comments
 (0)