Mutare.Mutators.RescueType (mutare v0.1.0)

Copy Markdown View Source

Narrows the exceptions handled by a rescue.

For a clause with two or more exception types, the mutator removes each type in turn:

rescue e in [ArgumentError, RuntimeError] -> handle(e)

produces clauses that rescue only ArgumentError or only RuntimeError. Both bound var in [A, B] and bare [A, B] forms are supported. A one-element list, a single type, and a bare variable are unchanged because they cannot be narrowed this way without removing the rescue entirely.

A rescue with two or more clauses also produces one mutant per removed clause. This covers the common form where each clause handles one exception type. At least one clause is always retained, and the removed clause may have any valid head, including a catch-all variable.

Both explicit try expressions and the def ... rescue ... shorthand are supported. Type-list narrowing and clause removal are reported under the rescue_type family.

Summary

Functions

Returns one list for each exception type removed from types.

Functions

drops(types)

@spec drops([Macro.t()]) :: [[Macro.t()]]

Returns one list for each exception type removed from types.

At least two types are required, so every returned list remains non-empty. Returns [] for shorter lists.

name()