Header menu logo testify

Diff Module

Helpers for generating short human-readable diffs for assertion and property failures.

Functions and values

Function or value Description

Diff.array expected actual

Full Usage: Diff.array expected actual

Parameters:
    expected : 'T array - The expected array.
    actual : 'T array - The observed array.

Returns: string option Some human-readable explanation when the arrays differ; otherwise None.

Describes a mismatch between two arrays.

expected : 'T array

The expected array.

actual : 'T array

The observed array.

Returns: string option

Some human-readable explanation when the arrays differ; otherwise None.

Diff.defaultOptions

Full Usage: Diff.defaultOptions

Returns: DiffOptions

The default diff settings used by Testify expectations.

Returns: DiffOptions
Example

 let options = Diff.defaultOptions
val options: obj

Diff.list expected actual

Full Usage: Diff.list expected actual

Parameters:
    expected : 'T list - The expected list.
    actual : 'T list - The observed list.

Returns: string option Some human-readable explanation when the lists differ; otherwise None.

Describes a mismatch between two lists.

expected : 'T list

The expected list.

actual : 'T list

The observed list.

Returns: string option

Some human-readable explanation when the lists differ; otherwise None.

Diff.option expected actual

Full Usage: Diff.option expected actual

Parameters:
    expected : 'T option - The expected option value.
    actual : 'T option - The observed option value.

Returns: string option Some human-readable explanation when the options differ; otherwise None.

Describes a mismatch between two option values.

expected : 'T option

The expected option value.

actual : 'T option

The observed option value.

Returns: string option

Some human-readable explanation when the options differ; otherwise None.

Diff.seq expected actual

Full Usage: Diff.seq expected actual

Parameters:
    expected : 'T seq - The expected sequence.
    actual : 'T seq - The observed sequence.

Returns: string option Some human-readable explanation when the sequences differ; otherwise None.

Describes a mismatch between two sequences.

expected : 'T seq

The expected sequence.

actual : 'T seq

The observed sequence.

Returns: string option

Some human-readable explanation when the sequences differ; otherwise None.

Diff.string expected actual

Full Usage: Diff.string expected actual

Parameters:
    expected : string - The expected string.
    actual : string - The observed string.

Returns: string option Some human-readable explanation when the strings differ; otherwise None.

Describes a string mismatch, including the first differing character when possible.

expected : string

The expected string.

actual : string

The observed string.

Returns: string option

Some human-readable explanation when the strings differ; otherwise None.

Diff.tryDescribe expected actual

Full Usage: Diff.tryDescribe expected actual

Parameters:
    expected : 'T - The expected value.
    actual : 'T - The observed value.

Returns: string option Some explanation when the values differ and Testify can describe the mismatch; otherwise None.

Attempts a mismatch description using defaultOptions.

expected : 'T

The expected value.

actual : 'T

The observed value.

Returns: string option

Some explanation when the values differ and Testify can describe the mismatch; otherwise None.

Example

 let description =
     Diff.tryDescribe [ 1; 2; 3 ] [ 1; 4; 3 ]
val description: obj

Diff.tryDescribeFast expected actual

Full Usage: Diff.tryDescribeFast expected actual

Parameters:
    expected : 'T - The expected value.
    actual : 'T - The observed value.

Returns: string option Some human-readable explanation when a lightweight diff strategy can explain the mismatch; otherwise None.

Attempts a lightweight mismatch description without structural diffing.

expected : 'T

The expected value.

actual : 'T

The observed value.

Returns: string option

Some human-readable explanation when a lightweight diff strategy can explain the mismatch; otherwise None.

Diff.tryDescribeStructural expected actual

Full Usage: Diff.tryDescribeStructural expected actual

Parameters:
    expected : 'T - The expected value.
    actual : 'T - The observed value.

Returns: string option Some structural diff text when Diffract can explain the mismatch; otherwise None.

Attempts a structural mismatch description using Diffract.

expected : 'T

The expected value.

actual : 'T

The observed value.

Returns: string option

Some structural diff text when Diffract can explain the mismatch; otherwise None.

Diff.tryDescribeWith options expected actual

Full Usage: Diff.tryDescribeWith options expected actual

Parameters:
    options : DiffOptions - The diff configuration controlling strategy and truncation.
    expected : 'T - The expected value.
    actual : 'T - The observed value.

Returns: string option Some explanation when the values differ and the chosen diff strategy can describe the mismatch; otherwise None.

Attempts a mismatch description using the supplied diff options.

options : DiffOptions

The diff configuration controlling strategy and truncation.

expected : 'T

The expected value.

actual : 'T

The observed value.

Returns: string option

Some explanation when the values differ and the chosen diff strategy can describe the mismatch; otherwise None.

Type something to start searching.