Fix mutator to not mutate the rhs in a boolean connective

* If the right hand side of the expression includes a method which
  raises or otherwise exits the control flow we cannot kill that
  mutation. However we can mutate the left hand side, and then
  mutate the whole node so it is negated; in the worst case both
  those mutations will be equivalent, but in the best case the rhs
  will return a boolean which will be negated.
This commit is contained in:
Dan Kubb 2013-07-25 08:43:41 -07:00
parent 9a64656bd7
commit b88d3ccc87
2 changed files with 3 additions and 3 deletions

View file

@ -49,7 +49,7 @@ module Mutant
#
def mutate_operands
emit(s(node.type, n_not(left), right))
emit(s(node.type, left, n_not(right)))
emit(n_not(node))
end
end # Binary

View file

@ -13,7 +13,7 @@ describe Mutant::Mutator::Node::Connective::Binary, 'mutations' do
mutations << 'true or false'
mutations << 'not true and false'
mutations << 'true and not false'
mutations << 'not(true and false)'
end
it_should_behave_like 'a mutator'
@ -31,7 +31,7 @@ describe Mutant::Mutator::Node::Connective::Binary, 'mutations' do
mutations << 'true and false'
mutations << 'not true or false'
mutations << 'true or not false'
mutations << 'not(true or false)'
end
it_should_behave_like 'a mutator'