Use more modern spec file naming in spec/unit/mutator/node/*_spec.rb
* The old layout was imposed by older mutants that selected tests via file names. * Reduce the useless namespace Mutator::Node::Connective
This commit is contained in:
parent
1b28438d43
commit
a9974741f2
35 changed files with 60 additions and 63 deletions
|
@ -88,7 +88,7 @@ require 'mutant/mutator/node/argument'
|
|||
require 'mutant/mutator/node/arguments'
|
||||
require 'mutant/mutator/node/blockarg'
|
||||
require 'mutant/mutator/node/begin'
|
||||
require 'mutant/mutator/node/connective/binary'
|
||||
require 'mutant/mutator/node/binary'
|
||||
require 'mutant/mutator/node/const'
|
||||
require 'mutant/mutator/node/dstr'
|
||||
require 'mutant/mutator/node/dsym'
|
||||
|
|
58
lib/mutant/mutator/node/binary.rb
Normal file
58
lib/mutant/mutator/node/binary.rb
Normal file
|
@ -0,0 +1,58 @@
|
|||
# encoding: utf-8
|
||||
|
||||
module Mutant
|
||||
class Mutator
|
||||
class Node
|
||||
# Mutation emitter to handle binary connectives
|
||||
class Binary < self
|
||||
|
||||
INVERSE = {
|
||||
and: :or,
|
||||
or: :and
|
||||
}.freeze
|
||||
|
||||
handle(*INVERSE.keys)
|
||||
|
||||
children :left, :right
|
||||
|
||||
private
|
||||
|
||||
# Emit mutations
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_nil
|
||||
emit(left)
|
||||
emit(right)
|
||||
mutate_operator
|
||||
mutate_operands
|
||||
end
|
||||
|
||||
# Emit operator mutations
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_operator
|
||||
emit(s(INVERSE.fetch(node.type), left, right))
|
||||
end
|
||||
|
||||
# Emit condition mutations
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_operands
|
||||
emit(s(node.type, n_not(left), right))
|
||||
emit(n_not(node))
|
||||
end
|
||||
|
||||
end # Binary
|
||||
end # Node
|
||||
end # Mutator
|
||||
end # Mutant
|
|
@ -1,61 +0,0 @@
|
|||
# encoding: utf-8
|
||||
|
||||
module Mutant
|
||||
class Mutator
|
||||
class Node
|
||||
module Connective
|
||||
|
||||
# Mutation emitter to handle binary connectives
|
||||
class Binary < Node
|
||||
|
||||
INVERSE = {
|
||||
and: :or,
|
||||
or: :and
|
||||
}.freeze
|
||||
|
||||
handle(*INVERSE.keys)
|
||||
|
||||
children :left, :right
|
||||
|
||||
private
|
||||
|
||||
# Emit mutations
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_nil
|
||||
emit(left)
|
||||
emit(right)
|
||||
mutate_operator
|
||||
mutate_operands
|
||||
end
|
||||
|
||||
# Emit operator mutations
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_operator
|
||||
emit(s(INVERSE.fetch(node.type), left, right))
|
||||
end
|
||||
|
||||
# Emit condition mutations
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_operands
|
||||
emit(s(node.type, n_not(left), right))
|
||||
emit(n_not(node))
|
||||
end
|
||||
|
||||
end # Binary
|
||||
end # Connective
|
||||
end # Node
|
||||
end # Mutator
|
||||
end # Mutant
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Mutant::Mutator::Node::Connective::Binary, 'mutations' do
|
||||
describe Mutant::Mutator::Node::Binary, 'mutations' do
|
||||
context 'and' do
|
||||
let(:source) { 'true and false' }
|
||||
|
Loading…
Add table
Reference in a new issue