These tests implement the requirements for the JSON-LD [Compaction Algorithm](https://www.w3.org/TR/json-ld11-api/#compaction-algorithm).
Unreferenced nodes not containing properties are dropped
Properties mapped to null or which are never mapped are dropped
Containers mapped to @set keep empty arrays
keep expanded object format if @type doesn't match
Values not matching a coerced @type remain in expanded form
External context is added to the compacted document
Aliases for keywords are used in compacted document
Value with @id is compacted to string if property cast to @id
An array of objects is serialized with @graph
Expanded value with type xsd:dateTime is represented as string with type coercion
Native values are unmodified during compaction
Values with @language remain in expanded form by default
Aliasing @graph uses alias in compacted document
Property with values of different types use most appropriate term when compacting
Compacting a document with multiple embedded uses of @graph
A term mapping to null removes the mapping
Mapping a term to null causes the property and its values to be removed from the compacted document
Lists with values of different types use best term in compacted document
Duplicate values in @list or @set are retained in compacted document
Compact @id that is a property IRI when @container is @list
A term with @container: @list is also used as the value of an @id, if appropriate
Compact properties and types using @vocab
@vocab is used to create relative properties and types if no other term matches
Compact nested properties using @list containers
@vocab takes precedence over prefixes - even if the result is longer
The most specific term that matches all of the elements in the list, taking into account the default language, must be selected.
Multiple values with different languages use language maps if property has @container: @language
Language map term selection with complications
Test appropriate property use given language maps with @vocab, a default language, and a competing term
Fall back to term with @set container if term with language map is defined
Combination of keyword aliases and @vocab
Output uses index mapping if term is defined with @container: @index
Preserve @index tags if not compacted to an index map
A reverse map is replaced with a matching property defined with @reverse
Do not use reverse property if no other property matches as normal property
Compact @reverse node references using strings
Compact node references to strings for reverse properties using @type: @id
Compact reverse properties using index containers
Compact using both reverse properties and index containers
Complex round-tripping use case from Drupal
Ensure that value of @list is always an array
If an index is present, a term having an @list container is not selected
Make sure keyword aliasing works if a list can't be compacted
Ensure that @vocab compaction isn't used if the result collides with a term
Prefer properties with @type: @vocab in reverse-maps if the value can be compacted to a term
Values of @id are transformed to relative IRIs, terms are ignored
multiple objects without @context use @graph
Wrap top-level array into @graph even if no context is passed
Relative URLs remain relative after compaction
Prefer terms with a language mapping set to null over terms without language-mapping for non-strings
Round tripping of lists that contain just IRIs
List compaction without @container: @list still uses strings if @type: @id
Reverse properties require @type: @id to use string values
Node references in reverse properties are not compacted to strings without explicit type-coercion
Native values survive round-tripping with @list
Round tripping @list with scalar and @graph alias
Native values survive round-tripping with @list and @graph alias
Compact to @type: @vocab when no @type: @id term available
Compact to @type: @vocab and compact @id to term
Compacting IRI value of property with @type: @vocab can use term
Prefer @type: @vocab over @type: @id for terms
Complex round tripping @type: @vocab and @type: @id
Compacting IRI value of property with @type: @vocab can use term; more complex
Prefer @type: @id over @type: @vocab for non-terms
Choose a term having @type: @id over @type: @value if value is not a term
Term with @type: @vocab if no @type: @id
If there's no term with @type: @id, use terms with @type: @vocab for IRIs not mapped to terms
Term with @type: @id if no @type: @vocab and term value
If there's no term with @type: @vocab, use terms with @type: @id for IRIs mapped to terms
@type: @vocab/@id with values matching either
Separate IRIs for the same property to use term with more specific @type (@id vs. @vocab)
Relative IRIs don't round-trip with @type: @vocab
Compact IRI round-tripping with @type: @vocab
Term with @type: @vocab will use compact IRIs
Compact language-tagged and indexed strings to index-map
Given values with both @index and @language and term index-map term, use index map
Language-tagged and indexed strings with language-map
Language-tagged and indexed strings don't compact to language-map
Complex use cases for relative IRI compaction
Compact reverse property whose values are unlabeled blank nodes
Single values of reverse properties are compacted as values of ordinary properties
Single value reverse properties with @set
Single values are kept in array form for reverse properties if the container is to @set
Setting compactArrays to false causes single element arrays to be retained
Input has multiple @contexts, output has one
Expanding input with multiple @contexts and compacting with just one doesn't output undefined properties
Default language and unmapped properties
Ensure that the default language is handled correctly for unmapped properties
Ensure that compaction works with mapped @id and @type
Ensure that compaction works for empty list when property has container declared as @list and type as @id
Compact using relative fragment identifier
Compacting IRI equivalent to base, uses last path segment of base ending in '/'
Compact a @graph container having @index
Verify that having both @graph and @index allows @graph container compaction
Do not compact a graph having @id with a term having an @graph container
Graph compaction works only on simple graphs
Compact a [@graph, @index, @set] container
Compact a @graph container with @index and @set
[@graph, @index] does not compact graph with @id
Graph compaction with @graph and @index works only on simple graphs
Compact a simple graph with a [@graph, @id] container
Compact a simple graph using a @graph container with @id
Compact a named graph with a [@graph, @id] container
Compact a named graph using a @graph container with @id
Compact a simple graph with a [@graph, @id, @set] container
Compact a simple graph using a @graph container with @id and @set
Compact a named graph with a [@graph, @id, @set] container
Compact a named graph using a @graph container with @id and @set
Compact a graph with @index using a [@graph, @id] container
Compact a @graph container with @id and @set, discarding an @index value
Test appropriate property use given language maps with @vocab, a default language, no language, and competing terms
Compact input with @graph container to output without @graph container
Ensure @graph appears properly in output
Compact input with @graph container to output without @graph container with compactArrays unset
Ensure @graph appears properly in output with compactArrays unset
Compact input with [@graph, @set] container to output without [@graph, @set] container
Compact input with [@graph, @set] container to output without [@graph, @set] container with compactArrays unset
Relative propererty IRIs with @vocab: ''
Complex use cases for relative IRI compaction or properties
Compact @graph container (multiple graphs)
Compact [@graph, @set] container (multiple graphs)
Compact [@graph, @index] container (multiple indexed objects)
Compact [@graph, @index, @set] container (multiple indexed objects)
Compact [@graph, @id] container (multiple indexed objects)
Compact [@graph, @id, @set] container (multiple indexed objects)
Compact [@graph, @index] container (multiple indexes and objects)
Compact [@graph, @id] container (multiple ids and objects)
Ensures that a single @type value is represented as an array
Compact @type with @container: @set using an alias of @type
Do not compact @type with @container: @set to an array using an alias of @type
Ensures that a single @type value is not represented as an array in 1.0
context with JavaScript Object property names
Compact with context including JavaScript Object property names
Compact @graph container (multiple objects)
Multiple objects in a simple graph with a graph container need to use @included
Compact [@graph, @set] container (multiple objects)
Relative IRIs must not have the form a of keyword
Compact property index using Absolute IRI index
With @container: @index and @index an absolute IRI, ensure round-tripping of compacted representation
Compact property index using Compact IRI index
With @container: @index and @index a compact IRI, ensure round-tripping of compacted representation
Compaction 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
Nullifying a type-scoped context continues to use the previous context when compacting @type.
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
Empty-property scoped context does not affect term selection.
Adding a minimal/empty property-scoped context should not affect the using terms defined in outer context.
Uses term with null direction when two terms conflict on direction.
Term selection includes values of @list.
Term selection with language maps and @direction.
simple language map with overriding term direction
simple language map with overriding null direction
simple language map with mismatching term direction
Verifies that an exception is raised in Compaction when attempting to compact a list of lists
Verifies that IRI compaction detects when the result is an absolute IRI with a scheme matching a term.
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
@prefix is not allowed in a term definition 1.0
@prefix must be a boolean in a term definition in 1.1
If processingMode is json-ld-1.0, or if term contains a colon (:), an invalid term definition has been detected and processing is aborted.
@nest is not allowed in a term definitionin 1.0
@context is not allowed in a term definitionin 1.0
validate appropriate values of @container
Multiple properties mapping to @included are folded together
Tests compacting property with @type @json to a JSON literal (boolean true).
Tests compacting property with @type @json to a JSON literal (boolean false).
Tests compacting property with @type @json to a JSON literal (double).
Tests compacting property with @type @json to a JSON literal (double-zero).
Tests compacting property with @type @json to a JSON literal (integer).
Tests compacting property with @type @json to a JSON literal (object).
Tests compacting property with @type @json to a JSON literal (array).
Tests compacting JSON literal does not expand terms inside json.
Compact already expanded JSON literal with aliased keys
Tests compacting JSON literal in expanded form.
Tests compacting property with @type @json to a JSON literal (string).
Tests compacting property with @type @json to a JSON literal (null).
The most specific term that matches all of the elements in the list, taking into account the default language, must be selected, without considering case of language.
coerced @list containing mixed list values
Indexes to object already having an @type
@index map with @none value using alias of @none
language map with no @language using alias of @none
node reference compacts to string value of type map
node reference compacts to string value of type map with @type: @id
node reference compacts to string value of type map with @type: @vocab
Indexes to @nest for property with @nest
Indexes to @nest for all properties with @nest
Nests using alias of @nest (defined with @id)
Compact IRI will not use an expanded term definition in 1.0
Terms with an expanded term definition are not used for creating compact IRIs
Compact IRI does not use expanded term definition in 1.1
Compact IRI does not use simple term that does not end with a gen-delim
Terms not ending with a gen-delim are not used for creating compact IRIs
Compact IRIs using simple terms ending with gen-delim
All simple terms ending with gen-delim are suitable for compaction
Compact IRI uses term with definition including @prefix: true
Expanded term definition may set prefix explicitly in 1.1
Terms including a colon are excluded from being used as a prefix
Compact IRI does not use term with definition including @prefix: false
property-valued index indexes property value, instead of property (value)
property-valued index indexes property value, instead of property (multiple values)
property-valued index indexes property value, instead of property (node)
property-valued index indexes property value, instead of property (multiple nodes)
property-valued index indexes using @none if no property value exists
property-valued index indexes using @none if no property value does not compact to string
Check illegal clearing of context with protected terms
Check error when clearing a context with protected terms.
Check illegal overriding of protected term
Check error when overriding a protected term.
Check illegal overriding of protected term from type-scoped context
Check error when overriding a protected term from type-scoped context.
Check legal overriding of protected term from property-scoped context
Check overriding a protected term from property-scoped context.
Check legal overriding of type-scoped protected term from nested node
Check legal overriding of type-scoped protected term from nested node.
Expands and compacts to document base by default
Compact IRI attempts to compact document-relative IRIs
Expands and does not compact to document base with compactToRelative false
With compactToRelative option set to false, IRIs which could be made relative to the document base are not made relative.
@context with array including @set uses array values
@context values may include @set along with another compatible value
@type: @none does not use arrays by default
@type: @none uses arrays with @container: @set