1# Implemented Mutators 2 3`mutagen` provides several mutators. The document gives a rough overview of the implemented mutators. 4 5## lit_bool 6 7### Target Code 8 9bool literals `true` and `false` 10 11### Mutations 12 131. negating the value of the literal 14 15## lit_int 16 17### Target Code 18 19Integer literals like `0`, `1u8`, `5isize`. 20 21Byte-literals like `b'a'` are not mutated by this mutator. 22 23### Mutations 24 251. replacing the literal with a different literal 26 27### Limitations 28 29* literals cannot be mutated into negative numbers 30* literals with a value that does not fit into `u128` are not mutated 31 32### Customization 33 34Customization is WIP 35 36## unop_not 37 38### Target Code 39 40`!`-expressions, like `!done` 41 42### Mutations 43 441. removing the negation, i.e. replacing `!x` with `x` 45 46### Limitations 47 48This is a optimistic mutator. For some types the output type of the negation may be too different from the input type. 49 50such that the input type cannot be converted to it via `Into` without calling the negation. 51 52## binop_bool 53 54### Target Code 55 56expressions containing `&&` and `||`. 57 58### Mutations 59 601. replacing `&&` with `||` 612. replacing `||` with `&&` 62 63### Limitations 64 65none. 66 67The target code has the same short-circuiting behavior to the original operators: When the right argument is not needed for the value of the mutated or original expression, the right argument is not evaluated. 68 69## binop_cmp 70 71### Target Code 72 73expressions that compare two values: 74 75* `x < y` 76* `x <= y` 77* `x >= y` 78* `x > y` 79 80### Mutations 81 821. replacing the comparison with any of the other three 83 84## binop_eq 85 86### Target Code 87 88`==`-expressions, like `x == y` 89 90### Mutations 91 921. replacing `==` with `!=` 932. replacing `!=` with `==` 94 95## binop_num 96 97### Target Code 98 99expressions of numeric operators `+`, `-`, `*`, `/`, like `a+y` 100 101### Mutations 102 1031. replace `+` with `-` 1042. replace `-` with `+` 1053. replace `*` with `/` 1064. replace `/` with `*` 107 108### Limitations 109 110This is a optimistic mutator. The trait corresponding to the operation might not be implemented for the types inside the mutated expression. 111 112### Customization 113 114Customization is WIP 115 116Changing the any numeric operator to the other binary numeric operations as well as the bit-wise operations are possible optimistic mutations. 117 118## binop_bit 119 120### Target Code 121 122expressions of numeric operators `&`, `|`, `^`, like `x | 1` 123 124### Mutations 125 1261. the bit operation with any of the other two 127 128### Limitations 129 130This is a optimistic mutator. The trait corresponding to the operation might not be implemented for the types inside the mutated expression. 131 132## stmt_call 133 134### Target Code 135 136Statements that call a single function or method 137 138### Mutations 139 1401. removing the call to the function or method 141 142### Limitations 143 144This operation is optimistic, since the statement could have the type `!` and can be used in surprising contexts: 145 146* `let x = {f(return y);}` 147* `let x = {std::process::abort();}` 148 149Above examples compile and it is not possible to remove the statements without introducing compiler errors. 150