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+
}

tests/compact/js14-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/js14-in.jsonld

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

tests/compact/js14-out.jsonld

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

tests/compact/js15-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"}
5+
}
6+
}

tests/compact/js15-in.jsonld

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

tests/compact/js15-out.jsonld

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

tests/compact/js16-context.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-json": {"@id": "http://example.org/vocab#value", "@type": "@json"},
5+
"e-non-json": {"@id": "http://example.org/vocab#value"}
6+
}
7+
}

tests/compact/js16-in.jsonld

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

tests/compact/js16-out.jsonld

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

tests/expand-manifest.jsonld

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,6 +1826,20 @@
18261826
"purpose": "Verifies that an exception is raised when attempting to redefine @context.",
18271827
"input": "expand/er56-in.jsonld",
18281828
"expectErrorCode": "keyword redefinition"
1829+
}, {
1830+
"@id": "#ter57",
1831+
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
1832+
"name": "Array not found for @json @set.",
1833+
"purpose": "The value for a @json @set term MUST be an array.",
1834+
"input": "expand/er57-in.jsonld",
1835+
"expectErrorCode": "invalid set or list object"
1836+
}, {
1837+
"@id": "#ter58",
1838+
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
1839+
"name": "Array not found for @json @list.",
1840+
"purpose": "The value for a @json @list term MUST be an array.",
1841+
"input": "expand/er58-in.jsonld",
1842+
"expectErrorCode": "invalid set or list object"
18291843
}, {
18301844
"@id": "#tes01",
18311845
"@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"],
@@ -2098,6 +2112,62 @@
20982112
"input": "expand/js23-in.jsonld",
20992113
"expect": "expand/js23-out.jsonld",
21002114
"option": {"specVersion": "json-ld-1.1"}
2115+
}, {
2116+
"@id": "#tjs24",
2117+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
2118+
"name": "Expand JSON literal (one JSON literal).",
2119+
"purpose": "Tests expanding property with @type @json (one JSON literal).",
2120+
"input": "expand/js24-in.jsonld",
2121+
"expect": "expand/js24-out.jsonld",
2122+
"option": {"specVersion": "json-ld-1.1"}
2123+
}, {
2124+
"@id": "#tjs25",
2125+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
2126+
"name": "Expand JSON literal (two JSON literals).",
2127+
"purpose": "Tests expanding property with @type @json (two JSON literals).",
2128+
"input": "expand/js25-in.jsonld",
2129+
"expect": "expand/js25-out.jsonld",
2130+
"option": {"specVersion": "json-ld-1.1"}
2131+
}, {
2132+
"@id": "#tjs26",
2133+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
2134+
"name": "Expand JSON literal (JSON literal and non-JSON).",
2135+
"purpose": "Tests expanding property with @type @json (JSON literal and non-JSON).",
2136+
"input": "expand/js26-in.jsonld",
2137+
"expect": "expand/js26-out.jsonld",
2138+
"option": {"specVersion": "json-ld-1.1"}
2139+
}, {
2140+
"@id": "#tjs27",
2141+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
2142+
"name": "Expand JSON literal (duplicate JSON literals).",
2143+
"purpose": "Tests expanding property with @type @json (dupcliate JSON literals).",
2144+
"input": "expand/js27-in.jsonld",
2145+
"expect": "expand/js27-out.jsonld",
2146+
"option": {"specVersion": "json-ld-1.1"}
2147+
}, {
2148+
"@id": "#tjs28",
2149+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
2150+
"name": "Expand array-like value with @json and no @set/@list in @context.",
2151+
"purpose": "Tests expanding array-like value with @json and no @set/@list in @context.",
2152+
"input": "expand/js28-in.jsonld",
2153+
"expect": "expand/js28-out.jsonld",
2154+
"option": {"specVersion": "json-ld-1.1"}
2155+
}, {
2156+
"@id": "#tjs29",
2157+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
2158+
"name": "Expand array-like value with @json and @set in @context.",
2159+
"purpose": "Tests expanding array-like value with @json and @set in @context.",
2160+
"input": "expand/js29-in.jsonld",
2161+
"expect": "expand/js29-out.jsonld",
2162+
"option": {"specVersion": "json-ld-1.1"}
2163+
}, {
2164+
"@id": "#tjs30",
2165+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
2166+
"name": "Expand array-like value with @json and @list in @context.",
2167+
"purpose": "Tests expanding array-like value with @json and @list in @context.",
2168+
"input": "expand/js30-in.jsonld",
2169+
"expect": "expand/js30-out.jsonld",
2170+
"option": {"specVersion": "json-ld-1.1"}
21012171
}, {
21022172
"@id": "#tl001",
21032173
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],

tests/expand/er57-in.jsonld

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"@context": {
3+
"prop": {
4+
"@id": "ex:prop",
5+
"@type": "@json",
6+
"@container": "@list"
7+
}
8+
},
9+
"prop": "value"
10+
}

tests/expand/js24-in.jsonld

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

tests/expand/js24-out.jsonld

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

tests/expand/js25-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": ["JSON1"], "@type": "@json"},
4+
{"@value": ["JSON2"], "@type": "@json"}
5+
]
6+
}

tests/expand/js25-out.jsonld

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

tests/expand/js26-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": ["JSON"], "@type": "@json"},
4+
{"@value": "non-JSON"}
5+
]
6+
}

tests/expand/js26-out.jsonld

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

tests/expand/js27-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": ["dup"], "@type": "@json"},
4+
{"@value": ["dup"], "@type": "@json"}
5+
]
6+
}

tests/expand/js27-out.jsonld

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

tests/expand/js28-in.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": "ex:e", "@type": "@json"}
5+
},
6+
"e": ["v1", "v2"]
7+
}

0 commit comments

Comments
 (0)