Skip to content

Commit c9ffc91

Browse files
davidlehngkellogg
authored andcommitted
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 45d172b commit c9ffc91

Some content is hidden

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

56 files changed

+568
-2
lines changed

tests/compact-manifest.jsonld

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,6 +1405,15 @@
14051405
"input": "compact/ep15-in.jsonld",
14061406
"context": "compact/ep15-context.jsonld",
14071407
"expectErrorCode": "invalid container mapping"
1408+
}, {
1409+
"@id": "#tej01",
1410+
"@type": ["jld:NegativeEvaluationTest", "jld:CompactTest"],
1411+
"name": "Multiple JSON values for a JSON literal properties",
1412+
"purpose": "Tests compacting multiple JSON values for a JSON literal property.",
1413+
"input": "compact/ej01-in.jsonld",
1414+
"context": "compact/ej01-context.jsonld",
1415+
"expectErrorCode": "multiple JSON literals",
1416+
"option": {"specVersion": "json-ld-1.1"}
14081417
}, {
14091418
"@id": "#tin01",
14101419
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
@@ -1549,6 +1558,51 @@
15491558
"context": "compact/js11-context.jsonld",
15501559
"expect": "compact/js11-out.jsonld",
15511560
"option": {"specVersion": "json-ld-1.1"}
1561+
}, {
1562+
"@id": "#tjs12",
1563+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
1564+
"name": "Compact JSON literal (empty array)",
1565+
"purpose": "Tests compacting property with @type @json to a JSON literal (empty array).",
1566+
"input": "compact/js12-in.jsonld",
1567+
"context": "compact/js12-context.jsonld",
1568+
"expect": "compact/js12-out.jsonld",
1569+
"option": {"specVersion": "json-ld-1.1"}
1570+
}, {
1571+
"@id": "#tjs13",
1572+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
1573+
"name": "Compact JSON literal (array with string)",
1574+
"purpose": "Tests compacting property with @type @json to a JSON literal (array with string).",
1575+
"input": "compact/js13-in.jsonld",
1576+
"context": "compact/js13-context.jsonld",
1577+
"expect": "compact/js13-out.jsonld",
1578+
"option": {"specVersion": "json-ld-1.1"}
1579+
}, {
1580+
"@id": "#tjs14",
1581+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
1582+
"name": "Compact JSON literal and non-JSON with @json property",
1583+
"purpose": "Tests compacting property with @type @json with JSON literal and non-JSON.",
1584+
"input": "compact/js14-in.jsonld",
1585+
"context": "compact/js14-context.jsonld",
1586+
"expect": "compact/js14-out.jsonld",
1587+
"option": {"specVersion": "json-ld-1.1"}
1588+
}, {
1589+
"@id": "#tjs15",
1590+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
1591+
"name": "Compact JSON literal and non-JSON without @json property",
1592+
"purpose": "Tests compacting property without @type @json with JSON literal and non-JSON.",
1593+
"input": "compact/js15-in.jsonld",
1594+
"context": "compact/js15-context.jsonld",
1595+
"expect": "compact/js15-out.jsonld",
1596+
"option": {"specVersion": "json-ld-1.1"}
1597+
}, {
1598+
"@id": "#tjs16",
1599+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
1600+
"name": "Compact JSON literal and non-JSON with and without @json property",
1601+
"purpose": "Tests compacting property with and without @type @json with JSON literal and non-JSON.",
1602+
"input": "compact/js16-in.jsonld",
1603+
"context": "compact/js16-context.jsonld",
1604+
"expect": "compact/js16-out.jsonld",
1605+
"option": {"specVersion": "json-ld-1.1"}
15521606
}, {
15531607
"@id": "#tla01",
15541608
"@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)