-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add JSON literal tests. #559
base: main
Are you sure you want to change the base?
Conversation
- 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.
ad04884
to
8ec7642
Compare
Some of these assume changes to the algorithms that will need their own PRs:
|
Addresses #560. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
editorial, human-facing typo
Co-authored-by: Ted Thibodeau Jr <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree with tests er57 and er58 (in expand and toRdf) -- see my comments inline.
The rests of the tests make sense, but I agree with @gkellogg that some of them are breaking changes.
"@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).", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"purpose": "Tests compacting property with @type @json to a JSON literal (empty array).", | |
"purpose": "Tests compacting property with @type @json to a JSON literal (array with string).", |
"@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).", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"purpose": "Tests compacting property with @type @json to a JSON literal (array with string).", | |
"purpose": "Tests compacting property with @type @json to a JSON literal (empty array).", |
}, { | ||
"@id": "#ter58", | ||
"@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/er57-in.jsonld", | ||
"expectErrorCode": "invalid set or list object" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}, { | |
"@id": "#ter58", | |
"@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/er57-in.jsonld", | |
"expectErrorCode": "invalid set or list object" |
Duplicate id with the next one, and duplicate content with the previous one.
"@id": "#ter57", | ||
"@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/er57-in.jsonld", | ||
"expectErrorCode": "invalid set or list object" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I this test is accepted, it should have counterparts with other values for @type
(ex:datatype
, @id
), and without any @type
. I see no reason why "@type": "@json"
should behave differently.
But more generally, I don't think that this test should be accepted nor that this behavior should be required. There are many other situations where parts of the context are ignored if the encountered value is not of the expected kind. For example, @type
coertion is ignored if the value of the property is not a JSON scalar.
}, { | ||
"@id": "#ter58", | ||
"@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/er58-in.jsonld", | ||
"expectErrorCode": "invalid set or list object" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above (for ter57
): I don't think that this test should be accepted.
I concur that having a simple value converted to an RDF list is a bit counter-intuitive, but it follows the principle that, in JSON-LD, "prop": val
and "prop": [val]
are equivalent.
"name": "JSON literals (strings)", | ||
"purpose": "Tests creating property with multiple rdf:type rdf:JSON to a JSON literal (null).", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the 'name' is not accurate, and I don't understand the sentence under 'purpose' (using "rdf:type
" to talk about the datatype is very confusing).
"name": "JSON literals (strings)", | |
"purpose": "Tests creating property with multiple rdf:type rdf:JSON to a JSON literal (null).", | |
"name": "Multiple JSON literals", | |
"purpose": "Tests creating property with multiple literal values of datatype rdf:JSON", |
"name": "Mixed JSON literals and non-JSON", | ||
"purpose": "Tests creating property with mixed rdf:type rdf:JSON and non-JSON.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"name": "Mixed JSON literals and non-JSON", | |
"purpose": "Tests creating property with mixed rdf:type rdf:JSON and non-JSON.", | |
"name": "Mixed JSON literal and non-JSON", | |
"purpose": "Tests creating property with mixed values: literal of datatype rdf:type and non-JSON.", |
Actually, the test is mixing a literal of datatype rdf:JSON
and an IRI, so the text is still a bit misleading (I would expect "non-JSON" to mean "a literal with another datatype than rdf:JSON
).
}, { | ||
"@id": "#ter57", | ||
"@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": "#ter58", | ||
"@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/er58-in.jsonld", | ||
"expectErrorCode": "invalid set or list object" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}, { | |
"@id": "#ter57", | |
"@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": "#ter58", | |
"@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/er58-in.jsonld", | |
"expectErrorCode": "invalid set or list object" |
For the reasons explained above (in expand-manifest.jsonld), I believe that these tests should not be accepted.
}, { | ||
"@id": "#tej01", | ||
"@type": ["jld:NegativeEvaluationTest", "jld:CompactTest"], | ||
"name": "Multiple JSON values for a JSON literal properties", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Goes with change elsewhere
"name": "Multiple JSON values for a JSON literal properties", | |
"name": "Multiple JSON values for a JSON literal property", |
@type
of@json
is used, the JSON may be an array, and the interaction with a@container
of@set
and@list
.@json
and@set
with a JSON array.multiple JSON literals
error code when trying to add multiple JSON literals as values for a property not declared a@set
.NOTE: This is a work-in-progress that needs feedback. HTML rebuild has not yet been done.
Please put major discussion in the issue that links here as this PR may need to be replaced.