Skip to content

Commit ad04884

Browse files
committed
Add JSON literal tests.
- Various tests of when `@type` of `@json` is used, the JSON may be an array, and the interaction with a `@container` of `@set` and `@list`. - Change compaction output for `@json` and `@set` with a JSON array. - Add test for many other possibilities and processing algorithms. - Propose new `multiple JSON literals` error code when trying to add multiple JSON literals as values for a property.
1 parent 4f1c16f commit ad04884

Some content is hidden

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

58 files changed

+588
-2
lines changed

tests/compact-manifest.jsonld

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,6 +1398,15 @@
13981398
"input": "compact/ep15-in.jsonld",
13991399
"context": "compact/ep15-context.jsonld",
14001400
"expectErrorCode": "invalid container mapping"
1401+
}, {
1402+
"@id": "#tej01",
1403+
"@type": ["jld:NegativeEvaluationTest", "jld:CompactTest"],
1404+
"name": "Multiple JSON values for a JSON literal properties",
1405+
"purpose": "Tests compacting multiple JSON values for a JSON literal property.",
1406+
"input": "compact/ej01-in.jsonld",
1407+
"context": "compact/ej01-context.jsonld",
1408+
"expectErrorCode": "multiple JSON literals",
1409+
"option": {"specVersion": "json-ld-1.1"}
14011410
}, {
14021411
"@id": "#tin01",
14031412
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
@@ -1542,6 +1551,51 @@
15421551
"context": "compact/js11-context.jsonld",
15431552
"expect": "compact/js11-out.jsonld",
15441553
"option": {"specVersion": "json-ld-1.1"}
1554+
}, {
1555+
"@id": "#tjs12",
1556+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
1557+
"name": "Compact JSON literal (empty array)",
1558+
"purpose": "Tests compacting property with @type @json to a JSON literal (empty array).",
1559+
"input": "compact/js12-in.jsonld",
1560+
"context": "compact/js12-context.jsonld",
1561+
"expect": "compact/js12-out.jsonld",
1562+
"option": {"specVersion": "json-ld-1.1"}
1563+
}, {
1564+
"@id": "#tjs13",
1565+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
1566+
"name": "Compact JSON literal (array with string)",
1567+
"purpose": "Tests compacting property with @type @json to a JSON literal (array with string).",
1568+
"input": "compact/js13-in.jsonld",
1569+
"context": "compact/js13-context.jsonld",
1570+
"expect": "compact/js13-out.jsonld",
1571+
"option": {"specVersion": "json-ld-1.1"}
1572+
}, {
1573+
"@id": "#tjs14",
1574+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
1575+
"name": "Compact JSON literal and non-JSON with @json property",
1576+
"purpose": "Tests compacting property with @type @json with JSON literal and non-JSON.",
1577+
"input": "compact/js14-in.jsonld",
1578+
"context": "compact/js14-context.jsonld",
1579+
"expect": "compact/js14-out.jsonld",
1580+
"option": {"specVersion": "json-ld-1.1"}
1581+
}, {
1582+
"@id": "#tjs15",
1583+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
1584+
"name": "Compact JSON literal and non-JSON without @json property",
1585+
"purpose": "Tests compacting property without @type @json with JSON literal and non-JSON.",
1586+
"input": "compact/js15-in.jsonld",
1587+
"context": "compact/js15-context.jsonld",
1588+
"expect": "compact/js15-out.jsonld",
1589+
"option": {"specVersion": "json-ld-1.1"}
1590+
}, {
1591+
"@id": "#tjs16",
1592+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
1593+
"name": "Compact JSON literal and non-JSON with and without @json property",
1594+
"purpose": "Tests compacting property with and without @type @json with JSON literal and non-JSON.",
1595+
"input": "compact/js16-in.jsonld",
1596+
"context": "compact/js16-context.jsonld",
1597+
"expect": "compact/js16-out.jsonld",
1598+
"option": {"specVersion": "json-ld-1.1"}
15451599
}, {
15461600
"@id": "#tla01",
15471601
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],

tests/compact/ej01-context.jsonld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"e": {"@id": "http://example.org/vocab#value", "@type": "@json"}
5+
}
6+
}

tests/compact/ej01-in.jsonld

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[{
2+
"http://example.org/vocab#value": [{
3+
"@value": ["JSON1"],
4+
"@type": "@json"
5+
}, {
6+
"@value": ["JSON2"],
7+
"@type": "@json"
8+
}]
9+
}]

tests/compact/js07-out.jsonld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"@version": 1.1,
44
"e": {"@id": "http://example.org/vocab#array", "@type": "@json", "@container": "@set"}
55
},
6-
"e": [{"foo": "bar"}]
7-
}
6+
"e": [[{"foo": "bar"}]]
7+
}

tests/compact/js12-context.jsonld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"e": {"@id": "http://example.org/vocab#value", "@type": "@json"}
5+
}
6+
}

tests/compact/js12-in.jsonld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[{
2+
"http://example.org/vocab#value": [{
3+
"@value": ["string"],
4+
"@type": "@json"
5+
}]
6+
}]

tests/compact/js12-out.jsonld

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"e": {"@id": "http://example.org/vocab#value", "@type": "@json"}
5+
},
6+
"e": ["string"]
7+
}

tests/compact/js13-context.jsonld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"e": {"@id": "http://example.org/vocab#value", "@type": "@json"}
5+
}
6+
}

tests/compact/js13-in.jsonld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[{
2+
"http://example.org/vocab#value": [{
3+
"@value": [],
4+
"@type": "@json"
5+
}]
6+
}]

tests/compact/js13-out.jsonld

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"e": {"@id": "http://example.org/vocab#value", "@type": "@json"}
5+
},
6+
"e": []
7+
}

0 commit comments

Comments
 (0)