Flow Assertions v0.1.0 FlowAssertions.EnumA View Source

Assertions that apply to Enums.

Link to this section Summary

Functions

Assert that an Enum has no elements."

Assert that an Enum has only a single element.

Returns the content element of what must be a single-element Enum.

Link to this section Functions

Link to this function

assert_empty(value_to_check)

View Source

Assert that an Enum has no elements."

[] |> assert_empty    # true
%{} |> assert_empty   # true

Assert that an Enum has only a single element.

[1] |> assert_singleton   # passes
[ ] |> assert_singleton   # fails

%{a: 1} |> assert_singleton       # passes
%{a: 1, b: 2} |> assert_singleton # fails

Returns the content element of what must be a single-element Enum.

''' [1] |> singleton_content # 1 [ ] |> singleton_content # fails %{a: 1} |> singleton_content # the tuple {:a, 1}