AB.InvalidGenerators (AB v0.2.1)

View Source

Functions for generating invalid test data that does NOT match type specifications. Used for robustness testing to ensure functions properly reject invalid input.

Summary

Functions

Creates invalid input generators from type specifications. Returns a generator that produces lists of invalid arguments.

Converts a type specification to an invalid StreamData generator.

Types

context()

@type context() :: %{
  optional(:module) => module() | nil,
  depth: non_neg_integer(),
  max_depth: non_neg_integer(),
  visited: [atom()]
}

typespec_ast()

@type typespec_ast() ::
  {:type, non_neg_integer(), atom(), [typespec_ast()]}
  | {:atom, non_neg_integer(), atom()}
  | {:integer, non_neg_integer(), integer()}
  | {:user_type, non_neg_integer(), atom(), [typespec_ast()]}
  | {:remote_type, non_neg_integer(), [typespec_ast()]}

Functions

create_invalid_input_generator(input_types, module \\ nil, opts \\ [])

@spec create_invalid_input_generator([typespec_ast()], module() | nil, keyword()) ::
  any()

Creates invalid input generators from type specifications. Returns a generator that produces lists of invalid arguments.

Options:

  • max_depth: Maximum recursion depth for circular types (default: 5)

type_to_invalid_generator(type, context \\ nil)

@spec type_to_invalid_generator(typespec_ast(), module() | context()) :: any()

Converts a type specification to an invalid StreamData generator.

The context parameter can be either:

  • A module atom (for backwards compatibility)
  • A map with module, depth, max_depth, and visited keys