View Source Finitomata.Test.Listener (Finitomata v0.15.0)

The instance of FSM backed up by Finitomata.

FSM representation

graph TD
    idle --> |start| started
    started --> |do| done

Summary

Types

Kind of event which might be send to initiate the transition.

Functions

Getter for the internal compiled in FSM information.

Returns the generator to be used in StreamData-powered property testing, based on the specification given to use Estructura.Nested, which contained

Casts the map representation as given to Estructura.Nested.shape/1 to the nested Estructura instance.

Returns a specification to start this module under a supervisor.

The convenient macro to allow using states in guards, returns a compile-time list of states for Finitomata.Test.Listener.

Gets the value for the given key from the structure

Safely parses the json, applying all the specified validations and coercions

Same as parse/1 but either returns the result of successful parsing or raises

Puts the value for the given key into the structure, passing coercion and validation, returns {:ok, updated_struct} or {:error, reason} if there is no such key

Puts the value for the given key into the structure, passing coercion and validation, returns the value or raises if there is no such key

Starts an FSM alone with name and payload given.

Types

@type state() :: :done | :started | :idle | :*

Kind of event which might be send to initiate the transition.

FSM representation

graph TD
    idle --> |start| started
    started --> |do| done

Functions

@spec __config__(atom()) :: any()

Getter for the internal compiled in FSM information.

@spec __generator__() ::
  StreamData.t(%Finitomata.Test.Listener{internals: term(), pid: term()})

See Finitomata.Test.Listener.__generator__/1

@spec __generator__(%Finitomata.Test.Listener{internals: term(), pid: term()}) ::
  StreamData.t(%Finitomata.Test.Listener{internals: term(), pid: term()})

Returns the generator to be used in StreamData-powered property testing, based on the specification given to use Estructura.Nested, which contained

shape

%{
  pid: {StreamData, :constant, [#PID<0.177.0>]},
  internals: %{counter: {StreamData, :integer, []}}
}

The argument given would be used as a template to generate new values.

Casts the map representation as given to Estructura.Nested.shape/1 to the nested Estructura instance.

Returns a specification to start this module under a supervisor.

See Supervisor.

The convenient macro to allow using states in guards, returns a compile-time list of states for Finitomata.Test.Listener.

Link to this function

get(data, key, default \\ nil)

View Source
@spec get(
  %Finitomata.Test.Listener{internals: term(), pid: term()},
  Estructura.Config.key(),
  any()
) ::
  any()

Gets the value for the given key from the structure

@spec parse(binary()) :: {:ok, struct()} | {:error, Exception.t()}

Safely parses the json, applying all the specified validations and coercions

@spec parse!(binary()) :: struct() | no_return()

Same as parse/1 but either returns the result of successful parsing or raises

@spec put(
  %Finitomata.Test.Listener{internals: term(), pid: term()},
  Estructura.Config.key(),
  any()
) ::
  {:ok, %Finitomata.Test.Listener{internals: term(), pid: term()}}
  | {:error, any()}

Puts the value for the given key into the structure, passing coercion and validation, returns {:ok, updated_struct} or {:error, reason} if there is no such key

@spec put!(
  %Finitomata.Test.Listener{internals: term(), pid: term()},
  Estructura.Config.key(),
  any()
) ::
  %Finitomata.Test.Listener{internals: term(), pid: term()} | no_return()

Puts the value for the given key into the structure, passing coercion and validation, returns the value or raises if there is no such key

Starts an FSM alone with name and payload given.

Usually one does not want to call this directly, the most common way would be to start a Finitomata supervision tree or even better embed it into the existing supervision tree and start FSM with Finitomata.start_fsm/3 passing Finitomata.Test.Listener as the first parameter.