From ad04884bcd0d2fed25918f7ee06b2cab1559f645 Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Wed, 1 Mar 2023 01:19:14 -0500 Subject: [PATCH] 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. --- tests/compact-manifest.jsonld | 54 ++++++++++++++++++++++++ tests/compact/ej01-context.jsonld | 6 +++ tests/compact/ej01-in.jsonld | 9 ++++ tests/compact/js07-out.jsonld | 4 +- tests/compact/js12-context.jsonld | 6 +++ tests/compact/js12-in.jsonld | 6 +++ tests/compact/js12-out.jsonld | 7 ++++ tests/compact/js13-context.jsonld | 6 +++ tests/compact/js13-in.jsonld | 6 +++ tests/compact/js13-out.jsonld | 7 ++++ tests/compact/js14-context.jsonld | 6 +++ tests/compact/js14-in.jsonld | 8 ++++ tests/compact/js14-out.jsonld | 8 ++++ tests/compact/js15-context.jsonld | 6 +++ tests/compact/js15-in.jsonld | 8 ++++ tests/compact/js15-out.jsonld | 13 ++++++ tests/compact/js16-context.jsonld | 7 ++++ tests/compact/js16-in.jsonld | 8 ++++ tests/compact/js16-out.jsonld | 9 ++++ tests/expand-manifest.jsonld | 70 +++++++++++++++++++++++++++++++ tests/expand/er56-in.jsonld | 10 +++++ tests/expand/er57-in.jsonld | 10 +++++ tests/expand/js24-in.jsonld | 3 ++ tests/expand/js24-out.jsonld | 8 ++++ tests/expand/js25-in.jsonld | 6 +++ tests/expand/js25-out.jsonld | 13 ++++++ tests/expand/js26-in.jsonld | 6 +++ tests/expand/js26-out.jsonld | 10 +++++ tests/expand/js27-in.jsonld | 6 +++ tests/expand/js27-out.jsonld | 13 ++++++ tests/expand/js28-in.jsonld | 7 ++++ tests/expand/js28-out.jsonld | 13 ++++++ tests/expand/js29-in.jsonld | 7 ++++ tests/expand/js29-out.jsonld | 14 +++++++ tests/expand/js30-in.jsonld | 7 ++++ tests/expand/js30-out.jsonld | 18 ++++++++ tests/fromRdf-manifest.jsonld | 16 +++++++ tests/fromRdf/js12-in.nq | 2 + tests/fromRdf/js12-out.jsonld | 10 +++++ tests/fromRdf/js13-in.nq | 2 + tests/fromRdf/js13-out.jsonld | 9 ++++ tests/toRdf-manifest.jsonld | 70 +++++++++++++++++++++++++++++++ tests/toRdf/er56-in.jsonld | 10 +++++ tests/toRdf/er57-in.jsonld | 10 +++++ tests/toRdf/js24-in.jsonld | 3 ++ tests/toRdf/js24-out.nq | 1 + tests/toRdf/js25-in.jsonld | 6 +++ tests/toRdf/js25-out.nq | 2 + tests/toRdf/js26-in.jsonld | 6 +++ tests/toRdf/js26-out.nq | 2 + tests/toRdf/js27-in.jsonld | 6 +++ tests/toRdf/js27-out.nq | 1 + tests/toRdf/js28-in.jsonld | 7 ++++ tests/toRdf/js28-out.nq | 1 + tests/toRdf/js29-in.jsonld | 7 ++++ tests/toRdf/js29-out.nq | 2 + tests/toRdf/js30-in.jsonld | 7 ++++ tests/toRdf/js30-out.nq | 5 +++ 58 files changed, 588 insertions(+), 2 deletions(-) create mode 100644 tests/compact/ej01-context.jsonld create mode 100644 tests/compact/ej01-in.jsonld create mode 100644 tests/compact/js12-context.jsonld create mode 100644 tests/compact/js12-in.jsonld create mode 100644 tests/compact/js12-out.jsonld create mode 100644 tests/compact/js13-context.jsonld create mode 100644 tests/compact/js13-in.jsonld create mode 100644 tests/compact/js13-out.jsonld create mode 100644 tests/compact/js14-context.jsonld create mode 100644 tests/compact/js14-in.jsonld create mode 100644 tests/compact/js14-out.jsonld create mode 100644 tests/compact/js15-context.jsonld create mode 100644 tests/compact/js15-in.jsonld create mode 100644 tests/compact/js15-out.jsonld create mode 100644 tests/compact/js16-context.jsonld create mode 100644 tests/compact/js16-in.jsonld create mode 100644 tests/compact/js16-out.jsonld create mode 100644 tests/expand/er56-in.jsonld create mode 100644 tests/expand/er57-in.jsonld create mode 100644 tests/expand/js24-in.jsonld create mode 100644 tests/expand/js24-out.jsonld create mode 100644 tests/expand/js25-in.jsonld create mode 100644 tests/expand/js25-out.jsonld create mode 100644 tests/expand/js26-in.jsonld create mode 100644 tests/expand/js26-out.jsonld create mode 100644 tests/expand/js27-in.jsonld create mode 100644 tests/expand/js27-out.jsonld create mode 100644 tests/expand/js28-in.jsonld create mode 100644 tests/expand/js28-out.jsonld create mode 100644 tests/expand/js29-in.jsonld create mode 100644 tests/expand/js29-out.jsonld create mode 100644 tests/expand/js30-in.jsonld create mode 100644 tests/expand/js30-out.jsonld create mode 100644 tests/fromRdf/js12-in.nq create mode 100644 tests/fromRdf/js12-out.jsonld create mode 100644 tests/fromRdf/js13-in.nq create mode 100644 tests/fromRdf/js13-out.jsonld create mode 100644 tests/toRdf/er56-in.jsonld create mode 100644 tests/toRdf/er57-in.jsonld create mode 100644 tests/toRdf/js24-in.jsonld create mode 100644 tests/toRdf/js24-out.nq create mode 100644 tests/toRdf/js25-in.jsonld create mode 100644 tests/toRdf/js25-out.nq create mode 100644 tests/toRdf/js26-in.jsonld create mode 100644 tests/toRdf/js26-out.nq create mode 100644 tests/toRdf/js27-in.jsonld create mode 100644 tests/toRdf/js27-out.nq create mode 100644 tests/toRdf/js28-in.jsonld create mode 100644 tests/toRdf/js28-out.nq create mode 100644 tests/toRdf/js29-in.jsonld create mode 100644 tests/toRdf/js29-out.nq create mode 100644 tests/toRdf/js30-in.jsonld create mode 100644 tests/toRdf/js30-out.nq diff --git a/tests/compact-manifest.jsonld b/tests/compact-manifest.jsonld index c0c429ac..13783511 100644 --- a/tests/compact-manifest.jsonld +++ b/tests/compact-manifest.jsonld @@ -1398,6 +1398,15 @@ "input": "compact/ep15-in.jsonld", "context": "compact/ep15-context.jsonld", "expectErrorCode": "invalid container mapping" + }, { + "@id": "#tej01", + "@type": ["jld:NegativeEvaluationTest", "jld:CompactTest"], + "name": "Multiple JSON values for a JSON literal properties", + "purpose": "Tests compacting multiple JSON values for a JSON literal property.", + "input": "compact/ej01-in.jsonld", + "context": "compact/ej01-context.jsonld", + "expectErrorCode": "multiple JSON literals", + "option": {"specVersion": "json-ld-1.1"} }, { "@id": "#tin01", "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], @@ -1542,6 +1551,51 @@ "context": "compact/js11-context.jsonld", "expect": "compact/js11-out.jsonld", "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#tjs12", + "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], + "name": "Compact JSON literal (empty array)", + "purpose": "Tests compacting property with @type @json to a JSON literal (empty array).", + "input": "compact/js12-in.jsonld", + "context": "compact/js12-context.jsonld", + "expect": "compact/js12-out.jsonld", + "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#tjs13", + "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], + "name": "Compact JSON literal (array with string)", + "purpose": "Tests compacting property with @type @json to a JSON literal (array with string).", + "input": "compact/js13-in.jsonld", + "context": "compact/js13-context.jsonld", + "expect": "compact/js13-out.jsonld", + "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#tjs14", + "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], + "name": "Compact JSON literal and non-JSON with @json property", + "purpose": "Tests compacting property with @type @json with JSON literal and non-JSON.", + "input": "compact/js14-in.jsonld", + "context": "compact/js14-context.jsonld", + "expect": "compact/js14-out.jsonld", + "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#tjs15", + "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], + "name": "Compact JSON literal and non-JSON without @json property", + "purpose": "Tests compacting property without @type @json with JSON literal and non-JSON.", + "input": "compact/js15-in.jsonld", + "context": "compact/js15-context.jsonld", + "expect": "compact/js15-out.jsonld", + "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#tjs16", + "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], + "name": "Compact JSON literal and non-JSON with and without @json property", + "purpose": "Tests compacting property with and without @type @json with JSON literal and non-JSON.", + "input": "compact/js16-in.jsonld", + "context": "compact/js16-context.jsonld", + "expect": "compact/js16-out.jsonld", + "option": {"specVersion": "json-ld-1.1"} }, { "@id": "#tla01", "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], diff --git a/tests/compact/ej01-context.jsonld b/tests/compact/ej01-context.jsonld new file mode 100644 index 00000000..46787e1d --- /dev/null +++ b/tests/compact/ej01-context.jsonld @@ -0,0 +1,6 @@ +{ + "@context": { + "@version": 1.1, + "e": {"@id": "http://example.org/vocab#value", "@type": "@json"} + } +} diff --git a/tests/compact/ej01-in.jsonld b/tests/compact/ej01-in.jsonld new file mode 100644 index 00000000..590f51ae --- /dev/null +++ b/tests/compact/ej01-in.jsonld @@ -0,0 +1,9 @@ +[{ + "http://example.org/vocab#value": [{ + "@value": ["JSON1"], + "@type": "@json" + }, { + "@value": ["JSON2"], + "@type": "@json" + }] +}] diff --git a/tests/compact/js07-out.jsonld b/tests/compact/js07-out.jsonld index d4e7c2cb..bd557c0b 100644 --- a/tests/compact/js07-out.jsonld +++ b/tests/compact/js07-out.jsonld @@ -3,5 +3,5 @@ "@version": 1.1, "e": {"@id": "http://example.org/vocab#array", "@type": "@json", "@container": "@set"} }, - "e": [{"foo": "bar"}] -} \ No newline at end of file + "e": [[{"foo": "bar"}]] +} diff --git a/tests/compact/js12-context.jsonld b/tests/compact/js12-context.jsonld new file mode 100644 index 00000000..46787e1d --- /dev/null +++ b/tests/compact/js12-context.jsonld @@ -0,0 +1,6 @@ +{ + "@context": { + "@version": 1.1, + "e": {"@id": "http://example.org/vocab#value", "@type": "@json"} + } +} diff --git a/tests/compact/js12-in.jsonld b/tests/compact/js12-in.jsonld new file mode 100644 index 00000000..33e2be76 --- /dev/null +++ b/tests/compact/js12-in.jsonld @@ -0,0 +1,6 @@ +[{ + "http://example.org/vocab#value": [{ + "@value": ["string"], + "@type": "@json" + }] +}] diff --git a/tests/compact/js12-out.jsonld b/tests/compact/js12-out.jsonld new file mode 100644 index 00000000..2e680bce --- /dev/null +++ b/tests/compact/js12-out.jsonld @@ -0,0 +1,7 @@ +{ + "@context": { + "@version": 1.1, + "e": {"@id": "http://example.org/vocab#value", "@type": "@json"} + }, + "e": ["string"] +} diff --git a/tests/compact/js13-context.jsonld b/tests/compact/js13-context.jsonld new file mode 100644 index 00000000..46787e1d --- /dev/null +++ b/tests/compact/js13-context.jsonld @@ -0,0 +1,6 @@ +{ + "@context": { + "@version": 1.1, + "e": {"@id": "http://example.org/vocab#value", "@type": "@json"} + } +} diff --git a/tests/compact/js13-in.jsonld b/tests/compact/js13-in.jsonld new file mode 100644 index 00000000..6cdd158e --- /dev/null +++ b/tests/compact/js13-in.jsonld @@ -0,0 +1,6 @@ +[{ + "http://example.org/vocab#value": [{ + "@value": [], + "@type": "@json" + }] +}] diff --git a/tests/compact/js13-out.jsonld b/tests/compact/js13-out.jsonld new file mode 100644 index 00000000..4b889432 --- /dev/null +++ b/tests/compact/js13-out.jsonld @@ -0,0 +1,7 @@ +{ + "@context": { + "@version": 1.1, + "e": {"@id": "http://example.org/vocab#value", "@type": "@json"} + }, + "e": [] +} diff --git a/tests/compact/js14-context.jsonld b/tests/compact/js14-context.jsonld new file mode 100644 index 00000000..46787e1d --- /dev/null +++ b/tests/compact/js14-context.jsonld @@ -0,0 +1,6 @@ +{ + "@context": { + "@version": 1.1, + "e": {"@id": "http://example.org/vocab#value", "@type": "@json"} + } +} diff --git a/tests/compact/js14-in.jsonld b/tests/compact/js14-in.jsonld new file mode 100644 index 00000000..9255f815 --- /dev/null +++ b/tests/compact/js14-in.jsonld @@ -0,0 +1,8 @@ +[{ + "http://example.org/vocab#value": [{ + "@value": [], + "@type": "@json" + }, + "non-JSON" + ] +}] diff --git a/tests/compact/js14-out.jsonld b/tests/compact/js14-out.jsonld new file mode 100644 index 00000000..6ef179b8 --- /dev/null +++ b/tests/compact/js14-out.jsonld @@ -0,0 +1,8 @@ +{ + "@context": { + "@version": 1.1, + "e": {"@id": "http://example.org/vocab#value", "@type": "@json"} + }, + "e": [], + "http://example.org/vocab#value": "non-JSON" +} diff --git a/tests/compact/js15-context.jsonld b/tests/compact/js15-context.jsonld new file mode 100644 index 00000000..96b097d0 --- /dev/null +++ b/tests/compact/js15-context.jsonld @@ -0,0 +1,6 @@ +{ + "@context": { + "@version": 1.1, + "e": {"@id": "http://example.org/vocab#value"} + } +} diff --git a/tests/compact/js15-in.jsonld b/tests/compact/js15-in.jsonld new file mode 100644 index 00000000..9255f815 --- /dev/null +++ b/tests/compact/js15-in.jsonld @@ -0,0 +1,8 @@ +[{ + "http://example.org/vocab#value": [{ + "@value": [], + "@type": "@json" + }, + "non-JSON" + ] +}] diff --git a/tests/compact/js15-out.jsonld b/tests/compact/js15-out.jsonld new file mode 100644 index 00000000..fd291ac2 --- /dev/null +++ b/tests/compact/js15-out.jsonld @@ -0,0 +1,13 @@ +{ + "@context": { + "@version": 1.1, + "e": {"@id": "http://example.org/vocab#value"} + }, + "e": [ + { + "@type": "@json", + "@value": [] + }, + "non-JSON" + ] +} diff --git a/tests/compact/js16-context.jsonld b/tests/compact/js16-context.jsonld new file mode 100644 index 00000000..6a0627d9 --- /dev/null +++ b/tests/compact/js16-context.jsonld @@ -0,0 +1,7 @@ +{ + "@context": { + "@version": 1.1, + "e-json": {"@id": "http://example.org/vocab#value", "@type": "@json"}, + "e-non-json": {"@id": "http://example.org/vocab#value"} + } +} diff --git a/tests/compact/js16-in.jsonld b/tests/compact/js16-in.jsonld new file mode 100644 index 00000000..9255f815 --- /dev/null +++ b/tests/compact/js16-in.jsonld @@ -0,0 +1,8 @@ +[{ + "http://example.org/vocab#value": [{ + "@value": [], + "@type": "@json" + }, + "non-JSON" + ] +}] diff --git a/tests/compact/js16-out.jsonld b/tests/compact/js16-out.jsonld new file mode 100644 index 00000000..e2f6fb89 --- /dev/null +++ b/tests/compact/js16-out.jsonld @@ -0,0 +1,9 @@ +{ + "@context": { + "@version": 1.1, + "e-json": {"@id": "http://example.org/vocab#value", "@type": "@json"}, + "e-non-json": {"@id": "http://example.org/vocab#value"} + }, + "e-json": [], + "e-non-json": "non-JSON" +} diff --git a/tests/expand-manifest.jsonld b/tests/expand-manifest.jsonld index 57bc6b85..340b75b0 100644 --- a/tests/expand-manifest.jsonld +++ b/tests/expand-manifest.jsonld @@ -1811,6 +1811,20 @@ "purpose": "The value of @type in an expanded term definition object MUST be a string or null.", "input": "expand/er55-in.jsonld", "expectErrorCode": "invalid type mapping" + }, { + "@id": "#ter56", + "@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"], + "name": "Array not found for @json @set.", + "purpose": "The value for a @json @set term MUST be an array.", + "input": "expand/er56-in.jsonld", + "expectErrorCode": "invalid set or list object" + }, { + "@id": "#ter57", + "@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"], + "name": "Array not found for @json @list.", + "purpose": "The value for a @json @list term MUST be an array.", + "input": "expand/er57-in.jsonld", + "expectErrorCode": "invalid set or list object" }, { "@id": "#tes01", "@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"], @@ -2083,6 +2097,62 @@ "input": "expand/js23-in.jsonld", "expect": "expand/js23-out.jsonld", "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#tjs24", + "@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"], + "name": "Expand JSON literal (one JSON literal).", + "purpose": "Tests expanding property with @type @json (one JSON literal).", + "input": "expand/js24-in.jsonld", + "expect": "expand/js24-out.jsonld", + "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#tjs25", + "@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"], + "name": "Expand JSON literal (two JSON literals).", + "purpose": "Tests expanding property with @type @json (two JSON literals).", + "input": "expand/js25-in.jsonld", + "expect": "expand/js25-out.jsonld", + "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#tjs26", + "@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"], + "name": "Expand JSON literal (JSON literal and non-JSON).", + "purpose": "Tests expanding property with @type @json (JSON literal and non-JSON).", + "input": "expand/js26-in.jsonld", + "expect": "expand/js26-out.jsonld", + "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#tjs27", + "@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"], + "name": "Expand JSON literal (duplicate JSON literals).", + "purpose": "Tests expanding property with @type @json (dupcliate JSON literals).", + "input": "expand/js27-in.jsonld", + "expect": "expand/js27-out.jsonld", + "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#tjs28", + "@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"], + "name": "Expand array-like value with @json and no @set/@list in @context.", + "purpose": "Tests expanding array-like value with @json and no @set/@list in @context.", + "input": "expand/js28-in.jsonld", + "expect": "expand/js28-out.jsonld", + "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#tjs29", + "@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"], + "name": "Expand array-like value with @json and @set in @context.", + "purpose": "Tests expanding array-like value with @json and @set in @context.", + "input": "expand/js29-in.jsonld", + "expect": "expand/js29-out.jsonld", + "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#tjs30", + "@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"], + "name": "Expand array-like value with @json and @list in @context.", + "purpose": "Tests expanding array-like value with @json and @list in @context.", + "input": "expand/js30-in.jsonld", + "expect": "expand/js30-out.jsonld", + "option": {"specVersion": "json-ld-1.1"} }, { "@id": "#tl001", "@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"], diff --git a/tests/expand/er56-in.jsonld b/tests/expand/er56-in.jsonld new file mode 100644 index 00000000..07e6339b --- /dev/null +++ b/tests/expand/er56-in.jsonld @@ -0,0 +1,10 @@ +{ + "@context": { + "prop": { + "@id": "ex:prop", + "@type": "@json", + "@container": "@set" + } + }, + "prop": "value" +} diff --git a/tests/expand/er57-in.jsonld b/tests/expand/er57-in.jsonld new file mode 100644 index 00000000..3ea8be4c --- /dev/null +++ b/tests/expand/er57-in.jsonld @@ -0,0 +1,10 @@ +{ + "@context": { + "prop": { + "@id": "ex:prop", + "@type": "@json", + "@container": "@list" + } + }, + "prop": "value" +} diff --git a/tests/expand/js24-in.jsonld b/tests/expand/js24-in.jsonld new file mode 100644 index 00000000..e62286bf --- /dev/null +++ b/tests/expand/js24-in.jsonld @@ -0,0 +1,3 @@ +{ + "http://example.org/vocab#null": {"@value": ["JSON"], "@type": "@json"} +} diff --git a/tests/expand/js24-out.jsonld b/tests/expand/js24-out.jsonld new file mode 100644 index 00000000..a0a7348b --- /dev/null +++ b/tests/expand/js24-out.jsonld @@ -0,0 +1,8 @@ +[{ + "http://example.org/vocab#null": [{ + "@type": "@json", + "@value": [ + "JSON" + ] + }] +}] diff --git a/tests/expand/js25-in.jsonld b/tests/expand/js25-in.jsonld new file mode 100644 index 00000000..84ff724c --- /dev/null +++ b/tests/expand/js25-in.jsonld @@ -0,0 +1,6 @@ +{ + "http://example.org/vocab#value": [ + {"@value": ["JSON1"], "@type": "@json"}, + {"@value": ["JSON2"], "@type": "@json"} + ] +} diff --git a/tests/expand/js25-out.jsonld b/tests/expand/js25-out.jsonld new file mode 100644 index 00000000..6e6ff887 --- /dev/null +++ b/tests/expand/js25-out.jsonld @@ -0,0 +1,13 @@ +[{ + "http://example.org/vocab#value": [{ + "@type": "@json", + "@value": [ + "JSON1" + ] + }, { + "@type": "@json", + "@value": [ + "JSON2" + ] + }] +}] diff --git a/tests/expand/js26-in.jsonld b/tests/expand/js26-in.jsonld new file mode 100644 index 00000000..3f11042f --- /dev/null +++ b/tests/expand/js26-in.jsonld @@ -0,0 +1,6 @@ +{ + "http://example.org/vocab#value": [ + {"@value": ["JSON"], "@type": "@json"}, + {"@value": "non-JSON"} + ] +} diff --git a/tests/expand/js26-out.jsonld b/tests/expand/js26-out.jsonld new file mode 100644 index 00000000..6251d232 --- /dev/null +++ b/tests/expand/js26-out.jsonld @@ -0,0 +1,10 @@ +[{ + "http://example.org/vocab#value": [{ + "@type": "@json", + "@value": [ + "JSON" + ] + }, { + "@value": "non-JSON" + }] +}] diff --git a/tests/expand/js27-in.jsonld b/tests/expand/js27-in.jsonld new file mode 100644 index 00000000..9d479f74 --- /dev/null +++ b/tests/expand/js27-in.jsonld @@ -0,0 +1,6 @@ +{ + "http://example.org/vocab#value": [ + {"@value": ["dup"], "@type": "@json"}, + {"@value": ["dup"], "@type": "@json"} + ] +} diff --git a/tests/expand/js27-out.jsonld b/tests/expand/js27-out.jsonld new file mode 100644 index 00000000..5e15b03c --- /dev/null +++ b/tests/expand/js27-out.jsonld @@ -0,0 +1,13 @@ +[{ + "http://example.org/vocab#value": [{ + "@type": "@json", + "@value": [ + "dup" + ] + }, { + "@type": "@json", + "@value": [ + "dup" + ] + }] +}] diff --git a/tests/expand/js28-in.jsonld b/tests/expand/js28-in.jsonld new file mode 100644 index 00000000..8a10ef58 --- /dev/null +++ b/tests/expand/js28-in.jsonld @@ -0,0 +1,7 @@ +{ + "@context": { + "@version": 1.1, + "e": {"@id": "ex:e", "@type": "@json"} + }, + "e": ["v1", "v2"] +} diff --git a/tests/expand/js28-out.jsonld b/tests/expand/js28-out.jsonld new file mode 100644 index 00000000..48880690 --- /dev/null +++ b/tests/expand/js28-out.jsonld @@ -0,0 +1,13 @@ +[ + { + "ex:e": [ + { + "@type": "@json", + "@value": [ + "v1", + "v2" + ] + } + ] + } +] diff --git a/tests/expand/js29-in.jsonld b/tests/expand/js29-in.jsonld new file mode 100644 index 00000000..a06649ee --- /dev/null +++ b/tests/expand/js29-in.jsonld @@ -0,0 +1,7 @@ +{ + "@context": { + "@version": 1.1, + "e": {"@id": "ex:e", "@type": "@json", "@container": "@set"} + }, + "e": ["v1", "v2"] +} diff --git a/tests/expand/js29-out.jsonld b/tests/expand/js29-out.jsonld new file mode 100644 index 00000000..55f2348b --- /dev/null +++ b/tests/expand/js29-out.jsonld @@ -0,0 +1,14 @@ +[ + { + "ex:e": [ + { + "@type": "@json", + "@value": "v1" + }, + { + "@type": "@json", + "@value": "v2" + } + ] + } +] diff --git a/tests/expand/js30-in.jsonld b/tests/expand/js30-in.jsonld new file mode 100644 index 00000000..aaa153d2 --- /dev/null +++ b/tests/expand/js30-in.jsonld @@ -0,0 +1,7 @@ +{ + "@context": { + "@version": 1.1, + "e": {"@id": "ex:e", "@type": "@json", "@container": "@list"} + }, + "e": ["v1", "v2"] +} diff --git a/tests/expand/js30-out.jsonld b/tests/expand/js30-out.jsonld new file mode 100644 index 00000000..47e6e973 --- /dev/null +++ b/tests/expand/js30-out.jsonld @@ -0,0 +1,18 @@ +[ + { + "ex:e": [ + { + "@list": [ + { + "@type": "@json", + "@value": "v1" + }, + { + "@type": "@json", + "@value": "v2" + } + ] + } + ] + } +] diff --git a/tests/fromRdf-manifest.jsonld b/tests/fromRdf-manifest.jsonld index 1764a682..90c8cadf 100644 --- a/tests/fromRdf-manifest.jsonld +++ b/tests/fromRdf-manifest.jsonld @@ -379,6 +379,22 @@ "input": "fromRdf/js11-in.nq", "expect": "fromRdf/js11-out.jsonld", "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#tjs12", + "@type": ["jld:PositiveEvaluationTest", "jld:FromRDFTest"], + "name": "JSON literals (strings)", + "purpose": "Tests creating property with multiple rdf:type rdf:JSON to a JSON literal (null).", + "input": "fromRdf/js12-in.nq", + "expect": "fromRdf/js12-out.jsonld", + "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#tjs13", + "@type": ["jld:PositiveEvaluationTest", "jld:FromRDFTest"], + "name": "Mixed JSON literals and non-JSON", + "purpose": "Tests creating property with mixed rdf:type rdf:JSON and non-JSON.", + "input": "fromRdf/js13-in.nq", + "expect": "fromRdf/js13-out.jsonld", + "option": {"specVersion": "json-ld-1.1"} }, { "@id": "#tli01", "@type": ["jld:PositiveEvaluationTest", "jld:FromRDFTest"], diff --git a/tests/fromRdf/js12-in.nq b/tests/fromRdf/js12-in.nq new file mode 100644 index 00000000..8dddac6b --- /dev/null +++ b/tests/fromRdf/js12-in.nq @@ -0,0 +1,2 @@ + "[\"string1\"]"^^ . + "[\"string2\"]"^^ . diff --git a/tests/fromRdf/js12-out.jsonld b/tests/fromRdf/js12-out.jsonld new file mode 100644 index 00000000..9a0686ab --- /dev/null +++ b/tests/fromRdf/js12-out.jsonld @@ -0,0 +1,10 @@ +[{ + "@id": "http://example.org/vocab#id", + "http://example.org/vocab#multi": [{ + "@value": ["string1"], + "@type": "@json" + }, { + "@value": ["string2"], + "@type": "@json" + }] +}] diff --git a/tests/fromRdf/js13-in.nq b/tests/fromRdf/js13-in.nq new file mode 100644 index 00000000..394bb536 --- /dev/null +++ b/tests/fromRdf/js13-in.nq @@ -0,0 +1,2 @@ + "null"^^ . + . diff --git a/tests/fromRdf/js13-out.jsonld b/tests/fromRdf/js13-out.jsonld new file mode 100644 index 00000000..e2bcda7e --- /dev/null +++ b/tests/fromRdf/js13-out.jsonld @@ -0,0 +1,9 @@ +[{ + "@id": "http://example.org/vocab#id", + "http://example.org/vocab#mixed": [{ + "@value": null, + "@type": "@json" + }, { + "@id": "http://example.org/vocab#value" + }] +}] diff --git a/tests/toRdf-manifest.jsonld b/tests/toRdf-manifest.jsonld index e13eab49..05402f3d 100644 --- a/tests/toRdf-manifest.jsonld +++ b/tests/toRdf-manifest.jsonld @@ -2237,6 +2237,20 @@ "purpose": "The value of @type in an expanded term definition object MUST be a string or null.", "input": "toRdf/er55-in.jsonld", "expectErrorCode": "invalid type mapping" + }, { + "@id": "#ter56", + "@type": ["jld:NegativeEvaluationTest", "jld:ToRDFTest" ], + "name": "Array not found for @json @list.", + "purpose": "The value for a @json @list term MUST be an array.", + "input": "toRdf/er57-in.jsonld", + "expectErrorCode": "invalid set or list object" + }, { + "@id": "#ter57", + "@type": ["jld:NegativeEvaluationTest", "jld:ToRDFTest" ], + "name": "Array not found for @json @set.", + "purpose": "The value for a @json @set term MUST be an array.", + "input": "toRdf/er56-in.jsonld", + "expectErrorCode": "invalid set or list object" }, { "@id": "#tin01", "@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"], @@ -2493,6 +2507,62 @@ "input": "toRdf/js23-in.jsonld", "expect": "toRdf/js23-out.nq", "option": {"specVersion": "json-ld-1.1", "useJCS": true} + }, { + "@id": "#tjs24", + "@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"], + "name": "Transform JSON literal (one JSON literal).", + "purpose": "Tests transforming property with @type @json to a JSON literal (one JSON literal).", + "input": "toRdf/js24-in.jsonld", + "expect": "toRdf/js24-out.nq", + "option": {"specVersion": "json-ld-1.1", "useJCS": true} + }, { + "@id": "#tjs25", + "@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"], + "name": "Transform JSON literal (two JSON literals).", + "purpose": "Tests transforming property with @type @json to a JSON literal (two JSON literals).", + "input": "toRdf/js25-in.jsonld", + "expect": "toRdf/js25-out.nq", + "option": {"specVersion": "json-ld-1.1", "useJCS": true} + }, { + "@id": "#tjs26", + "@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"], + "name": "Transform JSON literal (JSON literal and non-JSON).", + "purpose": "Tests transforming property with @type @json to a JSON literal (JSON literal and non-JSON).", + "input": "toRdf/js26-in.jsonld", + "expect": "toRdf/js26-out.nq", + "option": {"specVersion": "json-ld-1.1", "useJCS": true} + }, { + "@id": "#tjs27", + "@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"], + "name": "Transform JSON literal (duplicate JSON literals).", + "purpose": "Tests transforming property with @type @json to a JSON literal (duplicate JSON literals).", + "input": "toRdf/js27-in.jsonld", + "expect": "toRdf/js27-out.nq", + "option": {"specVersion": "json-ld-1.1", "useJCS": true} + }, { + "@id": "#tjs28", + "@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"], + "name": "Transform array-like value with @json and no @set/@list in @context.", + "purpose": "Tests transforming array-like value with @json and no @set/@list in @context.", + "input": "toRdf/js28-in.jsonld", + "expect": "toRdf/js28-out.nq", + "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#tjs29", + "@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"], + "name": "Transform array-like value with @json and @set in @context.", + "purpose": "Tests transforming array-like value with @json and @set in @context.", + "input": "toRdf/js29-in.jsonld", + "expect": "toRdf/js29-out.nq", + "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#tjs30", + "@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"], + "name": "Transform array-like value with @json and @list in @context.", + "purpose": "Tests transforming array-like value with @json and @list in @context.", + "input": "toRdf/js30-in.jsonld", + "expect": "toRdf/js30-out.nq", + "option": {"specVersion": "json-ld-1.1"} }, { "@id": "#tli01", "@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"], diff --git a/tests/toRdf/er56-in.jsonld b/tests/toRdf/er56-in.jsonld new file mode 100644 index 00000000..07e6339b --- /dev/null +++ b/tests/toRdf/er56-in.jsonld @@ -0,0 +1,10 @@ +{ + "@context": { + "prop": { + "@id": "ex:prop", + "@type": "@json", + "@container": "@set" + } + }, + "prop": "value" +} diff --git a/tests/toRdf/er57-in.jsonld b/tests/toRdf/er57-in.jsonld new file mode 100644 index 00000000..3ea8be4c --- /dev/null +++ b/tests/toRdf/er57-in.jsonld @@ -0,0 +1,10 @@ +{ + "@context": { + "prop": { + "@id": "ex:prop", + "@type": "@json", + "@container": "@list" + } + }, + "prop": "value" +} diff --git a/tests/toRdf/js24-in.jsonld b/tests/toRdf/js24-in.jsonld new file mode 100644 index 00000000..6031cc67 --- /dev/null +++ b/tests/toRdf/js24-in.jsonld @@ -0,0 +1,3 @@ +{ + "http://example.org/vocab#value": {"@value": ["JSON"], "@type": "@json"} +} diff --git a/tests/toRdf/js24-out.nq b/tests/toRdf/js24-out.nq new file mode 100644 index 00000000..8bf2d7a4 --- /dev/null +++ b/tests/toRdf/js24-out.nq @@ -0,0 +1 @@ +_:b0 "[\"JSON\"]"^^ . diff --git a/tests/toRdf/js25-in.jsonld b/tests/toRdf/js25-in.jsonld new file mode 100644 index 00000000..84ff724c --- /dev/null +++ b/tests/toRdf/js25-in.jsonld @@ -0,0 +1,6 @@ +{ + "http://example.org/vocab#value": [ + {"@value": ["JSON1"], "@type": "@json"}, + {"@value": ["JSON2"], "@type": "@json"} + ] +} diff --git a/tests/toRdf/js25-out.nq b/tests/toRdf/js25-out.nq new file mode 100644 index 00000000..53af01e9 --- /dev/null +++ b/tests/toRdf/js25-out.nq @@ -0,0 +1,2 @@ +_:b0 "[\"JSON1\"]"^^ . +_:b0 "[\"JSON2\"]"^^ . diff --git a/tests/toRdf/js26-in.jsonld b/tests/toRdf/js26-in.jsonld new file mode 100644 index 00000000..3f11042f --- /dev/null +++ b/tests/toRdf/js26-in.jsonld @@ -0,0 +1,6 @@ +{ + "http://example.org/vocab#value": [ + {"@value": ["JSON"], "@type": "@json"}, + {"@value": "non-JSON"} + ] +} diff --git a/tests/toRdf/js26-out.nq b/tests/toRdf/js26-out.nq new file mode 100644 index 00000000..cb658a4c --- /dev/null +++ b/tests/toRdf/js26-out.nq @@ -0,0 +1,2 @@ +_:b0 "[\"JSON\"]"^^ . +_:b0 "non-JSON" . diff --git a/tests/toRdf/js27-in.jsonld b/tests/toRdf/js27-in.jsonld new file mode 100644 index 00000000..a0a817f2 --- /dev/null +++ b/tests/toRdf/js27-in.jsonld @@ -0,0 +1,6 @@ +{ + "http://example.org/vocab#value": [ + {"@value": [{"dup": true}], "@type": "@json"}, + {"@value": [{"dup": true}], "@type": "@json"} + ] +} diff --git a/tests/toRdf/js27-out.nq b/tests/toRdf/js27-out.nq new file mode 100644 index 00000000..6b84ec97 --- /dev/null +++ b/tests/toRdf/js27-out.nq @@ -0,0 +1 @@ +_:b0 "[{\"dup\":true}]"^^ . diff --git a/tests/toRdf/js28-in.jsonld b/tests/toRdf/js28-in.jsonld new file mode 100644 index 00000000..8a10ef58 --- /dev/null +++ b/tests/toRdf/js28-in.jsonld @@ -0,0 +1,7 @@ +{ + "@context": { + "@version": 1.1, + "e": {"@id": "ex:e", "@type": "@json"} + }, + "e": ["v1", "v2"] +} diff --git a/tests/toRdf/js28-out.nq b/tests/toRdf/js28-out.nq new file mode 100644 index 00000000..379870bb --- /dev/null +++ b/tests/toRdf/js28-out.nq @@ -0,0 +1 @@ +_:b0 "[\"v1\",\"v2\"]"^^ . diff --git a/tests/toRdf/js29-in.jsonld b/tests/toRdf/js29-in.jsonld new file mode 100644 index 00000000..a06649ee --- /dev/null +++ b/tests/toRdf/js29-in.jsonld @@ -0,0 +1,7 @@ +{ + "@context": { + "@version": 1.1, + "e": {"@id": "ex:e", "@type": "@json", "@container": "@set"} + }, + "e": ["v1", "v2"] +} diff --git a/tests/toRdf/js29-out.nq b/tests/toRdf/js29-out.nq new file mode 100644 index 00000000..17b54b47 --- /dev/null +++ b/tests/toRdf/js29-out.nq @@ -0,0 +1,2 @@ +_:b0 "\"v1\""^^ . +_:b0 "\"v2\""^^ . diff --git a/tests/toRdf/js30-in.jsonld b/tests/toRdf/js30-in.jsonld new file mode 100644 index 00000000..aaa153d2 --- /dev/null +++ b/tests/toRdf/js30-in.jsonld @@ -0,0 +1,7 @@ +{ + "@context": { + "@version": 1.1, + "e": {"@id": "ex:e", "@type": "@json", "@container": "@list"} + }, + "e": ["v1", "v2"] +} diff --git a/tests/toRdf/js30-out.nq b/tests/toRdf/js30-out.nq new file mode 100644 index 00000000..34766071 --- /dev/null +++ b/tests/toRdf/js30-out.nq @@ -0,0 +1,5 @@ +_:b0 _:b1 . +_:b1 "\"v1\""^^ . +_:b1 _:b2 . +_:b2 "\"v2\""^^ . +_:b2 .