These tests implement the requirements for the JSON-LD [Expansion Algorithm](https://www.w3.org/TR/json-ld11-api/#expansion-algorithm).
Expand drops unreferenced nodes having only @id
Expanding terms with different types of values
Verifies that null values and unmapped properties are removed from expanded output
Uses of @set are removed in expansion; values of @set, or just plain values which are empty arrays are retained
If a keyword is aliased, it is not used when expanding
Aliased keywords expand in resulting document
Expand strings to expanded value with @type: xsd:dateTime
Keep expanded values with @language, drop non-conforming value objects containing just @language
Use of @graph to contain multiple nodes within array
Expanding native scalar retains native scalar within expanded value
A value of a property with @type: @id coercion expands to a node reference
Expand does not mess up already expanded document
@set of @value objects with keyword aliases
An array of multiple @set nodes are collapsed into a single array
Setting @context to null within an embedded object resets back to initial context state
override default @language in terms; only language-tag strings
Expanding a value of null removes the value
do not remove @graph if not at top-level
do not remove @graph at top-level if not only property
@graph used at the top level is retained if there are other properties
Expanding with a default language applies that language to string values
Expanding lists and sets with properties having coercion coerces list/set values
Tests that contexts in an array are merged
Expanding different kinds of terms and Compact IRIs
Expanding term mapping to @type uses @type syntax
Duplicate values in @list and @set are not merged
Use @vocab in properties and @type but not in @id
@vocab is used to compact properties and @type, but is not used for @id
@base is used to compact @id; test with different relative IRIs
Language Maps expand values to include @language
Expanding native types with type coercion adds the coerced type to an expanded value representation and retains the native value representation
Mapping a term to null decouples it from @vocab
Verifies that terms can be defined using @vocab
Multiple properties expanding to the same IRI
Verifies multiple values from separate terms are deterministically made multiple values of the IRI associated with the terms
Language maps with @vocab, default language, and colliding property
Expanding index maps for terms defined with @container: @index
Blank nodes are not relabeled during expansion
language and index expansion on non-objects
Only invoke language and index map expansion if the value is a JSON object
@language: null resets the default language
Expanding terms defined as reverse properties uses @reverse in expanded document
Using reverse properties inside a @reverse-container
Expanding a reverse property within a @reverse undoes both reversals
Expanding top-level value objects causes them to be removed
Expanding free-floating nodes causes them to be removed
Free-floating values in sets and free-floating lists
Free-floating values in sets are removed, free-floating lists are removed completely
String values of a reverse property with @type: @id are treated as IRIs
Term definitions with prefix separate from prefix definitions
Term definitions using compact IRIs don't inherit the definitions of the prefix
Expansion of keyword aliases in term definitions
Expanding terms which are keyword aliases
@vocab-relative IRIs in term definitions
If @vocab is defined, term definitions are expanded relative to @vocab
Expanding values of properties of @type: @vocab does not further expand absolute IRIs
Expanding values of properties of @type: @vocab does not expand term values
Expand @vocab-relative term with @type: @vocab
Expanding values of properties of @type: @vocab expands relative IRIs using @vocab
Use terms with @type: @vocab but not with @type: @id
Checks that expansion uses appropriate base depending on term definition having @type @id or @vocab
Relative values of terms with @type: @vocab expand relative to @vocab
Compact IRIs are expanded normally even if term has @type: @vocab
Setting @vocab to null removes a previous definition
Overwrite document base with @base and reset it again
Setting @base to an IRI and then resetting it to nil
Coercing native types to arbitrary datatypes
Expanding native types when coercing to arbitrary datatypes
Expaning reverse properties with an index-container
Expand reverse property whose values are unlabeled blank nodes
Keys that are not mapped to an IRI in a reverse-map are dropped
Expand uses @vocab to expand keys in reverse-maps
prefix:suffix values are not interpreted as compact IRIs if suffix begins with two slashes
prefix:suffix values are not interpreted as compact IRIs if prefix is an underscore
Redefine compact IRI to define type mapping using the compact IRI itself as value of @id
Compact IRI as term defined using equivalent compact IRI
Redefine compact IRI to define type mapping using the compact IRI itself as string value
Redefine terms looking like compact IRIs
Term definitions may look like compact IRIs
Redefining a term as itself when @vocab is defined uses @vocab, not previous term definition
Objects are unordered, so serialized node definition containing @context may have @context at the end of the node definition
Objects are unordered, so serialized node definition containing @id may have @id at the end of the node definition
Use @vocab to map all properties to blank node identifiers
Use of the base option overrides the document location
Use of the expandContext option to expand the input document
Creates an @graph container if value is a graph
Don't double-expand an already expanded graph
Use of @graph containers with @index and @set
Do not expand [@graph, @index] container if value is a graph
Does not create a new graph object if indexed value is already a graph object
Use of @graph containers with @id and @set
Do not expand [@graph, @id] container if value is a graph
Value Expansion does not expand native values, such as booleans, to a node object
Use of an empty @base is applied to the base option
relative @base overrides base option and document location
Use of a relative @base overrides base option and document location
relative and absolute @base overrides base option and document location
Use of a relative and absolute @base overrides base option and document location
Various relative IRIs as properties with with @vocab: ''
expand @graph container (multiple objects)
expand [@graph, @set] container (multiple objects)
Creates an @graph container if value is a graph (multiple objects)
expand [@graph, @index] container (multiple indexed objects)
expand [@graph, @index, @set] container (multiple objects)
Do not expand [@graph, @index] container if value is a graph (multiple objects)
expand [@graph, @id] container (multiple objects)
expand [@graph, @id, @set] container (multiple objects)
Do not expand [@graph, @id] container if value is a graph (multiple objects)
Expand @graph container if value is a graph (multiple objects)
Creates a new graph object if indexed value is already a graph object
Expand @graph container if value is a graph (multiple graphs)
Creates an @graph container if value is a graph (mixed graph and object)
Do not expand [@graph, @index] container if value is a graph (mixed graph and object)
Do not expand [@graph, @id] container if value is a graph (mixed graph and object)
expand [@graph, @index] container (indexes with multiple objects)
expand [@graph, @id] container (multiple ids and objects)
IRI expansion of fragments including ':'
Do not treat as absolute IRIs values that look like compact IRIs if they're not absolute
Various relative IRIs as properties with with relative @vocab
Various relative IRIs as properties with with relative @vocab itself relative to an existing vocabulary base
Various relative IRIs as properties with with relative @vocab relative to another relative vocabulary base
context with JavaScript Object property names
Expand with context including JavaScript Object property names
Expansion allows multiple properties expanding to @type
An exception for the colliding keywords error is made for @type
Verifies that relative IRIs as properties with @vocab: '' in 1.0 generate an error
Relative property IRIs with relative @vocab in 1.0
Verifies that relative IRIs as properties with relative @vocab in 1.0 generate an error
A term starting with a colon can expand to a different IRI
Terms may begin with a colon and not be treated as IRIs.
Expanding a value staring with a colon does not treat that value as an IRI
Processors SHOULD generate a warning and MUST ignore terms having the form of a keyword.
Ignore some values of @id with @, allow others.
Processors SHOULD generate a warning and MUST ignore values of @id having the form of a keyword.
Ignore some values of @reverse with @, allow others.
Processors SHOULD generate a warning and MUST ignore values of @reverse having the form of a keyword.
Ignore some IRIs when that start with @ when expanding.
Processors SHOULD generate a warning and MUST ignore IRIs having the form of a keyword. (Note: the resulting document will not be valid JSON-LD, due to the `null` value for `@id`)
Value objects including invalid literal datatype IRIs are rejected
Verifies that @vocab defined as a compact IRI expands properly
Verifies that @vocab defined as a term expands properly
A scoped context may include itself recursively (direct)
Verifies that no exception is raised on expansion when processing a scoped context referencing itself directly
A scoped context may include itself recursively (indirect)
Verifies that no exception is raised on expansion when processing a scoped context referencing itself indirectly
Two scoped context may include a shared context
Verifies that no exception is raised on expansion when processing two scoped contexts referencing a shared context
Base without trailing slash, without path
Verify URI resolution relative to base (without trailing slash, without path) according to RFC 3986
Verify URI resolution relative to base (without trailing slash, with path) according to RFC 3986
Reverse term with property based indexed container
Expanding a reverse term using @container: @index and @index set to a property
Expansion using a scoped context uses term scope for selecting proper term
property and value with different terms mapping to the same expanded property
scoped context layers on intemediate contexts
deep @type-scoped @context does NOT affect nested nodes
orders @type terms when applying scoped contexts
deep property-term scoped @context in @type-scoped @context affects nested nodes
type maps use scoped context from type index and not scoped context from containing
multiple type-scoped contexts are properly reverted
multiple type-scoped contexts are property reverted
multiple type-scoped types resolved against previous context
type-scoped context with multiple property scoped terms
type-scoped property-scoped contexts including @type:@vocab
composed type-scoped property-scoped contexts including @type:@vocab
type-scoped + property-scoped + values evaluates against previous context
type-scoped context with @propagate: true survive node-objects
@propagate: false on property-scoped context
property-scoped context with @propagate: false do not survive node-objects
embedded context with @propagate: false do not survive node-objects
@context resolutions respects relative URLs.
An embedded context which is never used should still be checked.
Unused context with an embedded context error.
An unused context with an embedded context should still be checked.
Scoped contexts may be externally loaded.
Terms should make use of @vocab relative to the scope in which the term was defined.
Expansion with empty property-scoped context.
Adding a minimal/empty property-scoped context should not affect expansion of terms defined in the outer scope.
property-scoped contexts which are alias of @nest
Nesting terms may have property-scoped contexts defined.
Expand string using default and term directions
Strings are coerced to have @direction based on default and term direction.
Expand string using default and term directions and languages
List values where the term has @direction are used in expansion.
Term selection with language maps and @direction.
simple language mapwith overriding term direction
simple language mapwith overriding null direction
simple language map with mismatching term direction
Generate an error if @direction has illegal value.
Value objects can have either @type but not @language or @direction.
Verifies that an exception is raised on expansion when a invalid term definition is found
Verifies that an exception is raised if @type is defined as a term with an empty map
Verifies that an exception is raised on expansion when a invalid container mapping is found
@nest MUST NOT have a value object value
does not allow a keyword other than @nest for the value of @nest
processingMode json-ld-1.0 conflicts with @version: 1.1
If processingMode is explicitly json-ld-1.0, it will conflict with 1.1 features.
If @version is specified, it must be 1.1
Keywords cannot be aliased to other keywords
Verifies that an exception is raised on expansion when processing an invalid context aliasing a keyword to another keyword
A context may not include itself recursively (direct)
Verifies that an exception is raised on expansion when processing a context referencing itself
A context may not include itself recursively (indirect)
Verifies that an exception is raised on expansion when processing a context referencing itself indirectly
Verifies that an exception is raised on expansion when a context dereference results in an error
Verifies that an exception is raised on expansion when a remote context is not an object containing @context
Verifies that an exception is raised on expansion when a context is not a string or object
Verifies that an exception is raised on expansion when a context contains an invalid @base
Verifies that an exception is raised on expansion when a context contains an invalid @vocab mapping
Verifies that an exception is raised on expansion when a context contains an invalid @language
Verifies that an exception is raised on expansion when a cyclic IRI mapping is found
Verifies that an exception is raised on expansion when a invalid type mapping is found
Verifies that an exception is raised on expansion when a invalid reverse property is found
Invalid IRI mapping (@reverse not a string)
Verifies that an exception is raised on expansion when a invalid IRI mapping is found
Invalid reverse property (invalid @container)
Verifies that an exception is raised on expansion when a invalid keyword alias is found
Verifies that an exception is raised on expansion when a invalid language mapping is found
Invalid IRI mapping (relative IRI in @type)
Verifies that an exception is raised in Expansion when a list of lists is found
Verifies that an exception is raised in Expansion when a invalid reverse property map is found
Verifies that an exception is raised in Expansion when colliding keywords are found
Verifies that an exception is raised in Expansion when an invalid @id value is found
Verifies that an exception is raised in Expansion when an invalid type value is found
Verifies that an exception is raised in Expansion when an invalid value object value is found
Verifies that an exception is raised in Expansion when an invalid language-tagged string value is found
Verifies that an exception is raised in Expansion when an invalid @index value value is found
Verifies that an exception is raised in Expansion when an invalid @reverse value is found
Invalid reverse property value (in @reverse)
Verifies that an exception is raised in Expansion when an invalid reverse property value is found
Verifies that an exception is raised in Expansion when an invalid language map value is found
Invalid reverse property value (through coercion)
Invalid value object (unexpected keyword)
Verifies that an exception is raised in Expansion when an invalid value object is found
Invalid value object (@type and @language)
Verifies that an exception is raised in Expansion when an invalid language-tagged value is found
Verifies that an exception is raised in Expansion when an invalid typed value is found
Verifies that an exception is raised in Expansion when an invalid set or list object is found
Verifies that an exception is raised on expansion when processing an invalid context attempting to define @container on a keyword
Expanding term mapping to @type uses @type syntax now illegal
Term definitions may look like compact IRIs, but must be consistent.
Verifies that a relative IRI cannot be used as a term.
A relative IRI cannot be used as a prefix
Verifies that an exception is raised in Expansion when an invalid IRI is used for @reverse.
Invalid value object value using a value alias
Verifies that an exception is raised in Expansion when an invalid value object value is found using a value alias
Verifies that an exception is raised on expansion when a context contains a definition for the empty term
Verifies that an exception is raised on expansion when a context contains an invalid @prefix value
Invalid value object, multiple values for @type.
The value of @type in a value object MUST be a string or null.
Invalid term definition, multiple values for @type.
The value of @type in an expanded term definition object MUST be a string or null.
Invalid redefinition of @context keyword.
Verifies that an exception is raised when attempting to redefine @context.
Using an array value for @context is illegal in JSON-LD 1.0
Mapping @container: [@list, @set] is invalid
Testing legal combinations of @set with other container values
Multiple properties mapping to @included are folded together
Error if @included value is a value object
Error if @included value is a list object
Tests expanding property with @type @json to a JSON literal (boolean true).
Tests expanding property with @type @json to a JSON literal (boolean false).
Tests expanding property with @type @json to a JSON literal (double).
Tests expanding property with @type @json to a JSON literal (double-zero).
Tests expanding property with @type @json to a JSON literal (integer).
Tests expanding property with @type @json to a JSON literal (object).
Tests expanding property with @type @json to a JSON literal (array).
Expand JSON literal with array canonicalization
Tests expanding JSON literal with array canonicalization.
Transform JSON literal with string canonicalization
Tests expanding JSON literal with string canonicalization.
Expand JSON literal with structural canonicalization
Tests expanding JSON literal with structural canonicalization.
Expand JSON literal with unicode canonicalization
Tests expanding JSON literal with unicode canonicalization.
Expand JSON literal with value canonicalization
Tests expanding JSON literal with value canonicalization.
Expand JSON literal with wierd canonicalization
Tests expanding JSON literal with wierd canonicalization.
Expand JSON literal without expanding contents
Tests expanding JSON literal does not expand terms inside json.
Expand JSON literal aleady in expanded form
Tests expanding JSON literal in expanded form.
Expand JSON literal aleady in expanded form with aliased keys
Tests expanding JSON literal in expanded form with aliased keys in value object.
Tests expanding property with @type @json to a JSON literal (string).
Tests expanding property with @type @json to a JSON literal (null).
Tests expanding JSON literal with aliased @type.
Tests expanding JSON literal with aliased @value.
Tests expanding JSON literal with a @context.
Expand JSON literal (null) aleady in expanded form.
Tests expanding property with @type @json to a JSON literal (empty array).
A language map may have a null value, which is ignored
@list containing empty @list (with coercion)
coerced @list containing deep empty arrays
coerced @list containing mixed list values
Retains @id in object already having an @id
Adds @type to object not having an @type
Prepends @type in object already having an @type
Adds vocabulary expanded @type to object
string value of type map expands to node reference
string value of type map expands to node reference with @type: @id
string value of type map expands to node reference with @type: @vocab
string value of type map must not be a literal
Appends nested values when property at base and nested
Appends nested values from all @nest aliases
Multiple keys may mapping to @type when nesting
@version may be specified after first context
If processing mode is not set through API, it is set by the first context containing @version.
error if @version is json-ld-1.0 for property-valued index
Expanding index maps where index is a property.
error if @container does not include @index for property-valued index
error if @index is a keyword for property-valued index
error if @index is not a string for property-valued index
error if attempting to add property to value object for property-valued index
property-valued index expands to property value, instead of @index (value)
property-valued index appends to property value, instead of @index (value)
property-valued index expands to property value, instead of @index (node)
property-valued index appends to property value, instead of @index (node)
property-valued index does not output property for @none
property-valued index adds property to graph object
Check error when overriding a protected term.
A term with @protected: false is not protected.
A protected context protects all term definitions.
Do not protect term with @protected: false
A protected context does not protect terms with @protected: false.
Clear active context with protected terms from an embedded context
The Active context be set to null from an embedded context.
Clear active context of protected terms from a term.
The Active context may be set to null from a scoped context of a term.
Attempt to redefine term in other protected context.
A protected term cannot redefine another protected term.
Scoped context fail to override protected term.
Clear protection with array with null context
Fail to override protected terms with type.
Fail to override protected terms with type+null+ctx.
Fail with mix of protected and unprotected terms with type+null+ctx.
Fail with mix of protected and unprotected terms with type+null.
Check legal overriding of type-scoped protected term from nested node.
Allows redefinition of protected alias term with same definition.
Allows redefinition of protected prefix term with same definition.
Allows redefinition of terms with scoped contexts using same definitions.
Fails on redefinition of terms with scoped contexts using different definitions.
Allows redefinition of protected alias term with same definition modulo protected flag.
Fails if trying to redefine a protected null term.
A protected term with a null IRI mapping cannot be redefined.
Does not expand a Compact IRI using a non-prefix term.
Expansion of Compact IRIs considers if the term can be used as a prefix.
Keywords may not be redefined other than to protect them.
Protected keyword aliases cannot be overridden.
Fails if trying to declare a keyword alias as prefix.
Keyword aliases can not be used as prefixes.
Ignores a non-keyword term starting with '@'
Terms in the form of a keyword, which are not keywords, are ignored.
Ignores a non-keyword term starting with '@' (with @vocab)
Ignores a term mapping to a value in the form of a keyword.
Ignores a term mapping to a value in the form of a keyword (with @vocab).
Ignores a term mapping to a value in the form of a keyword (@reverse).
Ignores a term mapping to a value in the form of a keyword (@reverse with @vocab).
Protected terms and property-scoped contexts
Check overriding of protected term from property-scoped context.
Allows protected redefinition of equivalent id terms
Check protected redefinition of equivalent id terms in different forms.
Fail if protected flag not retained during redefinition
Check protected redefinition retains protected flag.
Clear protection in @graph @container with null context.
Processors must detect source contexts that include @import.
@propagate: true on type-scoped context with @import
type-scoped context with @propagate: true survive node-objects (with @import)
@propagate: false on property-scoped context with @import
property-scoped context with @propagate: false do not survive node-objects (with @import)
Override term defined in sourced context
The containing context is merged into the source context.
Override @vocab defined in sourced context
Override protected terms in sourced context
@import may not be used in an imported context.
@import only valid within a term definition.
@import can only reference a single context
@import can only reference a single context.
@type: @none expands strings as value objects
@type: @none leaves inputs other than strings alone