Mutare.Decimal.Arithmetic (mutare_decimal v0.2.1)

Copy Markdown View Source

:decimal_arithmetic — swaps Decimal arithmetic calls for other operations of the same arity and reverses operands for non-commutative arithmetic calls.

Function-name swaps keep the original arguments:

Decimal.add(a, b)     # -> Decimal.sub(a, b) / Decimal.mult(a, b)
Decimal.sub(a, b)     # -> Decimal.add(a, b)
Decimal.mult(a, b)    # -> Decimal.div(a, b)
Decimal.div(a, b)     # -> Decimal.mult(a, b) / Decimal.div_int(a, b)
Decimal.div_int(a, b) # -> Decimal.rem(a, b) / Decimal.div(a, b)
Decimal.rem(a, b)     # -> Decimal.div_int(a, b)

It also reverses the operands of Decimal.sub/2, div/2, div_int/2, and rem/2 when they are written differently:

Decimal.sub(a, b) # -> Decimal.sub(b, a)

It resolves qualified, aliased, and imported Decimal calls through Mutare's call resolver. A pipe stage is the call it stands for, so a |> Decimal.sub(b) gets the same mutants as Decimal.sub(a, b), its operand reversal included.

Summary

Functions

The target-operation labels accepted by qualified mutare ignore directives.

Functions

variants()

@spec variants() :: [atom()]

The target-operation labels accepted by qualified mutare ignore directives.