The position a corpus step's expect_position states (ADR-0076): what
Statifier.Position.export/1 answers for the chart's state after that
step, with the fields a conforming implementation need not share left
out, rendered as the JSON value a case writes.
The rendering is a map with string keys and exactly these seven members:
configuration,entered_statesandstates_to_invoke: each set of state ids as an array sorted ascending.history_values: an object from each history state's id to its recorded state ids, as an array sorted ascending.active_invocations: one object per active invocation,state(the id of the state that owns the<invoke>) andindex(the<invoke>'s ordinal among that state's own), sorted bystateand then byindex; the invocation's id is left out.running: the export's boolean as it is.datamodel: the export's datamodel with_event,_ioprocessors,_nameand_sessionidremoved. A string, a number, a boolean andnilare written as they are,:undefinedasnil(JSONnull), a list as an array and a map with string keys as an object, member by member; any other value has no JSON form and is refused, naming its variable.
The export's other members (identity, invoke_counter, send_counter,
timer_counter, status, macrostep, microstep, round, trace and
max_macrostep_rounds) are not rendered. ADR-0076 gives the reason for
each.
A case that carries an expect_position on any step needs every state of
its document to carry an id (named/1), because the export refuses a
position that holds a state it cannot name.
Summary
Functions
Compares expected, a step's expect_position, with the rendering of
machine_state. step names the step in a disagreement: its one-based
number and its event's name. Each member that differs is named, with
both values as JSON.
Whether any of corpus_case's steps carries an expect_position.
Answers :ok when every state of machine but the root carries an id,
and a disagreement naming the count of states without one otherwise.
Renders machine_state's exported position in the expectation's JSON
form, or answers why it cannot: the export's own refusal, or a datamodel
value with no JSON form.
Functions
@spec compare( expected :: map(), machine_state :: Statifier.MachineState.t(), step :: {pos_integer(), String.t()} ) :: :ok | {:disagree, String.t()}
Compares expected, a step's expect_position, with the rendering of
machine_state. step names the step in a disagreement: its one-based
number and its event's name. Each member that differs is named, with
both values as JSON.
Values compare as JSON values: two numbers agree when they are equal
in value, so a float 2.0 the chart holds agrees with an expected
2; an array compares element by element in order, an object member
by member; a string, a boolean and null agree only with themselves.
Whether any of corpus_case's steps carries an expect_position.
@spec named(machine :: Statifier.Machine.t()) :: :ok | {:disagree, String.t()}
Answers :ok when every state of machine but the root carries an id,
and a disagreement naming the count of states without one otherwise.
@spec render(machine_state :: Statifier.MachineState.t()) :: {:ok, map()} | {:error, String.t()}
Renders machine_state's exported position in the expectation's JSON
form, or answers why it cannot: the export's own refusal, or a datamodel
value with no JSON form.