Remove duplicate between memoized and abstract subject class

This commit is contained in:
Markus Schirp 2014-12-07 21:27:38 +00:00
parent 2d6694bb82
commit ad05adafc8
3 changed files with 12 additions and 47 deletions

View file

@ -1,3 +1,3 @@
---
threshold: 18
total_score: 1161
total_score: 1164

View file

@ -13,7 +13,9 @@ module Mutant
#
def mutations
mutations = [neutral_mutation]
generate_mutations(mutations)
Mutator.each(node) do |mutant|
mutations << Mutation::Evil.new(self, wrap_node(mutant))
end
mutations
end
memoize :mutations
@ -96,7 +98,7 @@ module Mutant
# @api private
#
def source
Unparser.unparse(node)
Unparser.unparse(wrap_node(node))
end
memoize :source
@ -125,21 +127,19 @@ module Mutant
# @api private
#
def neutral_mutation
Mutation::Neutral.new(self, node)
Mutation::Neutral.new(self, wrap_node(node))
end
# Generate mutations
# Wrap node into subject specific container
#
# @param [#<<] emitter
# @param [Parser::AST::Node] node
#
# @return [undefined]
# @return [Parser::AST::Node]
#
# @api private
#
def generate_mutations(emitter)
Mutator.each(node) do |mutant|
emitter << Mutation::Evil.new(self, mutant)
end
def wrap_node(node)
node
end
end # Subject

View file

@ -33,17 +33,6 @@ module Mutant
class Memoized < self
include AST::Sexp
# Return source
#
# @return [String]
#
# @api private
#
def source
Unparser.unparse(memoizer_node(node))
end
memoize :source
# Prepare subject for mutation insertion
#
# @return [self]
@ -58,30 +47,6 @@ module Mutant
private
# Return mutations
#
# @param [#<<] emitter
#
# @return [undefined]
#
# @api private
#
def generate_mutations(emitter)
Mutator.each(node) do |mutant|
emitter << Mutation::Evil.new(self, memoizer_node(mutant))
end
end
# Return neutral mutation
#
# @return [Mutation::Neutral]
#
# @api private
#
def neutral_mutation
Mutation::Neutral.new(self, memoizer_node(node))
end
# Return memoizer node for mutant
#
# @param [Parser::AST::Node] mutant
@ -90,7 +55,7 @@ module Mutant
#
# @api private
#
def memoizer_node(mutant)
def wrap_node(mutant)
s(:begin, mutant, s(:send, nil, :memoize, s(:args, s(:sym, name))))
end