Initial round of refactoring

* Remove some RBX only nodes
* Register parser types
* Remove all occurences of ::Rubinius when loading libraries
This commit is contained in:
Markus Schirp 2013-06-04 10:25:13 +02:00
parent 014fc7c961
commit 6b2e2a8bb0
45 changed files with 246 additions and 675 deletions

View file

@ -1,4 +1,3 @@
require 'backports'
require 'set'
require 'adamantium'
require 'ice_nine'
@ -47,7 +46,6 @@ require 'mutant/mutator/node/literal/string'
require 'mutant/mutator/node/literal/fixnum'
require 'mutant/mutator/node/literal/float'
require 'mutant/mutator/node/literal/array'
require 'mutant/mutator/node/literal/empty_array'
require 'mutant/mutator/node/literal/hash'
require 'mutant/mutator/node/literal/regex'
require 'mutant/mutator/node/literal/nil'
@ -55,19 +53,10 @@ require 'mutant/mutator/node/block'
require 'mutant/mutator/node/while'
require 'mutant/mutator/node/super'
require 'mutant/mutator/node/send'
require 'mutant/mutator/node/send/with_arguments'
require 'mutant/mutator/node/send/binary_operator_method'
require 'mutant/mutator/node/when'
require 'mutant/mutator/node/assignment'
require 'mutant/mutator/node/define'
require 'mutant/mutator/node/formal_arguments_19'
require 'mutant/mutator/node/formal_arguments_19/default_mutations'
require 'mutant/mutator/node/formal_arguments_19/require_defaults'
require 'mutant/mutator/node/formal_arguments_19/pattern_argument_expansion'
require 'mutant/mutator/node/actual_arguments'
require 'mutant/mutator/node/pattern_arguments'
require 'mutant/mutator/node/pattern_variable'
require 'mutant/mutator/node/default_arguments'
require 'mutant/mutator/node/return'
require 'mutant/mutator/node/iter_19'
require 'mutant/mutator/node/if'

View file

@ -6,7 +6,7 @@ module Mutant
# Return AST wrapping mutated node
#
# @return [Rubinius::AST::Script]
# @return [Parser::AST::Node]
#
# @api private
#
@ -29,12 +29,12 @@ module Mutant
# Wrap node into ast node
#
# @param [Class, Module] scope
# @param [Rubinius::AST::Node] node
# @param [Parser::AST::Node] node
#
# @return [Rubinius::AST::Class]
# @return [Parser::AST::Class]
# if scope is of kind Class
#
# @return [Rubinius::AST::Module]
# @return [Parser::AST::Module]
# if scope is of kind module
#
# @api private
@ -110,7 +110,7 @@ module Mutant
# Return new root ast
#
# @return [Rubinius::AST::Node]
# @return [Parser::AST::Node]
#
# @api private
#
@ -128,6 +128,7 @@ module Mutant
scope.name.split('::')
end
memoize :name_nesting
end
end
end
end # Scope
end # Context
end # Mutant

View file

@ -16,7 +16,7 @@ module Mutant
# Initialize and insert mutation into vm
#
# @param [Rubinius::AST::Script] root
# @param [Parser::AST::Node] root
# @param [Subject] subject
#
# @return [undefined]
@ -52,7 +52,7 @@ module Mutant
def source
ToSource.to_source(@root)
end
end
end # Eval
end
end
end # Loader
end # Mutant

View file

@ -73,7 +73,7 @@ module Mutant
# Return full ast
#
# @return [Rubinius::AST::Node]
# @return [Parser::AST::Node]
#
# @api private
#
@ -143,6 +143,6 @@ module Mutant
last_match
end
end
end
end
end # Method
end # Matcher
end # Mutant

View file

@ -20,7 +20,7 @@ module Mutant
# Check if node is matched
#
# @param [Rubinius::AST::Node] node
# @param [Parser::AST::Node] node
#
# @return [true]
# returns true if node matches method
@ -36,7 +36,7 @@ module Mutant
node.name == method_name
end
end
end
end
end
end # Instance
end # Method
end # Matcher
end # Mutant

View file

@ -20,7 +20,7 @@ module Mutant
# Test for node match
#
# @param [Rubinius::AST::Node] node
# @param [Parser::AST::Node] node
#
# @return [true]
# returns true if node matches method
@ -39,7 +39,7 @@ module Mutant
# Test for line match
#
# @param [Rubinius::AST::Node] node
# @param [Parser::AST::Node] node
#
# @return [true]
# returns true if node matches source line
@ -55,7 +55,7 @@ module Mutant
# Test for name match
#
# @param [Rubinius::AST::DefineSingleton] node
# @param [Parser::AST::Node] node
#
# @return [true]
# returns true if node name matches
@ -71,7 +71,7 @@ module Mutant
# Test for receiver match
#
# @param [Rubinius::AST::DefineSingleton] node
# @param [Parser::AST::Node] node
#
# @return [true]
# returns true when receiver is self or scope from pattern
@ -96,7 +96,7 @@ module Mutant
# Test if reciver name matches context
#
# @param [Rubinius::AST::Node] node
# @param [Parser::AST::Node] node
#
# @return [true]
# returns true when node name matches unqualified scope name
@ -110,7 +110,7 @@ module Mutant
node.name.to_s == context.unqualified_name
end
end
end
end
end
end # Singleton
end # Method
end # Matcher
end # Mutant

View file

@ -6,7 +6,7 @@ module Mutant
# Initialize mutation object
#
# @param [Subject] subject
# @param [Rubinius::Node::AST] node
# @param [Parser::Node::AST] node
#
# @return [undefined]
#
@ -26,7 +26,7 @@ module Mutant
# Return mutated node
#
# @return [Rubinius::AST::Node]
# @return [Parser::AST::Node]
#
# @api private
#
@ -34,7 +34,7 @@ module Mutant
# Return mutated root node
#
# @return [Rubinius::AST::Node]
# @return [Parser::AST::Node]
#
# @api private
#
@ -122,5 +122,5 @@ module Mutant
subject.source
end
end
end
end # Mutation
end # Mutant

View file

@ -21,14 +21,14 @@ module Mutant
# Register node class handler
#
# @param [Class:Rubinius::AST::Node] node_class
#
# @return [undefined]
#
# @api private
#
def self.handle(node_class)
Registry.register(node_class,self)
def self.handle(*types)
types.each do |type|
Registry.register(type, self)
enScriptd
end
private_class_method :handle
@ -171,7 +171,7 @@ module Mutant
# Call block with node
#
# @param [Rubinius::AST::Node] node
# @param [Parser::AST::Node] node
#
# @return [self]
#
@ -202,5 +202,5 @@ module Mutant
Helper.deep_clone(input)
end
end
end
end # Mutator
end # Mutant

View file

@ -7,7 +7,7 @@ module Mutant
# Return identity of node
#
# @param [Rubinius::AST::Node] node
# @param [Parser::AST::Node] node
#
# @return [String]
#
@ -21,7 +21,7 @@ module Mutant
# Return mutated node
#
# @return [Rubinius::AST::Node]
# @return [Parser::AST::Node]
#
# @api private
#
@ -29,7 +29,7 @@ module Mutant
# Return duplicated node
#
# @return [Rubinius::AST::Node]
# @return [Parser::AST::Node]
#
# @api private
#
@ -39,7 +39,7 @@ module Mutant
#
# @param [Rubinis::AST::Node:Class] node_class
#
# @return [Rubinius::AST::Node]
# @return [Parser::AST::Node]
#
# @api private
#
@ -49,7 +49,7 @@ module Mutant
# Create a new AST node with same class as wrapped node
#
# @return [Rubinius::AST::Node]
# @return [Parser::AST::Node]
#
# @api private
#
@ -59,7 +59,7 @@ module Mutant
# Create a new AST node with Rubnius::AST::NilLiteral class
#
# @return [Rubinius::AST::Node]
# @return [Parse::AST::Node]
#
# @api private
#
@ -155,6 +155,6 @@ module Mutant
#
alias_method :dup_node, :dup_input
end
end
end
end # Node
end # Mutator
end # Mutant

View file

@ -1,25 +0,0 @@
module Mutant
class Mutator
class Node
# Mutator for arguments
class Arguments < self
handle(Rubinius::AST::ActualArguments)
private
# Emit mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
emit_attribute_mutations(:array)
end
end
end
end
end

View file

@ -27,29 +27,29 @@ module Mutant
# Mutator for local variable assignments
class Local < self
PREFIX = ''.freeze
handle(Rubinius::AST::LocalVariableAssignment)
end
handle(:lvar)
end # Local
# Mutator for instance variable assignments
class Instance < self
PREFIX = '@'.freeze
handle(Rubinius::AST::InstanceVariableAssignment)
end
handle(:ivar)
end # Instance
# Mutator for class variable assignments
class Class < self
PREFIX = '@@'.freeze
handle(Rubinius::AST::ClassVariableAssignment)
end
handle(:cvar)
end # Class
# Mutator for global variable assignments
class Global < self
PREFIX = '$'.freeze
handle(Rubinius::AST::GlobalVariableAssignment)
end
handle(:gvar)
end # Global
end
end
end
end
end
end # Access
end # Variable
end # Node
end # Mutator
end # Mutant

View file

@ -4,7 +4,7 @@ module Mutant
# Mutator on AST blocks
class Block < self
handle(Rubinius::AST::Block)
handle(:block)
private
@ -26,7 +26,7 @@ module Mutant
end
end
end
end
end
end
end # Block
end # Node
end # Mutator
end # Mutant

View file

@ -1,25 +0,0 @@
module Mutant
class Mutator
class Node
# Mutantor for default arguments
class DefaultArguments < self
handle(Rubinius::AST::DefaultArguments)
private
# Emit mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
emit_attribute_mutations(:arguments) do |argument|
argument.names = argument.arguments.map(&:name)
argument
end
end
end
end
end
end

View file

@ -3,8 +3,7 @@ module Mutant
class Node
class Define < self
handle(Rubinius::AST::Define)
handle(Rubinius::AST::DefineSingletonScope)
handle(:define)
private
@ -18,24 +17,8 @@ module Mutant
emit_attribute_mutations(:body)
emit_attribute_mutations(:arguments)
end
end
class DefineSingleton < self
handle(Rubinius::AST::DefineSingleton)
private
# Emit mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
emit_attribute_mutations(:body)
end
end
end
end
end
end # Define
end # Node
end # Mutator
end # Mutant

View file

@ -1,41 +0,0 @@
module Mutant
class Mutator
class Node
# Mutator for formal arguments in 1.9 mode
class FormalArguments19 < self
private
handle(Rubinius::AST::FormalArguments19)
# Emit mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
run(DefaultMutations)
run(RequireDefaults)
run(PatternArgumentExpansion)
emit_required_mutations
end
# Emit required mutations
#
# @return [undefined]
#
# @api private
#
def emit_required_mutations
emit_attribute_mutations(:required) do |mutation|
mutation.names = mutation.optional + mutation.required
mutation
end
end
end
end
end
end

View file

@ -1,33 +0,0 @@
module Mutant
class Mutator
class Node
class FormalArguments19
# Mutator for default argument values
class DefaultMutations < Node
private
# Emit mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
return unless node.defaults
emit_attribute_mutations(:defaults) do |mutation|
mutation.optional = mutation.defaults.names
mutation.names = mutation.required + mutation.optional
if mutation.defaults.names.empty?
mutation.defaults = nil
end
mutation
end
end
end
end
end
end
end

View file

@ -1,35 +0,0 @@
module Mutant
class Mutator
class Node
class FormalArguments19
# Mutator that expands pattern arguments
class PatternArgumentExpansion < Node
private
# Emit mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
node.required.each_with_index do |argument, index|
next unless argument.kind_of?(Rubinius::AST::PatternArguments)
dup = dup_node
required = dup.required
required.delete_at(index)
argument.arguments.body.reverse.each do |node|
required.insert(index, node.name)
end
dup.names |= required
emit(dup)
end
end
end
end
end
end
end

View file

@ -1,37 +0,0 @@
module Mutant
class Mutator
class Node
class FormalArguments19
# Mutator for removing defaults and transform them into required arguments
class RequireDefaults < Node
private
# Emit mutants
#
# @return [undefined]
#
# @api private
#
def dispatch
return unless node.defaults
arguments = node.defaults.arguments
arguments.each_index do |index|
names = arguments.take(index+1).map(&:name)
dup = dup_node
defaults = dup.defaults
defaults.arguments = defaults.arguments.drop(names.size)
names.each { |name| dup.optional.delete(name) }
dup.required.concat(names)
if dup.optional.empty?
dup.defaults = nil
end
emit(dup)
end
end
end
end
end
end
end

View file

@ -1,14 +1,14 @@
module Mutant
class Mutator
class Node
# Mutator for Rubinius::AST::If nodes
# Mutator for if nodes
class If < self
handle(Rubinius::AST::If)
handle(:if)
private
# Emit mutations on Rubinius::AST::If nodes
# Emit mutations
#
# @return [undefined]
#
@ -97,7 +97,7 @@ module Mutant
# Return if_branch of node
#
# @return [Rubinius::AST::Node]
# @return [Parser::AST::Node]
#
# @api private
#
@ -107,7 +107,7 @@ module Mutant
# Return condition of node
#
# @return [Rubinius::AST::Node]
# @return [Parser::AST::Node]
#
# @api private
#
@ -117,14 +117,15 @@ module Mutant
# Return else body of node
#
# @return [Rubinius::AST::Node]
# @return [Parser::AST::Node]
#
# @api private
#
def else_branch
node.else
end
end
end
end
end
end # If
end # Node
end # Mutator
end # Mutant

View file

@ -2,9 +2,9 @@ module Mutant
class Mutator
class Node
# Emitter for mutations on 19 blocks
class Iter19 < self
class Block < self
handle(Rubinius::AST::Iter19)
handle(:block)
# Emit mutants
#
@ -21,7 +21,7 @@ module Mutant
end if node.arguments
end
end
end
end
end
end # Block
end # Node
end # Mutator
end # Mutant

View file

@ -11,12 +11,12 @@ module Mutant
#
# @param [#to_f] value
#
# @return [Rubinius::Node::FloatLiteral]
# @return [Parser::Node::FloatLiteral]
#
# @api private
#
def new_float(value)
new(Rubinius::AST::FloatLiteral, value)
new(Parser::AST::FloatLiteral, value)
end
# Emit a new node with wrapping class for each entry in values
@ -35,7 +35,7 @@ module Mutant
# Return AST representing NaN
#
# @return [Rubinius::Node::AST]
# @return [Parser::AST::Node]
#
# @api private
#
@ -46,7 +46,7 @@ module Mutant
# Return AST representing negative infinity
#
# @return [Rubinius::Node::AST]
# @return [Parser::AST::Node]
#
# @api private
#
@ -56,14 +56,15 @@ module Mutant
# Return AST representing infinity
#
# @return [Rubinius::Node::AST]
# @return [Parser::AST::Node]
#
# @api private
#
def infinity
new_send_with_arguments(new_float(1), :/, new_float(0))
end
end
end
end
end
end # Literal
end # Node
end # Mutator
end # Mutant

View file

@ -5,7 +5,7 @@ module Mutant
# Mutator for array literals
class Array < self
handle(Rubinius::AST::ArrayLiteral)
handle(:array)
private
@ -21,8 +21,9 @@ module Mutant
emit_nil
emit_self([new_nil] + node.body.dup)
end
end
end
end
end
end
end # Array
end # Literal
end # Node
end # Mutator
end # Mutant

View file

@ -15,35 +15,27 @@ module Mutant
#
def dispatch
emit_nil
emit(inverse)
end
# Return inverse
#
# @return [Rubinius::AST::Node]
#
# @api private
#
def inverse
new(self.class::INVERSE_CLASS)
emit(s(inverse))
end
# Mutator for true literals
class TrueLiteral < self
INVERSE_CLASS = Rubinius::AST::FalseLiteral
INVERSE_TYPE = :false
handle(Rubinius::AST::TrueLiteral)
handle(:true)
end
# Mutator for false literals
class FalseLiteral < self
INVERSE_CLASS = Rubinius::AST::TrueLiteral
INVERSE_TYPE = :true
handle(Rubinius::AST::FalseLiteral)
handle(:false)
end
end
end
end
end
end
end # Boolean
end # Literal
end # Node
end # Mutatork
end # Mutant

View file

@ -1,26 +0,0 @@
module Mutant
class Mutator
class Node
class Literal < self
# Mutator for empty array literals
class EmptyArray < self
handle(Rubinius::AST::EmptyArray)
private
# Emit mutants
#
# @return [undefined]
#
# @api private
#
def dispatch
emit_nil
emit_node(Rubinius::AST::ArrayLiteral, [new_nil])
end
end
end
end
end
end

View file

@ -5,7 +5,7 @@ module Mutant
# Mutator for fixnum literals
class Fixnum < self
handle(Rubinius::AST::FixnumLiteral)
handle(:int)
private
@ -30,8 +30,9 @@ module Mutant
def values
[0, 1, -node.value]
end
end
end
end
end
end
end # Fixnuma
end # Literal
end # Node
end # Mutator
end # Mutant

View file

@ -5,7 +5,7 @@ module Mutant
# Mutator for float literals
class Float < self
handle(Rubinius::AST::FloatLiteral)
handle(:float)
private
@ -41,8 +41,9 @@ module Mutant
def values
[0.0, 1.0] << -node.value
end
end
end
end
end
end
end # Float
end # Literal
end # Node
end # Mutator
end # Mutant

View file

@ -5,7 +5,7 @@ module Mutant
# Mutator for hash literals
class Hash < self
handle(Rubinius::AST::HashLiteral)
handle(:hash)
private
@ -76,8 +76,9 @@ module Mutant
emit_self(contents)
end
end
end
end
end
end
end
end # Hash
end # Literal
end # Node
end # Mutator
end # Mutant

View file

@ -5,7 +5,7 @@ module Mutant
# Mutator for nil literals
class Nil < self
handle(Rubinius::AST::NilLiteral)
handle(:nil)
private
@ -18,8 +18,9 @@ module Mutant
def dispatch
emit('Object.new'.to_ast)
end
end
end
end
end
end
end # Nil
end # Literal
end # Node
end # Mutator
end # Mutant

View file

@ -2,6 +2,7 @@ module Mutant
class Mutator
class Node
class Literal
# Abstract literal range mutator
class Range < self
include AbstractType
@ -22,7 +23,7 @@ module Mutant
# Return inverse node
#
# @return [Rubinius::AST::Node]
# @return [Parser::AST::Node]
#
# @api private
#
@ -68,7 +69,7 @@ module Mutant
# Return inverse AST node class
#
# @return [Class:Rubinius::AST::Node]
# @return [Class:Parser::AST::Node]
#
# @api private
#
@ -78,18 +79,19 @@ module Mutant
# Mutator for range exclude literals
class Exclude < self
INVERSE_CLASS = Rubinius::AST::Range
handle(Rubinius::AST::RangeExclude)
end
INVERSE_TYPE = :irange
handle(:erange)
end # Exclude
# Mutator for range include literals
class Include < self
INVERSE_CLASS = Rubinius::AST::RangeExclude
handle(Rubinius::AST::Range)
end
end
end
end
end
end
INVERSE_TYPE = :erange
handle(:irange)
end # Include
end # Range
end # Literal
end # Node
end # Mutator
end # Mutant

View file

@ -5,7 +5,7 @@ module Mutant
# Mutator for regexp literals
class Regex < self
handle(Rubinius::AST::RegexLiteral)
handle(:regexp)
private
@ -22,7 +22,7 @@ module Mutant
emit_new { new_self(Random.hex_string) }
end
# Return new Rubinius::AST::Regex
# Return new regexp node
#
# @param [String] source
#
@ -36,8 +36,9 @@ module Mutant
def new_self(source,options=nil)
super(source,options || node.options)
end
end
end
end
end
end
end # Regex
end # Literal
end # Node
end # Mutator
end # Mutant

View file

@ -5,7 +5,7 @@ module Mutant
# Mutator for string literals
class String < self
handle(Rubinius::AST::StringLiteral)
handle(:str)
private
@ -19,8 +19,9 @@ module Mutant
emit_nil
emit_new { new_self(Random.hex_string) }
end
end
end
end
end
end
end # String
end # Literal
end # Node
end # Mutator
end # Mutant

View file

@ -5,7 +5,7 @@ module Mutant
# Mutator for symbol literals
class Symbol < self
handle(Rubinius::AST::SymbolLiteral)
handle(:sym)
private
@ -19,8 +19,9 @@ module Mutant
emit_nil
emit_new { new_self(('s'+Random.hex_string).to_sym) }
end
end
end
end
end
end
end # Symbol
end # Literal
end # Node
end # Mutator
end # Mutant

View file

@ -5,51 +5,11 @@ module Mutant
class Noop < self
# Literal references to self do not need to be mutated?
handle(Rubinius::AST::Self)
# Currently unhandled node classes. Feel free to contribute your mutator!
#
# FIXME: This list is mixed with some 1.8 only nodes that should be extracted
#
%w(
ZSuper
ElementAssignment
AttributeAssignment
Not
And
Or
Defined
Super
Next
Break
Match3
ZSuper
MultipleAssignment
ScopedConstant
LocalVariableAccess
InstanceVariableAccess
GlobalVariableAccess
ClassVariableAccess
ToplevelConstant
Ensure
Rescue
DynamicString
DynamicSymbol
DynamicRegex
File
OpAssignOr19
BlockPass19
OpAssign1
NthRef
OpAssign2
SplatValue
ConstantAccess
Yield
Begin
Rescue
).each do |name|
handle(Rubinius::AST.const_get(name))
end
handle(
:self, :zsuper, :not, :or, :and, :defined,
:next, :break, :match, :gvar, :cvar, :ensure, :rescue,
:dstr, :dsym, :yield, :begin, :rescue
)
private

View file

@ -1,41 +0,0 @@
module Mutant
class Mutator
class Node
# Mutator for pattern arguments
class PatternArguments < self
handle(Rubinius::AST::PatternArguments)
private
# Emit mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
Mutator.each(node.arguments.body) do |mutation|
dup = dup_node
dup.arguments.body = mutation
emit(dup)
end
end
# Test if mutation should be skipped
#
# @return [true]
# if mutation should be skipped
#
# @return [false]
# otherwise
#
# @api private
#
def allow?(object)
object.arguments.body.size >= 2
end
end
end
end
end

View file

@ -1,23 +0,0 @@
module Mutant
class Mutator
class Node
# Mutator for pattern variable
class PatternVariable < self
handle(Rubinius::AST::PatternVariable)
private
# Emit mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
emit_attribute_mutations(:name)
end
end
end
end
end

View file

@ -2,10 +2,10 @@ module Mutant
class Mutator
class Node
# Mutator for Rubinius::AST::ReceiverCase nodes
# Mutator for case nodes
class ReceiverCase < self
handle(Rubinius::AST::ReceiverCase)
handle(:case)
private
@ -99,7 +99,7 @@ module Mutant
# Return receiver
#
# @return [Rubinius::AST::Node]
# @return [Parser::AST::Node]
#
# @api private
#
@ -109,14 +109,15 @@ module Mutant
# Return else branch
#
# @return [Rubinius::AST::Node]
# @return [Parser::AST::Node]
#
# @api private
#
def else_branch
node.else
end
end
end
end
end
end # ReceiverCase
end # Node
end # Mutator
end # Mutant

View file

@ -4,11 +4,10 @@ module Mutant
# Mutator for return statements
class Return < self
handle(Rubinius::AST::Return)
handle(:return)
private
# Emit mutants
#
# @return [undefined]
@ -24,8 +23,7 @@ module Mutant
end
end
end
end
end
end
end # Return
end # Node
end # Mutator
end # Mutant

View file

@ -5,7 +5,7 @@ module Mutant
# Namespace for send mutators
class Send < self
handle(Rubinius::AST::Send)
handle(:send)
private
@ -69,7 +69,7 @@ module Mutant
# Return receiver AST node
#
# @return [Rubinius::AST::Node]
# @return [Parser::AST::Node]
#
# @api private
#
@ -135,7 +135,8 @@ module Mutant
mutant.privately = true
emit(mutant)
end
end
end
end
end
end # Send
end # Node
end # Mutator
end # Mutant

View file

@ -32,7 +32,7 @@ module Mutant
# Return right
#
# @return [Rubinius::AST::Node]
# @return [Parser::AST::Node]
#
# @api private
#
@ -53,9 +53,10 @@ module Mutant
emit(dup)
end
end
end
end
end
end
end
end # BinaryOperatorMethod
end # Send
end # Node
end # Mutator
end # Mutant

View file

@ -1,81 +0,0 @@
module Mutant
class Mutator
class Node
class Send
# Mutator for send with arguments
class WithArguments < self
handle(Rubinius::AST::SendWithArguments)
private
# Emit mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
super
if binary_operator?
run(BinaryOperatorMethod)
return
end
emit_send_remove_mutation
emit_argument_mutations
end
# Test if message is a binary operator
#
# @return [true]
# if message is a binary operator
#
# @return [false]
# otherwise
#
# @api private
#
def binary_operator?
Mutant::BINARY_METHOD_OPERATORS.include?(node.name)
end
# Emit argument mutations
#
# @api private
#
# @return [undefined]
#
# @api private
#
def emit_argument_mutations
emit_attribute_mutations(:arguments) do |mutation|
if mutation.arguments.array.empty?
mutation = new_send(receiver, node.name)
mutation.privately = node.privately
mutation
else
mutation
end
end
end
# Emit send remove mutation
#
# @return [undefined]
#
# @api private
#
def emit_send_remove_mutation
array = node.arguments.array
return unless array.length == 1
emit(array.first)
end
end
end
end
end
end

View file

@ -4,7 +4,8 @@ module Mutant
# Mutator for super with parantheses
class Super < self
handle(Rubinius::AST::Super)
handle(:super)
private
@ -15,7 +16,7 @@ module Mutant
# @api private
#
def dispatch
emit_node(Rubinius::AST::ZSuper)
emit_node(:zsuper)
emit_without_block
emit_attribute_mutations(:block) if node.block
emit_attribute_mutations(:arguments)
@ -32,7 +33,8 @@ module Mutant
dup.block = nil
emit(dup)
end
end
end
end
end
end # Super
end # Node
end # Mutator
end # Mutant

View file

@ -2,10 +2,10 @@ module Mutant
class Mutator
class Node
# Mutator for Rubinius::AST::When nodes
# Mutator for when nodes
class When < self
handle(Rubinius::AST::When)
handle(:when)
private
@ -19,7 +19,7 @@ module Mutant
emit_attribute_mutations(:body)
end
end
end
end
end
end # When
end # Node
end # Mutator
end # Mutant

View file

@ -5,7 +5,7 @@ module Mutant
# Mutator for while expressions
class While < self
handle(Rubinius::AST::While)
handle(:while)
private
@ -20,7 +20,7 @@ module Mutant
emit_attribute_mutations(:body)
end
end
end
end
end
end # While
end # Node
end # Mutator
end # Mutant

View file

@ -13,7 +13,7 @@ module Mutant
# Return AST node
#
# @return [Rubinius::AST::Node]
# @return [Parser::AST::Node]
#
# @api private
#
@ -93,9 +93,9 @@ module Mutant
# Return root AST for node
#
# @param [Rubinius::AST::Node] node
# @param [Parser::AST::Node] node
#
# @return [Rubinius::AST::Node]
# @return [Parser::AST::Node]
#
# @api private
#
@ -105,7 +105,7 @@ module Mutant
# Return root AST node for original AST ndoe
#
# @return [Rubinius::AST::Node]
# @return [Parser::AST::Node]
#
# @api private
#
@ -120,7 +120,7 @@ module Mutant
#
# @param [Mutant::Context] context
#
# @param [Rubinius::AST::Node] node
# @param [Parser::AST::Node] node
# the original node to be mutated
#
# @return [unkown]
@ -140,5 +140,5 @@ module Mutant
abstract_method :subtype
private :subtype
end
end
end # Subject
end # Mutant

View file

@ -15,8 +15,6 @@ Gem::Specification.new do |gem|
gem.extra_rdoc_files = %w[TODO LICENSE]
gem.executables = [ 'mutant' ]
gem.add_runtime_dependency('backports', [ '~> 3.0', '>= 3.0.3' ])
gem.add_runtime_dependency('parser', '~> 2.0.beta3')
gem.add_runtime_dependency('unparser', '~> 0.0.1')
gem.add_runtime_dependency('ice_nine', '~> 0.7.0')