An example of a mutant schema for Elixir (from my experimental library named Darwin).
iex(87)> Darwin.mutations_for(1, quote(do: 1 + 2))
00:32:41.569 [debug]
(case(Darwin.ActiveMutation.get()) do
1 ->
&Kernel.-/2
2 ->
&Kernel.*/2
3 ->
&Kernel.//2
_other ->
&Kernel.+/2
end).(
case(Darwin.ActiveMutation.get()) do
4 ->
-1
5 ->
0
6 ->
2
_other ->
1
end,
case(Darwin.ActiveMutation.get()) do
7 ->
-1
8 ->
0
9 ->
1
_other ->
2
end
)
This generates 9 different mutations. Some of them mutate the arithmetic operator, and some of them mutate the integer arguments. The function call Darwin.ActiveMutation.get() gets the index of the active mutation from an Agent (in this case an integer from 1 to 9). This allows us to pick the right mutation at runtime, without the need to compile the file more than once.






















