Skip to content

Define rule for asserts #8

@gabrielpra1

Description

@gabrielpra1

In the tests, we have the option to either do

assert 1 + 1 == 2
assert one_plus_one() == 2

or

assert 2 == 1 + 1
assert 2 == one_plus_one()

While the first approach may be more intuitive, it is not possible to follow that order when using pattern matching. This is the only option:

assert %{result: 2} = %{result: 1 + 1, other_key: 3}
assert %{result: 2} = one_plus_one_in_a_map()

So in this case the expected value must always be on the left-hand side.


So I propose that we follow the pattern of always having the expected on the left-hand side and the value being tested on the right, allowing us to keep the pattern between == and pattern matches.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions