W3C

Expansion

This is an HTML version of a test manifest. The JSON-LD version of this manifest may be found at html-manifest.jsonld. The manifest vocabulary is described in the JSON-LD Test Vocabulary (JSON-LD, Turtle) and is based on the RDF Test Vocabulary.

The JSON-LD Test Suite is a set of tests that can be used to verify JSON-LD Processor conformance to the set of specifications that constitute JSON-LD. The goal of the suite is to provide an easy and comprehensive JSON-LD testing solution for developers creating JSON-LD Processors.

General instructions for running the JSON-LD Test suites

compact tests have input, expected and context documents.

The expected results can be compared using JSON-LD object comparison with the processor output. Additionally, if the ordered option is not set, result should be expanded and compared with the expanded expected document also using JSON-LD object comparison.

For NegativeEvaluationTests, the result is a string associated with the expected error code.

expand tests have input and expected documents.

The expected results can be compared using JSON-LD object comparison with the processor output.

For NegativeEvaluationTests, the result is a string associated with the expected error code.

html tests have input and expected documents and an optional context document.

The expected results can be compared using JSON-LD object comparison with the processor output after potentially remapping blank node identifiers (see below). Additionally, if the result is compacted and the ordered option is not set, result should be expanded and compared with the expanded expected document also using JSON-LD object comparison.

For NegativeEvaluationTests, the result is a string associated with the expected error code.

flatten tests have input and expected documents and an optional context document.

The expected results can be compared using JSON-LD object comparison with the processor output after potentially remapping blank node identifiers (see below). Additionally, if the result is compacted and the ordered option is not set, result should be expanded and compared with the expanded expected document also using JSON-LD object comparison.

For NegativeEvaluationTests, the result is a string associated with the expected error code.

Unless processingMode is set explicitly in a test entry, processingMode is compatible with both json-ld-1.0 and json-ld-1.1.

Test results that include a context input presume that the context is provided locally, and not from the referenced location, thus the results will include the content of the context file, rather than a reference.

Developers are encouraged to make a local copy of the test suite (available on GitHub) and simulate the behavior of fetching test files remotely and setting HTTP headers as described in a particular test entry.

JSON-LD Object comparison

If algorithms are invoked with the ordered flag set to true, simple JSON Object comparison may be used, as the order of all arrays will be preserved (except for fromRdf, unless the input quads are also ordered). If ordered is false, then the following algorithm will ensure arrays other than values of @list are compared without regard to order.

JSON-LD Object comparison compares JSON objects, arrays, and values recursively for equality.

Note that some tests require re-expansion and comparison, as list values may exist as values of properties that have @container: @list and the comparison algorithm will not consider ordering significant.

Running tests

The top-level manifest references the specific test manifests, which in turn reference each test associated with a particular type of behavior. Implementations create their own infrastructure for running the test suite. In particular, the following should be considered:

Contributing Tests

If you would like to contribute a new test or a fix to an existing test, please follow these steps:

  1. Notify the JSON-LD mailing list, public-json-ld-wg@w3.org, that you will be creating a new test or fix and the purpose of the change.
  2. Clone the git repository: git://github.com/w3c/json-ld-api.git
  3. Make your changes and submit them via github, or via a 'git format-patch' to the JSON-LD Working Group mailing list.

Distribution

Distributed under the W3C Test Suite License. To contribute to a W3C Test Suite, see the policies and contribution forms.

Disclaimer

UNDER THE EXCLUSIVE LICENSE, THIS DOCUMENT AND ALL DOCUMENTS, TESTS AND SOFTWARE THAT LINK THIS STATEMENT ARE PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE; THAT THE CONTENTS OF THE DOCUMENT ARE SUITABLE FOR ANY PURPOSE; NOR THAT THE IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE DOCUMENT OR THE PERFORMANCE OR IMPLEMENTATION OF THE CONTENTS THEREOF.

baseIri
https://w3c.github.io/json-ld-api/tests/

JSON-LD HTML tests

Test sequence:

Test te001 Expands embedded JSON-LD script element
id
#te001
Type
jld:PositiveEvaluationTest, jld:ExpandTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML
input
html/e001-in.html
expect
html/e001-out.jsonld
Options
specVersion
json-ld-1.1
Test te002 Expands first embedded JSON-LD script element
id
#te002
Type
jld:PositiveEvaluationTest, jld:ExpandTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML
input
html/e002-in.html
expect
html/e002-out.jsonld
Options
specVersion
json-ld-1.1
Test te003 Expands targeted JSON-LD script element
id
#te003
Type
jld:PositiveEvaluationTest, jld:ExpandTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML with fragment identifier
input
html/e003-in.html#second
expect
html/e003-out.jsonld
Options
specVersion
json-ld-1.1
Test te004 Expands all embedded JSON-LD script elements with extractAllScripts option
id
#te004
Type
jld:PositiveEvaluationTest, jld:ExpandTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML extracting all elements
input
html/e004-in.html
expect
html/e004-out.jsonld
Options
specVersion
json-ld-1.1
extractAllScripts
true
Test te005 Expands multiple embedded JSON-LD script elements where one is an array
id
#te005
Type
jld:PositiveEvaluationTest, jld:ExpandTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML extracting all elements with array
input
html/e005-in.html
expect
html/e005-out.jsonld
Options
specVersion
json-ld-1.1
extractAllScripts
true
Test te006 Expands as empty with no embedded JSON-LD script elements
id
#te006
Type
jld:PositiveEvaluationTest, jld:ExpandTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML when none exist
input
html/e006-in.html
expect
html/e006-out.jsonld
Options
specVersion
json-ld-1.1
Test te007 Expands as empty with no embedded JSON-LD script elements and extractAllScripts
id
#te007
Type
jld:PositiveEvaluationTest, jld:ExpandTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML when none exist extracting all elements
input
html/e007-in.html
expect
html/e007-out.jsonld
Options
specVersion
json-ld-1.1
extractAllScripts
true
Test te010 Expands embedded JSON-LD script element with HTML character references
id
#te010
Type
jld:PositiveEvaluationTest, jld:ExpandTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML with character references
input
html/e010-in.html
expect
html/e010-out.jsonld
Options
specVersion
json-ld-1.1
Test te011 Errors if no element found at target
id
#te011
Type
jld:NegativeEvaluationTest, jld:ExpandTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML with fragment identifier that doesn't exist
input
html/e011-in.html#third
expect
invalid script element
Options
specVersion
json-ld-1.1
Test te012 Errors if targeted element is not a script element
id
#te012
Type
jld:NegativeEvaluationTest, jld:ExpandTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML which isn't a script element
input
html/e012-in.html#first
expect
invalid script element
Options
specVersion
json-ld-1.1
Test te013 Errors if targeted element does not have type application/ld+json
id
#te013
Type
jld:NegativeEvaluationTest, jld:ExpandTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML with wrong type
input
html/e013-in.html#first
expect
invalid script element
Options
specVersion
json-ld-1.1
Test te014 Errors if uncommented script text contains comment
id
#te014
Type
jld:NegativeEvaluationTest, jld:ExpandTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML with comments leftover
input
html/e014-in.html
expect
invalid script element
Options
specVersion
json-ld-1.1
Test te015 Errors if end comment missing
id
#te015
Type
jld:NegativeEvaluationTest, jld:ExpandTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML with unballanced comments
input
html/e015-in.html
expect
invalid script element
Options
specVersion
json-ld-1.1
Test te016 Errors if start comment missing
id
#te016
Type
jld:NegativeEvaluationTest, jld:ExpandTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML with unballanced comments
input
html/e016-in.html
expect
invalid script element
Options
specVersion
json-ld-1.1
Test te017 Errors if uncommented script is not valid JSON
id
#te017
Type
jld:NegativeEvaluationTest, jld:ExpandTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML which is invalid JSON
input
html/e017-in.html
expect
invalid script element
Options
specVersion
json-ld-1.1
Test te018 Expands embedded JSON-LD script element relative to document base
id
#te018
Type
jld:PositiveEvaluationTest, jld:ExpandTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML
input
html/e018-in.html
expect
html/e018-out.jsonld
Options
specVersion
json-ld-1.1
Test te019 Expands embedded JSON-LD script element relative to base option
id
#te019
Type
jld:PositiveEvaluationTest, jld:ExpandTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML
input
html/e019-in.html
expect
html/e019-out.jsonld
Options
specVersion
json-ld-1.1
base
http://a.example.com/doc
Test te020 Expands embedded JSON-LD script element relative to HTML base
id
#te020
Type
jld:PositiveEvaluationTest, jld:ExpandTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML
input
html/e020-in.html
expect
html/e020-out.jsonld
Options
specVersion
json-ld-1.1
base
http://a.example.com/doc
Test te021 Expands embedded JSON-LD script element relative to relative HTML base
id
#te021
Type
jld:PositiveEvaluationTest, jld:ExpandTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML
input
html/e021-in.html
expect
html/e021-out.jsonld
Options
specVersion
json-ld-1.1
base
http://a.example.com/doc
Test te022 Expands targeted JSON-LD script element with fragment and HTML base
id
#te022
Type
jld:PositiveEvaluationTest, jld:ExpandTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML with fragment identifier
input
html/e022-in.html#second
expect
html/e022-out.jsonld
Options
specVersion
json-ld-1.1
Test tc001 Compacts embedded JSON-LD script element
id
#tc001
Type
jld:PositiveEvaluationTest, jld:CompactTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML
input
html/c001-in.html
context
html/c001-context.jsonld
expect
html/c001-out.jsonld
Options
specVersion
json-ld-1.1
Test tc002 Compacts first embedded JSON-LD script element
id
#tc002
Type
jld:PositiveEvaluationTest, jld:CompactTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML
input
html/c002-in.html
context
html/c002-context.jsonld
expect
html/c002-out.jsonld
Options
specVersion
json-ld-1.1
Test tc003 Compacts targeted JSON-LD script element
id
#tc003
Type
jld:PositiveEvaluationTest, jld:CompactTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML with fragment identifier
input
html/c003-in.html#second
context
html/c003-context.jsonld
expect
html/c003-out.jsonld
Options
specVersion
json-ld-1.1
Test tc004 Compacts all embedded JSON-LD script elements with extractAllScripts option
id
#tc004
Type
jld:PositiveEvaluationTest, jld:CompactTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML extracting all elements
input
html/c004-in.html
context
html/c004-context.jsonld
expect
html/c004-out.jsonld
Options
specVersion
json-ld-1.1
extractAllScripts
true
Test tf001 Flattens embedded JSON-LD script element
id
#tf001
Type
jld:PositiveEvaluationTest, jld:FlattenTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML
input
html/f001-in.html
context
html/f001-context.jsonld
expect
html/f001-out.jsonld
Options
specVersion
json-ld-1.1
Test tf002 Flattens first embedded JSON-LD script element
id
#tf002
Type
jld:PositiveEvaluationTest, jld:FlattenTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML
input
html/f002-in.html
context
html/f002-context.jsonld
expect
html/f002-out.jsonld
Options
specVersion
json-ld-1.1
extractAllScripts
false
Test tf003 Flattens targeted JSON-LD script element
id
#tf003
Type
jld:PositiveEvaluationTest, jld:FlattenTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML with fragment identifier
input
html/f003-in.html#second
context
html/f003-context.jsonld
expect
html/f003-out.jsonld
Options
specVersion
json-ld-1.1
Test tf004 Flattens all script elements by default
id
#tf004
Type
jld:PositiveEvaluationTest, jld:FlattenTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML with fragment identifier
input
html/f004-in.html
context
html/f004-context.jsonld
expect
html/f004-out.jsonld
Options
specVersion
json-ld-1.1
Test tr001 Transforms embedded JSON-LD script element
id
#tr001
Type
jld:PositiveEvaluationTest, jld:ToRDFTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML
input
html/r001-in.html
expect
html/r001-out.nq
Options
specVersion
json-ld-1.1
Test tr002 Transforms first embedded JSON-LD script element
id
#tr002
Type
jld:PositiveEvaluationTest, jld:ToRDFTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML
input
html/r002-in.html
expect
html/r002-out.nq
Options
specVersion
json-ld-1.1
extractAllScripts
false
Test tr003 Transforms targeted JSON-LD script element
id
#tr003
Type
jld:PositiveEvaluationTest, jld:ToRDFTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML with fragment identifier
input
html/r003-in.html#second
expect
html/r003-out.nq
Options
specVersion
json-ld-1.1
Test tr004 Expands all embedded JSON-LD script elements with extractAllScripts option
id
#tr004
Type
jld:PositiveEvaluationTest, jld:ToRDFTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML extracting all elements
input
html/r004-in.html
expect
html/r004-out.nq
Options
specVersion
json-ld-1.1
extractAllScripts
true
Test tr005 Expands multiple embedded JSON-LD script elements where one is an array
id
#tr005
Type
jld:PositiveEvaluationTest, jld:ToRDFTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML extracting all elements with array
input
html/r005-in.html
expect
html/r005-out.nq
Options
specVersion
json-ld-1.1
extractAllScripts
true
Test tr006 Expands as empty with no embedded JSON-LD script elements
id
#tr006
Type
jld:PositiveEvaluationTest, jld:ToRDFTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML when none exist
input
html/r006-in.html
expect
html/r006-out.nq
Options
specVersion
json-ld-1.1
Test tr007 Expands as empty with no embedded JSON-LD script elements and extractAllScripts
id
#tr007
Type
jld:PositiveEvaluationTest, jld:ToRDFTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML when none exist extracting all elements
input
html/r007-in.html
expect
html/r007-out.nq
Options
specVersion
json-ld-1.1
extractAllScripts
true
Test tr010 Expands embedded JSON-LD script element with HTML character references
id
#tr010
Type
jld:PositiveEvaluationTest, jld:ToRDFTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML with character references
input
html/r010-in.html
expect
html/r010-out.nq
Options
specVersion
json-ld-1.1
Test tr011 Errors if no element found at target
id
#tr011
Type
jld:NegativeEvaluationTest, jld:ToRDFTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML with fragment identifier that doesn't exist
input
html/r011-in.html#third
expect
invalid script element
Options
specVersion
json-ld-1.1
Test tr012 Errors if targeted element is not a script element
id
#tr012
Type
jld:NegativeEvaluationTest, jld:ToRDFTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML which isn't a script element
input
html/r012-in.html#first
expect
invalid script element
Options
specVersion
json-ld-1.1
Test tr013 Errors if targeted element does not have type application/ld+json
id
#tr013
Type
jld:NegativeEvaluationTest, jld:ToRDFTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML with wrong type
input
html/r013-in.html#first
expect
invalid script element
Options
specVersion
json-ld-1.1
Test tr014 Errors if uncommented script text contains comment
id
#tr014
Type
jld:NegativeEvaluationTest, jld:ToRDFTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML with comments leftover
input
html/r014-in.html
expect
invalid script element
Options
specVersion
json-ld-1.1
Test tr015 Errors if end comment missing
id
#tr015
Type
jld:NegativeEvaluationTest, jld:ToRDFTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML with unballanced comments
input
html/r015-in.html
expect
invalid script element
Options
specVersion
json-ld-1.1
Test tr016 Errors if start comment missing
id
#tr016
Type
jld:NegativeEvaluationTest, jld:ToRDFTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML with unballanced comments
input
html/r016-in.html
expect
invalid script element
Options
specVersion
json-ld-1.1
Test tr017 Errors if uncommented script is not valid JSON
id
#tr017
Type
jld:NegativeEvaluationTest, jld:ToRDFTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML which is invalid JSON
input
html/r017-in.html
expect
invalid script element
Options
specVersion
json-ld-1.1
Test tr018 Expands embedded JSON-LD script element relative to document base
id
#tr018
Type
jld:PositiveEvaluationTest, jld:ToRDFTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML
input
html/r018-in.html
expect
html/r018-out.nq
Options
specVersion
json-ld-1.1
Test tr019 Expands embedded JSON-LD script element relative to base option
id
#tr019
Type
jld:PositiveEvaluationTest, jld:ToRDFTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML
input
html/r019-in.html
expect
html/r019-out.nq
Options
specVersion
json-ld-1.1
base
http://a.example.com/doc
Test tr020 Expands embedded JSON-LD script element relative to HTML base
id
#tr020
Type
jld:PositiveEvaluationTest, jld:ToRDFTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML
input
html/r020-in.html
expect
html/r020-out.nq
Options
specVersion
json-ld-1.1
base
http://a.example.com/doc
Test tr021 Expands embedded JSON-LD script element relative to relative HTML base
id
#tr021
Type
jld:PositiveEvaluationTest, jld:ToRDFTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML
input
html/r021-in.html
expect
html/r021-out.nq
Options
specVersion
json-ld-1.1
base
http://a.example.com/doc
Test tr022 Expands targeted JSON-LD script element with fragment and HTML base
id
#tr022
Type
jld:PositiveEvaluationTest, jld:ToRDFTest, jld:HtmlTest
Purpose
Tests embedded JSON-LD in HTML with fragment identifier
input
html/r022-in.html#second
expect
html/r022-out.nq
Options
specVersion
json-ld-1.1