W3C

Flattening

This is an HTML version of a test manifest. The JSON-LD version of this manifest may be found at flatten-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.

The JSON-LD Framing Specification maintains it's own test suite.

General instructions for running the JSON-LD Test suites

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 Flattening tests.

Test sequence:

Test t0001 drop free-floating nodes
id
#t0001
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Flattening drops unreferenced nodes having only @id
input
flatten/0001-in.jsonld
expect
flatten/0001-out.jsonld
Test t0002 basic
id
#t0002
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Flattening terms with different types of values
input
flatten/0002-in.jsonld
expect
flatten/0002-out.jsonld
Test t0003 drop null and unmapped properties
id
#t0003
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Verifies that null values and unmapped properties are removed from expanded output
input
flatten/0003-in.jsonld
expect
flatten/0003-out.jsonld
Test t0004 optimize @set, keep empty arrays
id
#t0004
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Uses of @set are removed in expansion; values of @set, or just plain values which are empty arrays are retained
input
flatten/0004-in.jsonld
expect
flatten/0004-out.jsonld
Test t0005 do not expand aliased @id/@type
id
#t0005
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
If a keyword is aliased, it is not used when flattening
input
flatten/0005-in.jsonld
expect
flatten/0005-out.jsonld
Test t0006 alias keywords
id
#t0006
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Aliased keywords expand in resulting document
input
flatten/0006-in.jsonld
expect
flatten/0006-out.jsonld
Test t0007 date type-coercion
id
#t0007
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Expand strings to expanded value with @type: xsd:dateTime
input
flatten/0007-in.jsonld
expect
flatten/0007-out.jsonld
Test t0008 @value with @language
id
#t0008
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Keep expanded values with @language, drop non-conforming value objects containing just @language
input
flatten/0008-in.jsonld
expect
flatten/0008-out.jsonld
Test t0009 @graph with terms
id
#t0009
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Use of @graph to contain multiple nodes within array
input
flatten/0009-in.jsonld
expect
flatten/0009-out.jsonld
Test t0010 native types
id
#t0010
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Flattening native scalar retains native scalar within expanded value
input
flatten/0010-in.jsonld
expect
flatten/0010-out.jsonld
Test t0011 coerced @id
id
#t0011
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
A value of a property with @type: @id coercion expands to a node reference
input
flatten/0011-in.jsonld
expect
flatten/0011-out.jsonld
Test t0012 @graph with embed
id
#t0012
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Flattening objects containing chained objects flattens all objects
input
flatten/0012-in.jsonld
expect
flatten/0012-out.jsonld
Test t0013 flatten already expanded
id
#t0013
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Flattening an expanded/flattened document maintains input document
input
flatten/0013-in.jsonld
expect
flatten/0013-out.jsonld
Test t0014 @set of @value objects with keyword aliases
id
#t0014
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Flattening aliased @set and @value
input
flatten/0014-in.jsonld
expect
flatten/0014-out.jsonld
Options
specVersion
json-ld-1.0
Test t0015 collapse set of sets, keep empty lists
id
#t0015
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
An array of multiple @set nodes are collapsed into a single array
input
flatten/0015-in.jsonld
expect
flatten/0015-out.jsonld
Test t0016 context reset
id
#t0016
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Setting @context to null within an embedded object resets back to initial context state
input
flatten/0016-in.jsonld
expect
flatten/0016-out.jsonld
Test t0017 @graph and @id aliased
id
#t0017
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Flattening with @graph and @id aliases
input
flatten/0017-in.jsonld
expect
flatten/0017-out.jsonld
Test t0018 override default @language
id
#t0018
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
override default @language in terms; only language-tag strings
input
flatten/0018-in.jsonld
expect
flatten/0018-out.jsonld
Test t0019 remove @value = null
id
#t0019
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Flattening a value of null removes the value
input
flatten/0019-in.jsonld
expect
flatten/0019-out.jsonld
Test t0020 do not remove @graph if not at top-level
id
#t0020
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
@graph used under a node is retained
input
flatten/0020-in.jsonld
expect
flatten/0020-out.jsonld
Test t0021 do not remove @graph at top-level if not only property
id
#t0021
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
@graph used at the top level is retained if there are other properties
input
flatten/0021-in.jsonld
expect
flatten/0021-out.jsonld
Test t0022 flatten value with default language
id
#t0022
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Flattening with a default language applies that language to string values
input
flatten/0022-in.jsonld
expect
flatten/0022-out.jsonld
Test t0023 Flattening list/set with coercion
id
#t0023
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Flattening lists and sets with properties having coercion coerces list/set values
input
flatten/0023-in.jsonld
expect
flatten/0023-out.jsonld
Test t0024 Multiple contexts
id
#t0024
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Tests that contexts in an array are merged
input
flatten/0024-in.jsonld
expect
flatten/0024-out.jsonld
Test t0025 Problematic IRI flattening tests
id
#t0025
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Flattening different kinds of terms and Compact IRIs
input
flatten/0025-in.jsonld
expect
flatten/0025-out.jsonld
Test t0026 Term definition with @id: @type
id
#t0026
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Flattening term mapping to @type uses @type syntax
input
flatten/0026-in.jsonld
expect
flatten/0026-out.jsonld
Options
specVersion
json-ld-1.0
Test t0027 Duplicate values in @list and @set
id
#t0027
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Duplicate values in @list and @set are not merged
input
flatten/0027-in.jsonld
expect
flatten/0027-out.jsonld
Test t0028 Use @vocab in properties and @type but not in @id
id
#t0028
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
@vocab is used to compact properties and @type, but is not used for @id
input
flatten/0028-in.jsonld
expect
flatten/0028-out.jsonld
Test t0030 Language maps
id
#t0030
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Language Maps expand values to include @language
input
flatten/0030-in.jsonld
expect
flatten/0030-out.jsonld
Test t0031 type-coercion of native types
id
#t0031
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Flattening native types with type coercion adds the coerced type to an expanded value representation and retains the native value representation
input
flatten/0031-in.jsonld
expect
flatten/0031-out.jsonld
Test t0032 Null term and @vocab
id
#t0032
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Mapping a term to null decouples it from @vocab
input
flatten/0032-in.jsonld
expect
flatten/0032-out.jsonld
Test t0033 Using @vocab with with type-coercion
id
#t0033
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Verifies that terms can be defined using @vocab
input
flatten/0033-in.jsonld
expect
flatten/0033-out.jsonld
Test t0034 Multiple properties expanding to the same IRI
id
#t0034
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Verifies multiple values from separate terms are deterministically made multiple values of the IRI associated with the terms
input
flatten/0034-in.jsonld
expect
flatten/0034-out.jsonld
Test t0035 Language maps with @vocab, default language, and colliding property
id
#t0035
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Pathological tests of language maps
input
flatten/0035-in.jsonld
expect
flatten/0035-out.jsonld
Test t0036 Flattening @index
id
#t0036
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Flattening index maps for terms defined with @container: @index
input
flatten/0036-in.jsonld
expect
flatten/0036-out.jsonld
Test t0037 Flattening reverse properties
id
#t0037
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Flattening @reverse keeps @reverse
input
flatten/0037-in.jsonld
expect
flatten/0037-out.jsonld
Test t0038 Flattening blank node labels
id
#t0038
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Blank nodes are not relabeled during expansion
input
flatten/0038-in.jsonld
expect
flatten/0038-out.jsonld
Options
specVersion
json-ld-1.0
Test t0039 Using terms in a reverse-maps
id
#t0039
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Terms within @reverse are expanded
input
flatten/0039-in.jsonld
expect
flatten/0039-out.jsonld
Test t0040 language and index expansion on non-objects
id
#t0040
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Only invoke language and index map expansion if the value is a JSON object
input
flatten/0040-in.jsonld
expect
flatten/0040-out.jsonld
Test t0041 Free-floating sets and lists
id
#t0041
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Free-floating values in sets are removed, free-floating lists are removed completely
input
flatten/0041-in.jsonld
expect
flatten/0041-out.jsonld
Test t0042 List objects not equivalent
id
#t0042
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Lists objects are implicit unlabeled blank nodes and thus never equivalent
input
flatten/0042-in.jsonld
expect
flatten/0042-out.jsonld
Test t0043 Sample test manifest extract
id
#t0043
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Flatten a test manifest
input
flatten/0043-in.jsonld
expect
flatten/0043-out.jsonld
Test t0044 compactArrays option
id
#t0044
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Setting compactArrays to false causes single element arrays to be retained
input
flatten/0044-in.jsonld
context
flatten/0044-context.jsonld
expect
flatten/0044-out.jsonld
Options
compactArrays
false
Test t0045 Blank nodes with reverse properties
id
#t0045
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Proper (re-)labeling of blank nodes if used with reverse properties.
input
flatten/0045-in.jsonld
expect
flatten/0045-out.jsonld
Test t0046 Empty string as identifier
id
#t0046
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Usage of empty strings in identifiers needs special care when constructing the node map.
input
flatten/0046-in.jsonld
expect
flatten/0046-out.jsonld
Test t0047 Flatten using relative fragment identifier properly joins to base
id
#t0047
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Compacting a relative round-trips
input
flatten/0047-in.jsonld
expect
flatten/0047-out.jsonld
Options
base
http://example.org/
Test t0048 @list with embedded object
id
#t0048
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Node definitions contained within lists are flattend to top level.
input
flatten/0048-in.jsonld
expect
flatten/0048-out.jsonld
Test t0049 context with JavaScript Object property names
id
#t0049
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Flatten with context including JavaScript Object property names
input
flatten/0049-in.jsonld
expect
flatten/0049-out.jsonld
Test te001 Conflicting indexes
id
#te001
Type
jld:NegativeEvaluationTest, jld:FlattenTest
Purpose
Verifies that an exception is raised in Flattening when conflicting indexes are found
input
flatten/e001-in.jsonld
expect
conflicting indexes
Options
specVersion
json-ld-1.1
Test tin01 Basic Included array
id
#tin01
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Tests included maps.
input
flatten/in01-in.jsonld
expect
flatten/in01-out.jsonld
Options
specVersion
json-ld-1.1
Test tin02 Basic Included object
id
#tin02
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Tests included maps.
input
flatten/in02-in.jsonld
expect
flatten/in02-out.jsonld
Options
specVersion
json-ld-1.1
Test tin03 Multiple properties mapping to @included are folded together
id
#tin03
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Tests included maps.
input
flatten/in03-in.jsonld
expect
flatten/in03-out.jsonld
Options
specVersion
json-ld-1.1
Test tin04 Included containing @included
id
#tin04
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Tests included maps.
input
flatten/in04-in.jsonld
expect
flatten/in04-out.jsonld
Options
specVersion
json-ld-1.1
Test tin05 Property value with @included
id
#tin05
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Tests included maps.
input
flatten/in05-in.jsonld
expect
flatten/in05-out.jsonld
Options
specVersion
json-ld-1.1
Test tin06 json.api example
id
#tin06
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Tests included maps.
input
flatten/in06-in.jsonld
expect
flatten/in06-out.jsonld
Options
specVersion
json-ld-1.1
Test tli01 @list containing an deep list
id
#tli01
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Lists of lists
input
flatten/li01-in.jsonld
expect
flatten/li01-out.jsonld
Options
specVersion
json-ld-1.1
Test tli02 @list containing empty @list
id
#tli02
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Lists of lists
input
flatten/li02-in.jsonld
expect
flatten/li02-out.jsonld
Options
specVersion
json-ld-1.1
Test tli03 @list containing mixed list values
id
#tli03
Type
jld:PositiveEvaluationTest, jld:FlattenTest
Purpose
Lists of lists
input
flatten/li03-in.jsonld
expect
flatten/li03-out.jsonld
Options
specVersion
json-ld-1.1