MutationChecks.jl

Author jw3126
Popularity
6 Stars
Updated Last
10 Months Ago
Started In
November 2022

MutationChecks

Stable Dev Build Status Coverage

Mutation is the source of subtle bugs. This tiny package provides a simple macro that is useful for exposing unwanted mutations.

using MutationChecks

mymul(x,y) = x .* y
myadd(x,y) = x .+ y
mysub(x,y) = x .-= y # oups

function mycalc(a,b)
    c = @mutcheck myadd(a,b)
    d = @mutcheck mymul(c,b)
    e = @mutcheck mysub(d,c)
    c = @mutcheck myadd(a,e)
end

mycalc([1,2],[3,4])
ERROR: Mutation detected.
* Expression:           mysub(d, c)
* Calle:                Not mutated.
* Positional arguments: Mutated positions are [1].
* Keyword arguments:    None were mutated.