W3C

Transform RDF to JSON-LD

These tests implement the requirements for the JSON-LD Serialize RDF as JSON-LD Algorithm.

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

General instructions for running the JSON-LD Test suites

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/

Test sequence:

Test t0001 Object Lists
id
#t0001
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Tests generation using different types of objects.
input
fromRdf/0001-in.nq
expect
fromRdf/0001-out.jsonld
Test t0002 Native Types
id
#t0002
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Do not use native datatypes for xsd:boolean, xsd:integer, and xsd:double by default.
input
fromRdf/0002-in.nq
expect
fromRdf/0002-out.jsonld
Test t0003 BNodes and references
id
#t0003
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
BNode name generation and references between resources.
input
fromRdf/0003-in.nq
expect
fromRdf/0003-out.jsonld
Test t0004 Lists
id
#t0004
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Multiple lists with different types of element.
input
fromRdf/0004-in.nq
expect
fromRdf/0004-out.jsonld
Test t0005 Document with list
id
#t0005
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Uses a named graph containing a list.
input
fromRdf/0005-in.nq
expect
fromRdf/0005-out.jsonld
Test t0006 Two graphs having same subject but different values
id
#t0006
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Ensure that properties and list elements aren't confused between graphs.
input
fromRdf/0006-in.nq
expect
fromRdf/0006-out.jsonld
Test t0007 Graph with multiple named graphs
id
#t0007
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Testing @graph recursion.
input
fromRdf/0007-in.nq
expect
fromRdf/0007-out.jsonld
Test t0008 List conversion
id
#t0008
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Conversion of lists of lists (the triples in the input are only partially ordered on purpose (1.0 semantics)
input
fromRdf/0008-in.nq
expect
fromRdf/0008-out.jsonld
Options
specVersion
json-ld-1.0
Test t0009 List conversion with IRI nodes
id
#t0009
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Preserve IRI list nodes (i.e., not blank nodes) when converting to @list
input
fromRdf/0009-in.nq
expect
fromRdf/0009-out.jsonld
Test t0010 List pattern without rdf:nil
id
#t0010
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Do not convert lists that are not terminated by rdf:nil to @list.
input
fromRdf/0010-in.nq
expect
fromRdf/0010-out.jsonld
Test t0011 List pattern with extra properties
id
#t0011
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
If additional properties are associated to a list node, the list is only partially converted to @list.
input
fromRdf/0011-in.nq
expect
fromRdf/0011-out.jsonld
Test t0012 List pattern with cycles
id
#t0012
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Detect lists containing cycles and do not convert them to @list.
input
fromRdf/0012-in.nq
expect
fromRdf/0012-out.jsonld
Test t0013 List pattern with multiple values of rdf:first
id
#t0013
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Do not convert list nodes to @list if nodes contain more than one value for rdf:first.
input
fromRdf/0013-in.nq
expect
fromRdf/0013-out.jsonld
Test t0014 List pattern with multiple values of rdf:rest
id
#t0014
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Do not convert list nodes to @list if nodes contain more than one value for rdf:rest.
input
fromRdf/0014-in.nq
expect
fromRdf/0014-out.jsonld
Test t0015 List pattern with IRI rdf:rest
id
#t0015
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Do not convert lists to @list if a list node's rdf:rest is an IRI.
input
fromRdf/0015-in.nq
expect
fromRdf/0015-out.jsonld
Test t0016 List pattern with type rdf:List
id
#t0016
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
List nodes may have a rdf:type rdf:List.
input
fromRdf/0016-in.nq
expect
fromRdf/0016-out.jsonld
Test t0017 Remove duplicate triples
id
#t0017
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Equivalent triples are used only once
input
fromRdf/0017-in.nq
expect
fromRdf/0017-out.jsonld
Test t0018 use native types flag set to true
id
#t0018
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Literals with datatype xsd:boolean, xsd:integer, and xsd:double are serialized using native scalar values
input
fromRdf/0018-in.nq
expect
fromRdf/0018-out.jsonld
Options
useNativeTypes
true
Test t0019 use rdf:type flag set to false
id
#t0019
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Setting useRdfType to true causes an rdf:type predicate to be treated like a normal property, not @type
input
fromRdf/0019-in.nq
expect
fromRdf/0019-out.jsonld
Options
useRdfType
true
Test t0020 list with node shared across graphs
id
#t0020
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
An otherwise conformant list with a node shared across different lists does not serialize using @list
input
fromRdf/0020-in.nq
expect
fromRdf/0020-out.jsonld
Test t0021 list with node shared across graphs (same triple in different graphs)
id
#t0021
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
If a list node is used in different graphs, it isn't removed and converted to @list
input
fromRdf/0021-in.nq
expect
fromRdf/0021-out.jsonld
Test t0022 list from duplicate triples
id
#t0022
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Duplicate triples for a list node will not prevent @list from being properly generated
input
fromRdf/0022-in.nq
expect
fromRdf/0022-out.jsonld
Test t0023 triple with RDF nil subject
id
#t0023
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Test triple with RDF nil subject
input
fromRdf/0023-in.nq
expect
fromRdf/0023-out.jsonld
Test t0024 multiple languages for same subject+property+value
id
#t0024
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Uniqness of triples should include the value language
input
fromRdf/0024-in.nq
expect
fromRdf/0024-out.jsonld
Test t0025 multiple types for same subject+property+value
id
#t0025
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Uniqness of triples should include the value type
input
fromRdf/0025-in.nq
expect
fromRdf/0025-out.jsonld
Test t0026 triple with rdf:first property and rdf:nil value
id
#t0026
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Check list generation with rdf:first property and rdf:nil value.
input
fromRdf/0026-in.nq
expect
fromRdf/0026-out.jsonld
Test tdi01 rdfDirection: null with i18n literal with direction and no language
id
#tdi01
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Does not parse i18n datatype without proper option.
input
fromRdf/di01-in.nq
expect
fromRdf/di01-out.jsonld
Options
specVersion
json-ld-1.1
Test tdi02 rdfDirection: null with i18n literal with direction and language
id
#tdi02
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Does not parse i18n datatype without proper option.
input
fromRdf/di02-in.nq
expect
fromRdf/di02-out.jsonld
Options
specVersion
json-ld-1.1
Test tdi03 rdfDirection: null with compound literal with direction and no language
id
#tdi03
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Does not parse compound literal without proper option.
input
fromRdf/di03-in.nq
expect
fromRdf/di03-out.jsonld
Options
specVersion
json-ld-1.1
Test tdi04 rdfDirection: null with compound literal with direction and language
id
#tdi04
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Does not parse compound literal without proper option.
input
fromRdf/di04-in.nq
expect
fromRdf/di04-out.jsonld
Options
specVersion
json-ld-1.1
Test tdi05 rdfDirection: i18n-datatype with i18n literal with direction and no language
id
#tdi05
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Parses i18n datatype with proper option.
input
fromRdf/di05-in.nq
expect
fromRdf/di05-out.jsonld
Options
specVersion
json-ld-1.1
rdfDirection
i18n-datatype
normative
false
Test tdi06 rdfDirection: i18n-datatype with i18n literal with direction and language
id
#tdi06
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Parses i18n datatype with proper option.
input
fromRdf/di06-in.nq
expect
fromRdf/di06-out.jsonld
Options
specVersion
json-ld-1.1
rdfDirection
i18n-datatype
normative
false
Test tdi07 rdfDirection: i18n-datatype with compound literal with direction and no language
id
#tdi07
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Does not parse compound literal without proper option.
input
fromRdf/di07-in.nq
expect
fromRdf/di07-out.jsonld
Options
specVersion
json-ld-1.1
rdfDirection
i18n-datatype
normative
false
Test tdi08 rdfDirection: i18n-datatype with compound literal with direction and language
id
#tdi08
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Does not parse compound literal without proper option.
input
fromRdf/di08-in.nq
expect
fromRdf/di08-out.jsonld
Options
specVersion
json-ld-1.1
rdfDirection
i18n-datatype
normative
false
Test tdi09 rdfDirection: compound-literal with i18n literal with direction and no language
id
#tdi09
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Does not parse i18n datatype without proper option.
input
fromRdf/di09-in.nq
expect
fromRdf/di09-out.jsonld
Options
specVersion
json-ld-1.1
rdfDirection
compound-literal
normative
false
Test tdi10 rdfDirection: compound-literal with i18n literal with direction and language
id
#tdi10
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Does not parse i18n datatype without proper option.
input
fromRdf/di10-in.nq
expect
fromRdf/di10-out.jsonld
Options
specVersion
json-ld-1.1
rdfDirection
compound-literal
normative
false
Test tdi11 rdfDirection: compound-literal with compound literal with direction and no language
id
#tdi11
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Parses compound literal with proper option.
input
fromRdf/di11-in.nq
expect
fromRdf/di11-out.jsonld
Options
specVersion
json-ld-1.1
rdfDirection
compound-literal
normative
false
Test tdi12 rdfDirection: compound-literal with compound literal with direction and language
id
#tdi12
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Parses compound literal with proper option.
input
fromRdf/di12-in.nq
expect
fromRdf/di12-out.jsonld
Options
specVersion
json-ld-1.1
rdfDirection
compound-literal
normative
false
Test tjs01 JSON literal (boolean true)
id
#tjs01
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Tests creating property with rdf:type rdf:JSON to a JSON literal (boolean true).
input
fromRdf/js01-in.nq
expect
fromRdf/js01-out.jsonld
Options
specVersion
json-ld-1.1
Test tjs02 JSON literal (boolean false)
id
#tjs02
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Tests creating property with rdf:type rdf:JSON to a JSON literal (boolean false).
input
fromRdf/js02-in.nq
expect
fromRdf/js02-out.jsonld
Options
specVersion
json-ld-1.1
Test tjs03 JSON literal (double)
id
#tjs03
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Tests creating property with rdf:type rdf:JSON to a JSON literal (double).
input
fromRdf/js03-in.nq
expect
fromRdf/js03-out.jsonld
Options
specVersion
json-ld-1.1
Test tjs04 JSON literal (double-zero)
id
#tjs04
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Tests creating property with rdf:type rdf:JSON to a JSON literal (double-zero).
input
fromRdf/js04-in.nq
expect
fromRdf/js04-out.jsonld
Options
specVersion
json-ld-1.1
Test tjs05 JSON literal (integer)
id
#tjs05
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Tests creating property with rdf:type rdf:JSON to a JSON literal (integer).
input
fromRdf/js05-in.nq
expect
fromRdf/js05-out.jsonld
Options
specVersion
json-ld-1.1
Test tjs06 JSON literal (object)
id
#tjs06
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Tests creating property with rdf:type rdf:JSON to a JSON literal (object).
input
fromRdf/js06-in.nq
expect
fromRdf/js06-out.jsonld
Options
specVersion
json-ld-1.1
Test tjs07 JSON literal (array)
id
#tjs07
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Tests creating property with rdf:type rdf:JSON to a JSON literal (array).
input
fromRdf/js07-in.nq
expect
fromRdf/js07-out.jsonld
Options
specVersion
json-ld-1.1
Test tjs08 Invalid JSON literal (bare-word)
id
#tjs08
Type
jld:NegativeEvaluationTest, jld:FromRDFTest
Purpose
Processors must generate an error when deserializing an invalid JSON literal.
input
fromRdf/js08-in.nq
expect
invalid JSON literal
Options
specVersion
json-ld-1.1
Test tjs09 Invalid JSON literal (invalid structure)
id
#tjs09
Type
jld:NegativeEvaluationTest, jld:FromRDFTest
Purpose
Processors must generate an error when deserializing an invalid JSON literal.
input
fromRdf/js09-in.nq
expect
invalid JSON literal
Options
specVersion
json-ld-1.1
Test tjs10 JSON literal (string)
id
#tjs10
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Tests creating property with rdf:type rdf:JSON to a JSON literal (string).
input
fromRdf/js10-in.nq
expect
fromRdf/js10-out.jsonld
Options
specVersion
json-ld-1.1
Test tjs11 JSON literal (null)
id
#tjs11
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
Tests creating property with rdf:type rdf:JSON to a JSON literal (null).
input
fromRdf/js11-in.nq
expect
fromRdf/js11-out.jsonld
Options
specVersion
json-ld-1.1
Test tli01 @list containing empty @list
id
#tli01
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
List of lists
input
fromRdf/li01-in.nq
expect
fromRdf/li01-out.jsonld
Options
specVersion
json-ld-1.1
Test tli02 @list containing multiple lists
id
#tli02
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
List of lists
input
fromRdf/li02-in.nq
expect
fromRdf/li02-out.jsonld
Options
specVersion
json-ld-1.1
Test tli03 t0008 as interpreted for 1.1.
id
#tli03
Type
jld:PositiveEvaluationTest, jld:FromRDFTest
Purpose
List of lists
input
fromRdf/li02-in.nq
expect
fromRdf/li02-out.jsonld
Options
specVersion
json-ld-1.1