Skip to content

Commit

Permalink
more mutators
Browse files Browse the repository at this point in the history
  • Loading branch information
WiredNerd committed Nov 23, 2023
1 parent 4e05651 commit 0c577fb
Show file tree
Hide file tree
Showing 20 changed files with 435 additions and 178 deletions.
2 changes: 1 addition & 1 deletion docs/mutatest.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# mutatest mutators 3.1.0

## visit_BinOp
## visit_BinOp (x)
Replace with random other member of group:
Group: ast.Add, ast.Sub, ast.Div, ast.Mult, ast.Pow, ast.Mod, ast.FloorDiv
Group: BitAnd, BitOr, BitXor
Expand Down
6 changes: 3 additions & 3 deletions docs/mutators.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
| Mutator Type | Mutmut | Mutatest | Poodle |
| ------------ | ------ | -------- | ------ |
| Binary Operator | Replace with opposite operator | Replace with Random alternate operator | Replace with opposite operator or up to 6 alternates |
| Invert Operator '~' | Remove operator | - | TBD |
| Augmented Assign | Replace with opposite operator and '=' | Replace +=, -=, *=, /= with random alternate | TBD |
| Comparison | Replace with opposite comparison | Replace with opposite comparison | TBD |
| Unary Operator | Remove binary invert '~' | - | Replace '+' with '-'. Remove 'not' and binary invert '~'. |
| Augmented Assign | Replace with opposite operator and '=' | Replace +=, -=, *=, /= with random alternate | Replace with = and up to 6 alternates |
| Comparison | Replace with opposite comparison | Replace with random alternate comparison | Replace with 1-2 alternate comparisons. |
| Keywords | 11 keywords | 9 keywords | TBD |
| Number | Change value | - | TBD |
| If Statement | - | Replace with 'if True' and 'if False' | TBD |
Expand Down
58 changes: 58 additions & 0 deletions example/src/augassign.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
def addition_assign(x, y):
x += y
return x


def subtraction_assign(x, y):
x -= y
return x


def multiplication_assign(x, y):
x *= y
return x


def division_assign(x, y):
x /= y
return x


def modulus_assign(x, y):
x %= y
return x


def floor_division_assign(x, y):
x //= y
return x


def exponentiation_assign(x, y):
x **= y
return x


def left_shift_assign(x, y):
x <<= y
return x


def right_shift_assign(x, y):
x >>= y
return x


def bit_or_assign(x, y):
x |= y
return x


def bit_xor_assign(x, y):
x ^= y
return x


def bit_and_assign(x, y):
x &= y
return x
34 changes: 34 additions & 0 deletions example/src/compare.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
def equals(a, b):
return a == b


def less_than(a, b):
return a < b


def less_than_equal(a, b):
return a <= b


def greater_than(a, b):
return a > b


def greater_than_equal(a, b):
return a >= b


def value_is(a, b):
return a is b


def value_is_not(a, b):
return a is not b


def value_in(a, b):
return a in b


def value_not_in(a, b):
return a not in b
16 changes: 16 additions & 0 deletions example/src/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,19 @@ def bit_xor(x, y):

def bit_and(x, y):
return x & y


def unary_add(x):
return +x


def unary_sub(x):
return -x


def unary_not(x):
return not x


def unary_invert(x):
return ~x
49 changes: 49 additions & 0 deletions example/tests/test_augassign.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from augassign import *


def test_addition_assign():
assert addition_assign(4, 6) == 10


def test_subtraction_assign():
assert subtraction_assign(6, 4) == 2


def test_multiplication():
assert multiplication_assign(4, 3) == 12


def test_division():
assert division_assign(12, 4) == 3


def test_modulus():
assert modulus_assign(14, 4) == 2


def test_floor_division():
assert floor_division_assign(14, 4) == 3


def test_exponentiation():
assert exponentiation_assign(2, 10) == 1024


def test_left_shift():
assert left_shift_assign(3, 2) == 12


def test_right_shift():
assert right_shift_assign(15, 2) == 3


def test_bit_or():
assert bit_or_assign(5, 12) == 13


def test_bit_xor():
assert bit_xor_assign(5, 12) == 9


def test_bit_and():
assert bit_and_assign(5, 12) == 4
41 changes: 41 additions & 0 deletions example/tests/test_compare.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from compare import *


def test_equals():
assert equals(3, 3) is True


def test_less_than():
assert less_than(2, 3) is True
assert less_than(2, 2) is False


def test_less_than_equal():
assert less_than_equal(2, 3) is True
assert less_than_equal(2, 2) is True


def test_greater_than():
assert greater_than(3, 2) is True
assert greater_than(2, 2) is False


def test_greater_than_equal():
assert greater_than_equal(3, 2) is True
assert greater_than_equal(2, 2) is True


def test_value_is():
assert value_is(True, True) is True


def test_value_is_not():
assert value_is_not(True, False) is True


def test_value_in():
assert value_in(1, [1, 2, 3]) is True


def test_value_not_in():
assert value_not_in(4, [1, 2, 3]) is True
16 changes: 16 additions & 0 deletions example/tests/test_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,19 @@ def test_bit_xor():

def test_bit_and():
assert bit_and(5, 12) == 4


def test_unary_add():
assert unary_add(4) == 4


def test_unary_sub():
assert unary_sub(5) == -5


def test_unary_not():
assert unary_not(True) is False


def test_unary_invert():
assert unary_invert(4) == -5
Loading

0 comments on commit 0c577fb

Please sign in to comment.