lib/mutant/subject.rb in mutant-0.7.1 vs lib/mutant/subject.rb in mutant-0.7.2

- old
+ new

@@ -11,11 +11,13 @@ # # @api private # 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 # Return source path @@ -54,18 +56,30 @@ # def prepare self end + # Return source lines + # + # @return [Range<Fixnum>] + # + # @api private + # + def source_lines + expression = node.location.expression + expression.line..expression.source_buffer.decompose_position(expression.end_pos).first + end + memoize :source_lines + # Return source line # # @return [Fixnum] # # @api private # def source_line - node.location.expression.line + source_lines.begin end # Return subject identification # # @return [String] @@ -82,11 +96,11 @@ # @return [String] # # @api private # def source - Unparser.unparse(node) + Unparser.unparse(wrap_node(node)) end memoize :source # Return match expression # @@ -111,24 +125,22 @@ # @return [Mutation::Neutral] # # @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 end # Mutant