From 84159ed92328c399014cfbd7534917599daf7aee Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Wed, 21 Feb 2024 02:22:39 -0500 Subject: [PATCH] Test protected flag retained during redefinition. - Add expand and toRdf tests to check protection flag is retained when a term is redefined the same as a protected term, and then redefined as something else, triggering a failure. - See 4.1.11 https://www.w3.org/TR/json-ld11/#protected-term-definitions about similar overrides that don't change semantics of the protected term. - See 4.2.2.27.2 https://www.w3.org/TR/json-ld-api/#algorithm-0 about retaining the value of protected flag. --- tests/expand-manifest.jsonld | 8 ++++++++ tests/expand/pr42-in.jsonld | 15 +++++++++++++++ tests/toRdf-manifest.jsonld | 8 ++++++++ tests/toRdf/pr42-in.jsonld | 15 +++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 tests/expand/pr42-in.jsonld create mode 100644 tests/toRdf/pr42-in.jsonld diff --git a/tests/expand-manifest.jsonld b/tests/expand-manifest.jsonld index c18f12bb..636ad35e 100644 --- a/tests/expand-manifest.jsonld +++ b/tests/expand-manifest.jsonld @@ -2843,6 +2843,14 @@ "option": {"specVersion": "json-ld-1.1"}, "input": "expand/pr41-in.jsonld", "expect": "expand/pr41-out.jsonld" + }, { + "@id": "#tpr42", + "@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"], + "name": "Fail if protected flag not retained during redefinition", + "purpose": "Check protected redefinition retains protected flag.", + "option": {"specVersion": "json-ld-1.1"}, + "input": "expand/pr42-in.jsonld", + "expectErrorCode": "protected term redefinition" }, { "@id": "#tso01", "@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"], diff --git a/tests/expand/pr42-in.jsonld b/tests/expand/pr42-in.jsonld new file mode 100644 index 00000000..3dd79f95 --- /dev/null +++ b/tests/expand/pr42-in.jsonld @@ -0,0 +1,15 @@ +{ + "@context": [ + { + "@protected": true, + "protected": "ex:protected" + }, + { + "protected": "ex:protected" + }, + { + "protected": "ex:unprotected" + } + ], + "protected": "fail / protection not retained during redefinition" +} diff --git a/tests/toRdf-manifest.jsonld b/tests/toRdf-manifest.jsonld index b5448d5f..3b25e3a0 100644 --- a/tests/toRdf-manifest.jsonld +++ b/tests/toRdf-manifest.jsonld @@ -3372,6 +3372,14 @@ "option": {"specVersion": "json-ld-1.1"}, "input": "toRdf/pr41-in.jsonld", "expect": "toRdf/pr41-out.nq" + }, { + "@id": "#tpr42", + "@type": ["jld:NegativeEvaluationTest", "jld:ToRDFTest"], + "name": "Fail if protected flag not retained during redefinition", + "purpose": "Check protected redefinition retains protected flag.", + "option": {"specVersion": "json-ld-1.1"}, + "input": "toRdf/pr42-in.jsonld", + "expectErrorCode": "protected term redefinition" }, { "@id": "#trt01", "@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"], diff --git a/tests/toRdf/pr42-in.jsonld b/tests/toRdf/pr42-in.jsonld new file mode 100644 index 00000000..3dd79f95 --- /dev/null +++ b/tests/toRdf/pr42-in.jsonld @@ -0,0 +1,15 @@ +{ + "@context": [ + { + "@protected": true, + "protected": "ex:protected" + }, + { + "protected": "ex:protected" + }, + { + "protected": "ex:unprotected" + } + ], + "protected": "fail / protection not retained during redefinition" +}