parent
0fa3999d85
commit
2f53ef0d01
4 changed files with 20 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
|||
* Remove invalid mutation `super(...)` to `super`
|
||||
* Add mutation from `def foo(a = true); end` to `def foo(a = true); a = true; end` #419
|
||||
* Add mutation from `def foo; end` to `remove_method :foo` #413
|
||||
* Add mutation from `a or b` to `b unless a` and `a and b` to `b if a` #430
|
||||
|
||||
# v0.8.2 2015-08-11
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ module Mutant
|
|||
emit_singletons
|
||||
emit_promotions
|
||||
emit_operator_mutations
|
||||
emit_conditional_mutations
|
||||
emit_left_negation
|
||||
emit_left_mutations
|
||||
emit_right_mutations
|
||||
|
@ -38,6 +39,22 @@ module Mutant
|
|||
emit(s(INVERSE.fetch(node.type), left, right))
|
||||
end
|
||||
|
||||
# Mutate `and` and `or` into `if` and `unless`
|
||||
#
|
||||
# - `a or b` becomes `b unless a`
|
||||
# - `a and b` becomes `b if a`
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
def emit_conditional_mutations
|
||||
if n_or?(node)
|
||||
emit(s(:if, left, nil, right))
|
||||
else
|
||||
emit(s(:if, left, right, nil))
|
||||
end
|
||||
end
|
||||
|
||||
# Emit promotions
|
||||
#
|
||||
# @return [undefined]
|
||||
|
|
|
@ -10,4 +10,5 @@ Mutant::Meta::Example.add do
|
|||
mutation 'false and false'
|
||||
mutation 'true and true'
|
||||
mutation '!true and false'
|
||||
mutation 'false if true'
|
||||
end
|
||||
|
|
|
@ -10,4 +10,5 @@ Mutant::Meta::Example.add do
|
|||
mutation 'true or true'
|
||||
mutation 'true and false'
|
||||
mutation '!true or false'
|
||||
mutation 'false unless true'
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue