Merge pull request #364 from mbj/fix/documentation-style
Fix YARD documentation style
This commit is contained in:
commit
8a96379c7f
138 changed files with 230 additions and 708 deletions
|
@ -33,7 +33,6 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.ci?
|
||||
ENV.key?('CI')
|
||||
end
|
||||
|
|
|
@ -10,12 +10,11 @@ module Mutant
|
|||
Undefined = Class.new do
|
||||
INSPECT = 'Mutant::Actor::Undefined'.freeze
|
||||
|
||||
# Return object inspection
|
||||
# Object inspection
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def inspect
|
||||
INSPECT
|
||||
end
|
||||
|
@ -25,7 +24,7 @@ module Mutant
|
|||
class Message
|
||||
include Concord::Public.new(:type, :payload)
|
||||
|
||||
# Return new message
|
||||
# New message
|
||||
#
|
||||
# @param [Symbol] type
|
||||
# @param [Object] payload
|
||||
|
@ -33,7 +32,6 @@ module Mutant
|
|||
# @return [Message]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.new(_type, _payload = Undefined)
|
||||
super
|
||||
end
|
||||
|
@ -51,7 +49,6 @@ module Mutant
|
|||
# @return [Object]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def call(type)
|
||||
other.call(Message.new(type, mailbox.sender))
|
||||
message = mailbox.receiver.call
|
||||
|
|
|
@ -9,7 +9,6 @@ module Mutant
|
|||
# @return [Actor::Sender]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def spawn
|
||||
mailbox = new_mailbox
|
||||
|
||||
|
@ -20,12 +19,11 @@ module Mutant
|
|||
mailbox.sender
|
||||
end
|
||||
|
||||
# Return new unbound mailbox
|
||||
# New unbound mailbox
|
||||
#
|
||||
# @return [Mailbox]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def new_mailbox
|
||||
Mailbox.new
|
||||
end
|
||||
|
|
|
@ -4,12 +4,11 @@ module Mutant
|
|||
class Mailbox
|
||||
include Adamantium::Flat, Concord::Public.new(:receiver, :sender)
|
||||
|
||||
# Return new mailbox
|
||||
# New mailbox
|
||||
#
|
||||
# @return [Mailbox]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.new
|
||||
mutex = Mutex.new
|
||||
condition_variable = ConditionVariable.new
|
||||
|
@ -21,14 +20,13 @@ module Mutant
|
|||
)
|
||||
end
|
||||
|
||||
# Return binding for RPC to other actors
|
||||
# Binding for RPC to other actors
|
||||
#
|
||||
# @param [Actor::Sender] other
|
||||
#
|
||||
# @return [Binding]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def bind(other)
|
||||
Binding.new(self, other)
|
||||
end
|
||||
|
|
|
@ -9,7 +9,6 @@ module Mutant
|
|||
# @return [Object]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def call
|
||||
2.times do
|
||||
message = try_blocking_receive
|
||||
|
@ -29,7 +28,6 @@ module Mutant
|
|||
# if there is a message
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def try_blocking_receive
|
||||
mutex.synchronize do
|
||||
if messages.empty?
|
||||
|
|
|
@ -12,7 +12,6 @@ module Mutant
|
|||
# @return [self]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def call(message)
|
||||
mutex.synchronize do
|
||||
messages << message
|
||||
|
|
|
@ -16,7 +16,6 @@ module Mutant
|
|||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.find_last_path(node, &predicate)
|
||||
fail ArgumentError, 'block expected' unless block_given?
|
||||
path = []
|
||||
|
@ -39,7 +38,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.walk(node, stack, &block)
|
||||
block.call(node, stack)
|
||||
node.children.grep(Parser::AST::Node) do |child|
|
||||
|
|
|
@ -19,12 +19,11 @@ module Mutant
|
|||
INDEX_ASSIGNMENT_SELECTOR = :[]=
|
||||
ATTRIBUTE_ASSIGNMENT_SELECTOR_SUFFIX = '='.freeze
|
||||
|
||||
# Return arguments
|
||||
# Arguments of mutated node
|
||||
#
|
||||
# @return [Enumerable<Parser::AST::Node>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
alias_method :arguments, :remaining_children
|
||||
|
||||
# Test if AST node is a valid assignment target
|
||||
|
@ -32,7 +31,6 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def assignment?
|
||||
index_assignment? || attribute_assignment?
|
||||
end
|
||||
|
@ -42,7 +40,6 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def attribute_assignment?
|
||||
!Types::METHOD_OPERATORS.include?(selector) &&
|
||||
selector.to_s.end_with?(ATTRIBUTE_ASSIGNMENT_SELECTOR_SUFFIX)
|
||||
|
@ -53,7 +50,6 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def index_assignment?
|
||||
selector.equal?(INDEX_ASSIGNMENT_SELECTOR)
|
||||
end
|
||||
|
@ -63,7 +59,6 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def binary_method_operator?
|
||||
Types::BINARY_METHOD_OPERATORS.include?(selector)
|
||||
end
|
||||
|
|
|
@ -11,7 +11,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.included(host)
|
||||
host.class_eval do
|
||||
include InstanceMethods
|
||||
|
@ -24,12 +23,11 @@ module Mutant
|
|||
|
||||
private
|
||||
|
||||
# Return children
|
||||
# Mutated nodes children
|
||||
#
|
||||
# @return [Array<Parser::AST::Node]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def children
|
||||
node.children
|
||||
end
|
||||
|
@ -49,7 +47,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def define_named_child(name, index)
|
||||
define_method(name) do
|
||||
children.at(index)
|
||||
|
@ -63,7 +60,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def define_remaining_children(names)
|
||||
define_method(:remaining_children_with_index) do
|
||||
children.each_with_index.drop(names.length)
|
||||
|
@ -83,7 +79,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def children(*names)
|
||||
names.each_with_index do |name, index|
|
||||
define_named_child(name, index)
|
||||
|
|
|
@ -12,7 +12,6 @@ module Mutant
|
|||
# @return [Parser::AST::Node]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def s(type, *children)
|
||||
Parser::AST::Node.new(type, children)
|
||||
end
|
||||
|
@ -24,7 +23,6 @@ module Mutant
|
|||
# @return [Parser::AST::Node]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def n_not(node)
|
||||
s(:send, node, :!)
|
||||
end
|
||||
|
|
|
@ -8,19 +8,17 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def initialize
|
||||
@cache = {}
|
||||
end
|
||||
|
||||
# Return node for file
|
||||
# Root node parsed from file
|
||||
#
|
||||
# @param [#to_s] path
|
||||
#
|
||||
# @return [AST::Node]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def parse(path)
|
||||
@cache.fetch(path) do
|
||||
@cache[path] = Parser::CurrentRuby.parse(File.read(path))
|
||||
|
|
|
@ -18,7 +18,6 @@ module Mutant
|
|||
# the exit status
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.run(arguments)
|
||||
Runner.call(Env::Bootstrap.call(call(arguments))).success? ? EXIT_SUCCESS : EXIT_FAILURE
|
||||
rescue Error => exception
|
||||
|
@ -33,19 +32,17 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def initialize(arguments)
|
||||
@config = Config::DEFAULT
|
||||
|
||||
parse(arguments)
|
||||
end
|
||||
|
||||
# Return config
|
||||
# Config parsed from CLI
|
||||
#
|
||||
# @return [Config]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
attr_reader :config
|
||||
|
||||
private
|
||||
|
@ -61,7 +58,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def parse(arguments)
|
||||
opts = OptionParser.new do |builder|
|
||||
builder.banner = 'usage: mutant [options] MATCH_EXPRESSION ...'
|
||||
|
@ -82,7 +78,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def parse_match_expressions(expressions)
|
||||
fail Error, 'No expressions given' if expressions.empty?
|
||||
|
||||
|
@ -97,10 +92,9 @@ module Mutant
|
|||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
# rubocop:disable MethodLength
|
||||
#
|
||||
# @api private
|
||||
def add_environment_options(opts)
|
||||
opts.separator('Environment:')
|
||||
opts.on('--zombie', 'Run mutant zombified') do
|
||||
|
@ -124,7 +118,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def setup_integration(name)
|
||||
update(integration: Integration.setup(name))
|
||||
rescue LoadError
|
||||
|
@ -138,7 +131,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def add_mutation_options(opts)
|
||||
opts.separator(nil)
|
||||
opts.separator('Options:')
|
||||
|
@ -159,7 +151,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def add_filter_options(opts)
|
||||
opts.on('--ignore-subject PATTERN', 'Ignore subjects that match PATTERN') do |pattern|
|
||||
add_matcher(:subject_ignores, config.expression_parser.(pattern))
|
||||
|
@ -173,7 +164,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def add_debug_options(opts)
|
||||
opts.on('--fail-fast', 'Fail fast') do
|
||||
update(fail_fast: true)
|
||||
|
@ -198,7 +188,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def update(attributes)
|
||||
@config = @config.update(attributes)
|
||||
end
|
||||
|
@ -214,7 +203,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def add(attribute, value)
|
||||
update(attribute => config.public_send(attribute).dup << value)
|
||||
end
|
||||
|
@ -230,7 +218,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def add_matcher(attribute, value)
|
||||
update(matcher: config.matcher.add(attribute, value))
|
||||
end
|
||||
|
|
|
@ -10,7 +10,6 @@ module Mutant
|
|||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def format(text)
|
||||
"\e[#{@code}m#{text}\e[0m"
|
||||
end
|
||||
|
@ -25,7 +24,6 @@ module Mutant
|
|||
# the argument string
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def format(text)
|
||||
text
|
||||
end
|
||||
|
@ -37,7 +35,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def initialize
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
module Mutant
|
||||
# The configuration of a mutator run
|
||||
# Standalone configuration of a mutant execution.
|
||||
#
|
||||
# Does not reference any "external" volatile state. The configuration applied
|
||||
# to current environment is being represented by the Mutant::Env object.
|
||||
class Config
|
||||
include Adamantium::Flat, Anima::Update, Anima.new(
|
||||
:debug,
|
||||
|
|
|
@ -3,22 +3,20 @@ module Mutant
|
|||
class Context
|
||||
include Adamantium::Flat, AbstractType, Concord::Public.new(:source_path)
|
||||
|
||||
# Return root ast node
|
||||
# Root ast node
|
||||
#
|
||||
# @param [Parser::AST::Node] node
|
||||
#
|
||||
# @return [Parser::AST::Node]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
abstract_method :root
|
||||
|
||||
# Return identification
|
||||
# Identification string
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
abstract_method :identification
|
||||
|
||||
end # Context
|
||||
|
|
|
@ -7,24 +7,22 @@ module Mutant
|
|||
|
||||
NAMESPACE_DELIMITER = '::'.freeze
|
||||
|
||||
# Return AST wrapping mutated node
|
||||
# Return root node for mutation
|
||||
#
|
||||
# @return [Parser::AST::Node]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def root(node)
|
||||
nesting.reverse.reduce(node) do |current, scope|
|
||||
self.class.wrap(scope, current)
|
||||
end
|
||||
end
|
||||
|
||||
# Return identification
|
||||
# Identification string
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def identification
|
||||
scope.name
|
||||
end
|
||||
|
@ -41,7 +39,6 @@ module Mutant
|
|||
# if scope is of kind module
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.wrap(scope, node)
|
||||
name = s(:const, nil, scope.name.split(NAMESPACE_DELIMITER).last.to_sym)
|
||||
case scope
|
||||
|
@ -54,12 +51,11 @@ module Mutant
|
|||
end
|
||||
end
|
||||
|
||||
# Return nesting
|
||||
# Nesting of scope
|
||||
#
|
||||
# @return [Enumerable<Class,Module>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def nesting
|
||||
const = ::Object
|
||||
name_nesting.each_with_object([]) do |name, nesting|
|
||||
|
@ -69,22 +65,20 @@ module Mutant
|
|||
end
|
||||
memoize :nesting
|
||||
|
||||
# Return unqualified name of scope
|
||||
# Unqualified name of scope
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def unqualified_name
|
||||
name_nesting.last
|
||||
end
|
||||
|
||||
# Return match expressions
|
||||
# Match expressions for scope
|
||||
#
|
||||
# @return [Enumerable<Expression>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def match_expressions
|
||||
name_nesting.each_index.reverse_each.map do |index|
|
||||
Expression::Namespace::Recursive.new(
|
||||
|
@ -94,22 +88,20 @@ module Mutant
|
|||
end
|
||||
memoize :match_expressions
|
||||
|
||||
# Return scope wrapped by context
|
||||
# Scope wrapped by context
|
||||
#
|
||||
# @return [::Module|::Class]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
attr_reader :scope
|
||||
|
||||
private
|
||||
|
||||
# Return nesting of names of scope
|
||||
# Nesting of names in scope
|
||||
#
|
||||
# @return [Array<String>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def name_nesting
|
||||
scope.name.split(NAMESPACE_DELIMITER)
|
||||
end
|
||||
|
|
|
@ -11,7 +11,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def delegate(*names)
|
||||
names.each(&method(:define_delegator))
|
||||
end
|
||||
|
@ -23,7 +22,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def define_delegator(name)
|
||||
fail "method #{name} already defined" if instance_methods.include?(name)
|
||||
define_method(name) do
|
||||
|
@ -41,7 +39,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.included(host)
|
||||
super
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ module Mutant
|
|||
DELETION = '-'.freeze
|
||||
NEWLINE = "\n".freeze
|
||||
|
||||
# Return source diff
|
||||
# Unified source diff between old and new
|
||||
#
|
||||
# @return [String]
|
||||
# if there is exactly one diff
|
||||
|
@ -16,7 +16,6 @@ module Mutant
|
|||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def diff
|
||||
return if diffs.empty?
|
||||
|
||||
|
@ -26,7 +25,7 @@ module Mutant
|
|||
end
|
||||
memoize :diff
|
||||
|
||||
# Return colorized source diff
|
||||
# Colorized unified source diff between old and new
|
||||
#
|
||||
# @return [String]
|
||||
# if there is a diff
|
||||
|
@ -35,14 +34,13 @@ module Mutant
|
|||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def colorized_diff
|
||||
return unless diff
|
||||
diff.lines.map(&self.class.method(:colorize_line)).join
|
||||
end
|
||||
memoize :colorized_diff
|
||||
|
||||
# Return new object
|
||||
# Build new object from source strings
|
||||
#
|
||||
# @param [String] old
|
||||
# @param [String] new
|
||||
|
@ -50,7 +48,6 @@ module Mutant
|
|||
# @return [Diff]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.build(old, new)
|
||||
new(lines(old), lines(new))
|
||||
end
|
||||
|
@ -62,7 +59,6 @@ module Mutant
|
|||
# @return [Array<String>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.lines(source)
|
||||
source.lines.map(&:chomp)
|
||||
end
|
||||
|
@ -70,34 +66,31 @@ module Mutant
|
|||
|
||||
private
|
||||
|
||||
# Return diffs
|
||||
# Diffs between old and new
|
||||
#
|
||||
# @return [Array<Array>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def diffs
|
||||
::Diff::LCS.diff(old, new)
|
||||
end
|
||||
|
||||
# Return hunks
|
||||
# Raw diff-lcs hunks
|
||||
#
|
||||
# @return [Array<Diff::LCS::Hunk>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def hunks
|
||||
diffs.map do |diff|
|
||||
::Diff::LCS::Hunk.new(old, new, diff, max_length, 0)
|
||||
end
|
||||
end
|
||||
|
||||
# Return minimized hunks
|
||||
# Minimized hunks
|
||||
#
|
||||
# @return [Array<Diff::LCS::Hunk>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def minimized_hunks
|
||||
head, *tail = hunks
|
||||
|
||||
|
@ -111,24 +104,22 @@ module Mutant
|
|||
end
|
||||
end
|
||||
|
||||
# Return max length
|
||||
# Max length of source line in new and old
|
||||
#
|
||||
# @return [Fixnum]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def max_length
|
||||
[old, new].map(&:length).max
|
||||
end
|
||||
|
||||
# Return colorized diff line
|
||||
# Colorized a unified diff line
|
||||
#
|
||||
# @param [String] line
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.colorize_line(line)
|
||||
case line[0]
|
||||
when ADDITION
|
||||
|
|
|
@ -23,7 +23,6 @@ module Mutant
|
|||
# @return [self]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def warn(message)
|
||||
config.reporter.warn(message)
|
||||
self
|
||||
|
@ -36,7 +35,6 @@ module Mutant
|
|||
# @return [Result::Mutation]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def kill(mutation)
|
||||
test_result = run_mutation_tests(mutation)
|
||||
Result::Mutation.new(
|
||||
|
@ -54,10 +52,9 @@ module Mutant
|
|||
#
|
||||
# @return [Result::Test]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
# rubocop:disable MethodLength
|
||||
#
|
||||
# @api private
|
||||
def run_mutation_tests(mutation)
|
||||
start = Time.now
|
||||
tests = selector.call(mutation.subject)
|
||||
|
|
20
lib/mutant/env/bootstrap.rb
vendored
20
lib/mutant/env/bootstrap.rb
vendored
|
@ -8,20 +8,18 @@ module Mutant
|
|||
"Fix your lib to follow normal ruby semantics!\n" \
|
||||
'{Module,Class}#name should return resolvable constant name as String or nil'.freeze
|
||||
|
||||
# Return scopes that are eligible for mnatching
|
||||
# Scopes that are eligible for matching
|
||||
#
|
||||
# @return [Enumerable<Matcher::Scope>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
attr_reader :matchable_scopes
|
||||
|
||||
# Return new bootstrap env
|
||||
# New bootstrap env
|
||||
#
|
||||
# @return [Env]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.new(_config, _cache = Cache.new)
|
||||
super
|
||||
end
|
||||
|
@ -31,7 +29,6 @@ module Mutant
|
|||
# @return [Object]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def initialize(*)
|
||||
super
|
||||
infect
|
||||
|
@ -45,18 +42,16 @@ module Mutant
|
|||
# @return [self]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def warn(message)
|
||||
config.reporter.warn(message)
|
||||
self
|
||||
end
|
||||
|
||||
# Return environment after bootstraping
|
||||
# Environment after bootstraping
|
||||
#
|
||||
# @return [Env]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
# rubocop:disable MethodLength
|
||||
#
|
||||
def env
|
||||
|
@ -75,7 +70,7 @@ module Mutant
|
|||
|
||||
private
|
||||
|
||||
# Return scope name
|
||||
# Scope name from scopeing object
|
||||
#
|
||||
# @param [Class, Module] scope
|
||||
#
|
||||
|
@ -86,7 +81,6 @@ module Mutant
|
|||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def scope_name(scope)
|
||||
scope.name
|
||||
rescue => exception
|
||||
|
@ -99,19 +93,17 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def infect
|
||||
config.includes.each(&$LOAD_PATH.method(:<<))
|
||||
config.requires.each(&method(:require))
|
||||
@integration = config.integration.new(config).setup
|
||||
end
|
||||
|
||||
# Return matched subjects
|
||||
# Matched subjects
|
||||
#
|
||||
# @return [Enumerable<Subject>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def matched_subjects
|
||||
Matcher::Compiler.call(self, config.matcher).to_a
|
||||
end
|
||||
|
@ -121,7 +113,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def initialize_matchable_scopes
|
||||
scopes = ObjectSpace.each_object(Module).each_with_object([]) do |scope, aggregate|
|
||||
expression = expression(scope)
|
||||
|
@ -142,7 +133,6 @@ module Mutant
|
|||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def expression(scope)
|
||||
name = scope_name(scope) or return
|
||||
|
||||
|
|
|
@ -10,22 +10,20 @@ module Mutant
|
|||
|
||||
private_constant(*constants(false))
|
||||
|
||||
# Return syntax representing this expression
|
||||
# Syntax of expression
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
abstract_method :syntax
|
||||
|
||||
# Return match length for expression
|
||||
# Match length with other expression
|
||||
#
|
||||
# @param [Expression] other
|
||||
#
|
||||
# @return [Fixnum]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def match_length(other)
|
||||
if eql?(other)
|
||||
syntax.length
|
||||
|
@ -41,7 +39,6 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def prefix?(other)
|
||||
!match_length(other).zero?
|
||||
end
|
||||
|
|
|
@ -20,25 +20,23 @@ module Mutant
|
|||
|
||||
REGEXP = /\A#{SCOPE_NAME_PATTERN}#{SCOPE_SYMBOL_PATTERN}#{METHOD_NAME_PATTERN}\z/.freeze
|
||||
|
||||
# Return syntax
|
||||
# Syntax of expression
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def syntax
|
||||
[scope_name, scope_symbol, method_name].join
|
||||
end
|
||||
memoize :syntax
|
||||
|
||||
# Return method matcher
|
||||
# Matcher for expression
|
||||
#
|
||||
# @param [Env] env
|
||||
#
|
||||
# @return [Matcher]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def matcher(env)
|
||||
methods_matcher = MATCHERS.fetch(scope_symbol).new(env, scope)
|
||||
|
||||
|
@ -47,12 +45,11 @@ module Mutant
|
|||
|
||||
private
|
||||
|
||||
# Return scope
|
||||
# Scope object
|
||||
#
|
||||
# @return [Class, Method]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def scope
|
||||
Object.const_get(scope_name)
|
||||
end
|
||||
|
|
|
@ -14,37 +14,34 @@ module Mutant
|
|||
|
||||
REGEXP = /\A#{SCOPE_NAME_PATTERN}#{SCOPE_SYMBOL_PATTERN}\z/.freeze
|
||||
|
||||
# Return syntax
|
||||
# Syntax of expression
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def syntax
|
||||
[scope_name, scope_symbol].join
|
||||
end
|
||||
memoize :syntax
|
||||
|
||||
# Return method matcher
|
||||
# Matcher on expression
|
||||
#
|
||||
# @param [Env] env
|
||||
#
|
||||
# @return [Matcher::Method]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def matcher(env)
|
||||
MATCHERS.fetch(scope_symbol).new(env, scope)
|
||||
end
|
||||
|
||||
# Return length of match
|
||||
# Length of match with other expression
|
||||
#
|
||||
# @param [Expression] expression
|
||||
#
|
||||
# @return [Fixnum]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def match_length(expression)
|
||||
if expression.syntax.start_with?(syntax)
|
||||
syntax.length
|
||||
|
@ -55,12 +52,11 @@ module Mutant
|
|||
|
||||
private
|
||||
|
||||
# Return scope
|
||||
# Scope object
|
||||
#
|
||||
# @return [Class, Method]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def scope
|
||||
Object.const_get(scope_name)
|
||||
end
|
||||
|
|
|
@ -23,37 +23,34 @@ module Mutant
|
|||
)
|
||||
end
|
||||
|
||||
# Return the syntax for this expression
|
||||
# Syntax for expression
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def syntax
|
||||
"#{scope_name}*"
|
||||
end
|
||||
memoize :syntax
|
||||
|
||||
# Return matcher
|
||||
# Matcher for expression
|
||||
#
|
||||
# @param [Env::Bootstrap] env
|
||||
#
|
||||
# @return [Matcher]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def matcher(env)
|
||||
Matcher::Namespace.new(env, self)
|
||||
end
|
||||
|
||||
# Return length of match
|
||||
# Length of match with other expression
|
||||
#
|
||||
# @param [Expression] expression
|
||||
#
|
||||
# @return [Fixnum]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def match_length(expression)
|
||||
if @recursion_pattern =~ expression.syntax
|
||||
scope_name.length
|
||||
|
@ -72,19 +69,18 @@ module Mutant
|
|||
|
||||
REGEXP = /\A#{SCOPE_NAME_PATTERN}\z/.freeze
|
||||
|
||||
# Return matcher
|
||||
# Matcher matcher on expression
|
||||
#
|
||||
# @param [Env::Bootstrap] env
|
||||
#
|
||||
# @return [Matcher]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def matcher(env)
|
||||
Matcher::Scope.new(env, Object.const_get(scope_name), self)
|
||||
end
|
||||
|
||||
# Return the syntax for this expression
|
||||
# Syntax for expression
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
|
|
|
@ -24,7 +24,6 @@ module Mutant
|
|||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def call(input)
|
||||
try_parse(input) or fail InvalidExpressionError, "Expression: #{input.inspect} is not valid"
|
||||
end
|
||||
|
@ -40,7 +39,6 @@ module Mutant
|
|||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def try_parse(input)
|
||||
expressions = expressions(input)
|
||||
case expressions.length
|
||||
|
@ -53,7 +51,7 @@ module Mutant
|
|||
|
||||
private
|
||||
|
||||
# Return expressions for input
|
||||
# Expressions parsed from input
|
||||
#
|
||||
# @param [String] input
|
||||
#
|
||||
|
@ -61,7 +59,6 @@ module Mutant
|
|||
# if expressions can be parsed from input
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def expressions(input)
|
||||
types.each_with_object([]) do |type, aggregate|
|
||||
expression = type.try_parse(input)
|
||||
|
|
|
@ -13,7 +13,6 @@ module Mutant
|
|||
# @return [Integration]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.setup(name)
|
||||
require "mutant/integration/#{name}"
|
||||
lookup(name)
|
||||
|
@ -27,7 +26,6 @@ module Mutant
|
|||
# if found
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.lookup(name)
|
||||
REGISTRY.fetch(name)
|
||||
end
|
||||
|
@ -39,7 +37,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.register(name)
|
||||
REGISTRY[name] = self
|
||||
end
|
||||
|
@ -50,37 +47,33 @@ module Mutant
|
|||
# @return [self]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def setup
|
||||
self
|
||||
end
|
||||
|
||||
# Return test result for tests
|
||||
# Run a collection of tests
|
||||
#
|
||||
# @param [Enumerable<Test>] tests
|
||||
#
|
||||
# @return [Result::Test]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
abstract_method :call
|
||||
|
||||
# Return all available tests by integration
|
||||
# Available tests for integration
|
||||
#
|
||||
# @return [Enumerable<Test>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
abstract_method :all_tests
|
||||
|
||||
private
|
||||
|
||||
# Return expression parser
|
||||
# Expression parser
|
||||
#
|
||||
# @return [Expression::Parser]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def expression_parser
|
||||
config.expression_parser
|
||||
end
|
||||
|
@ -90,24 +83,22 @@ module Mutant
|
|||
|
||||
register('null')
|
||||
|
||||
# Return all tests
|
||||
# Available tests for integration
|
||||
#
|
||||
# @return [Enumerable<Test>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def all_tests
|
||||
EMPTY_ARRAY
|
||||
end
|
||||
|
||||
# Return report for test
|
||||
# Run a collection of tests
|
||||
#
|
||||
# @param [Enumerable<Mutant::Test>] tests
|
||||
#
|
||||
# @return [Result::Test]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def call(tests)
|
||||
Result::Test.new(
|
||||
tests: tests,
|
||||
|
|
|
@ -34,7 +34,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def initialize(*)
|
||||
super
|
||||
@output = StringIO.new
|
||||
|
@ -47,23 +46,21 @@ module Mutant
|
|||
# @return [self]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def setup
|
||||
@runner.setup($stderr, @output)
|
||||
self
|
||||
end
|
||||
memoize :setup
|
||||
|
||||
# Return report for test
|
||||
# Run a collection of tests
|
||||
#
|
||||
# @param [Enumerable<Mutant::Test>] tests
|
||||
#
|
||||
# @return [Result::Test]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
# rubocop:disable MethodLength
|
||||
#
|
||||
# @api private
|
||||
def call(tests)
|
||||
examples = tests.map(&all_tests_index.method(:fetch))
|
||||
filter_examples(&examples.method(:include?))
|
||||
|
@ -78,12 +75,11 @@ module Mutant
|
|||
)
|
||||
end
|
||||
|
||||
# Return all available tests
|
||||
# Available tests
|
||||
#
|
||||
# @return [Enumerable<Test>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def all_tests
|
||||
all_tests_index.keys
|
||||
end
|
||||
|
@ -91,12 +87,11 @@ module Mutant
|
|||
|
||||
private
|
||||
|
||||
# Return all tests index
|
||||
# Index of available tests
|
||||
#
|
||||
# @return [Hash<Test, RSpec::Core::Example]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def all_tests_index
|
||||
all_examples.each_with_index.each_with_object({}) do |(example, example_index), index|
|
||||
index[parse_example(example, example_index)] = example
|
||||
|
@ -112,7 +107,6 @@ module Mutant
|
|||
# @return [Test]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def parse_example(example, index)
|
||||
metadata = example.metadata
|
||||
location = metadata.fetch(:location)
|
||||
|
@ -131,7 +125,6 @@ module Mutant
|
|||
# @return [Expression]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def parse_expression(metadata)
|
||||
if metadata.key?(:mutant_expression)
|
||||
expression_parser.(metadata.fetch(:mutant_expression))
|
||||
|
@ -141,12 +134,11 @@ module Mutant
|
|||
end
|
||||
end
|
||||
|
||||
# Return all examples
|
||||
# Available rspec examples
|
||||
#
|
||||
# @return [Array<String, RSpec::Core::Example]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def all_examples
|
||||
@world.example_groups.flat_map(&:descendants).flat_map(&:examples).select do |example|
|
||||
example.metadata.fetch(:mutant, true)
|
||||
|
@ -160,7 +152,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def filter_examples(&predicate)
|
||||
@world.filtered_examples.each_value do |examples|
|
||||
examples.keep_if(&predicate)
|
||||
|
|
|
@ -13,7 +13,6 @@ module Mutant
|
|||
# if block terminates abnormal
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.call(&block)
|
||||
block.call
|
||||
rescue => exception
|
||||
|
@ -35,10 +34,9 @@ module Mutant
|
|||
# @raise [Error]
|
||||
# if block terminates abnormal
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
# rubocop:disable MethodLength
|
||||
#
|
||||
# @api private
|
||||
def self.call(&block)
|
||||
reader, writer = IO.pipe.map(&:binmode)
|
||||
|
||||
|
|
|
@ -10,12 +10,11 @@ module Mutant
|
|||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
# One off the very few valid uses of eval
|
||||
#
|
||||
# rubocop:disable Lint/Eval
|
||||
#
|
||||
# @api private
|
||||
def call
|
||||
eval(
|
||||
source,
|
||||
|
@ -28,12 +27,11 @@ module Mutant
|
|||
|
||||
private
|
||||
|
||||
# Return source
|
||||
# Source generated from AST
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def source
|
||||
Unparser.unparse(root)
|
||||
end
|
||||
|
|
|
@ -11,21 +11,19 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.build(*arguments)
|
||||
new(*arguments)
|
||||
end
|
||||
|
||||
# Enumerate subjects
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
# @return [self]
|
||||
# if block given
|
||||
#
|
||||
# @return [Enumerable<Subject>]
|
||||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
abstract_method :each
|
||||
|
||||
end # Matcher
|
||||
|
|
|
@ -13,7 +13,6 @@ module Mutant
|
|||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def each(&block)
|
||||
return to_enum unless block_given?
|
||||
|
||||
|
|
|
@ -5,12 +5,11 @@ module Mutant
|
|||
class Compiler
|
||||
include Concord.new(:env, :config), AST::Sexp, Procto.call(:result)
|
||||
|
||||
# Return generated matcher
|
||||
# Generated matcher
|
||||
#
|
||||
# @return [Mutant::Matcher]
|
||||
# @return [Matcher]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def result
|
||||
Filter.new(
|
||||
Chain.build(config.match_expressions.map(&method(:matcher))),
|
||||
|
@ -27,7 +26,6 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def call(subject)
|
||||
expression.prefix?(subject.expression)
|
||||
end
|
||||
|
@ -36,14 +34,13 @@ module Mutant
|
|||
|
||||
private
|
||||
|
||||
# Return predicate
|
||||
# Predicate constraining matches
|
||||
#
|
||||
# @return [#call]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
# rubocop:disable MethodLength
|
||||
#
|
||||
# @api private
|
||||
def predicate
|
||||
if subject_selector && subject_rejector
|
||||
Morpher::Evaluator::Predicate::Boolean::And.new([
|
||||
|
@ -59,7 +56,7 @@ module Mutant
|
|||
end
|
||||
end
|
||||
|
||||
# Return subject selector
|
||||
# the subject selector predicate
|
||||
#
|
||||
# @return [#call]
|
||||
# if selector is present
|
||||
|
@ -68,7 +65,6 @@ module Mutant
|
|||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def subject_selector
|
||||
selectors = config.subject_selects.map do |attribute, value|
|
||||
Morpher.compile(s(:eql, s(:attribute, attribute), s(:static, value)))
|
||||
|
@ -77,7 +73,7 @@ module Mutant
|
|||
Morpher::Evaluator::Predicate::Boolean::Or.new(selectors) if selectors.any?
|
||||
end
|
||||
|
||||
# Return subject rejector
|
||||
# Subject rejector predicate
|
||||
#
|
||||
# @return [#call]
|
||||
# if there is a subject rejector
|
||||
|
@ -86,21 +82,19 @@ module Mutant
|
|||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def subject_rejector
|
||||
rejectors = config.subject_ignores.map(&SubjectPrefix.method(:new))
|
||||
|
||||
Morpher::Evaluator::Predicate::Boolean::Or.new(rejectors) if rejectors.any?
|
||||
end
|
||||
|
||||
# Return a matcher from expression
|
||||
# Matcher for expression on env
|
||||
#
|
||||
# @param [Mutant::Expression] expression
|
||||
#
|
||||
# @return [Matcher]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def matcher(expression)
|
||||
expression.matcher(env)
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ module Mutant
|
|||
|
||||
DEFAULT = new(Hash[anima.attribute_names.map { |name| [name, []] }])
|
||||
|
||||
# Return configuration with added value
|
||||
# Add value to configurable collection
|
||||
#
|
||||
# @param [Symbol] attribute
|
||||
# @param [Object] value
|
||||
|
@ -18,7 +18,6 @@ module Mutant
|
|||
# @return [Config]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def add(attribute, value)
|
||||
update(attribute => public_send(attribute).dup << value)
|
||||
end
|
||||
|
|
|
@ -4,14 +4,13 @@ module Mutant
|
|||
class Filter < self
|
||||
include Concord.new(:matcher, :predicate)
|
||||
|
||||
# Return new matcher
|
||||
# New matcher
|
||||
#
|
||||
# @return [Matcher] matcher
|
||||
# @param [Matcher] matcher
|
||||
#
|
||||
# @return [Matcher]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.build(matcher, &predicate)
|
||||
new(matcher, predicate)
|
||||
end
|
||||
|
@ -25,7 +24,6 @@ module Mutant
|
|||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def each(&block)
|
||||
return to_enum unless block_given?
|
||||
matcher.select(&predicate.method(:call)).each(&block)
|
||||
|
|
|
@ -18,7 +18,6 @@ module Mutant
|
|||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def each
|
||||
return to_enum unless block_given?
|
||||
|
||||
|
@ -36,7 +35,6 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def skip?
|
||||
location = source_location
|
||||
if location.nil? || BLACKLIST.match(location.first)
|
||||
|
@ -50,67 +48,61 @@ module Mutant
|
|||
end
|
||||
end
|
||||
|
||||
# Return method name
|
||||
# Target method name
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def method_name
|
||||
target_method.name
|
||||
end
|
||||
|
||||
# Return context
|
||||
# Target context
|
||||
#
|
||||
# @return [Context::Scope]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def context
|
||||
Context::Scope.new(scope, source_path)
|
||||
end
|
||||
|
||||
# Return full ast
|
||||
# Root source node
|
||||
#
|
||||
# @return [Parser::AST::Node]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def ast
|
||||
env.cache.parse(source_path)
|
||||
end
|
||||
|
||||
# Return path to source
|
||||
# Path to source
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def source_path
|
||||
source_location.first
|
||||
end
|
||||
|
||||
# Return source file line
|
||||
# Source file line
|
||||
#
|
||||
# @return [Integer]
|
||||
# @return [Fixnum]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def source_line
|
||||
source_location.last
|
||||
end
|
||||
|
||||
# Return source location
|
||||
# Full source location
|
||||
#
|
||||
# @return [Array]
|
||||
# @return [Array{String,Fixnum}]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def source_location
|
||||
target_method.source_location
|
||||
end
|
||||
|
||||
# Return subject
|
||||
# Matched subject
|
||||
#
|
||||
# @return [Subject]
|
||||
# if there is a matched node
|
||||
|
@ -119,7 +111,6 @@ module Mutant
|
|||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def subject
|
||||
node = matched_node_path.last
|
||||
return unless node
|
||||
|
@ -127,12 +118,11 @@ module Mutant
|
|||
end
|
||||
memoize :subject
|
||||
|
||||
# Return matched node path
|
||||
# Matched node path
|
||||
#
|
||||
# @return [Array<Parser::AST::Node>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def matched_node_path
|
||||
AST.find_last_path(ast, &method(:match?))
|
||||
end
|
||||
|
|
|
@ -14,7 +14,6 @@ module Mutant
|
|||
# @return [Matcher::Method::Instance]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.build(env, scope, target_method)
|
||||
name = target_method.name
|
||||
if scope.ancestors.include?(::Memoizable) && scope.memoized?(name)
|
||||
|
@ -34,7 +33,6 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def match?(node)
|
||||
location = node.location || return
|
||||
expression = location.expression || return
|
||||
|
@ -50,12 +48,11 @@ module Mutant
|
|||
|
||||
private
|
||||
|
||||
# Return source location
|
||||
# Source location
|
||||
#
|
||||
# @return [Array]
|
||||
# @return [Array{String,Fixnum}]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def source_location
|
||||
scope.unmemoized_instance_method(method_name).source_location
|
||||
end
|
||||
|
|
|
@ -16,7 +16,6 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def match?(node)
|
||||
line?(node) && name?(node) && receiver?(node)
|
||||
end
|
||||
|
@ -28,7 +27,6 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def line?(node)
|
||||
expression = node.location.expression
|
||||
return false unless expression
|
||||
|
@ -42,7 +40,6 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def name?(node)
|
||||
node.children[NAME_INDEX].equal?(method_name)
|
||||
end
|
||||
|
@ -54,7 +51,6 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def receiver?(node)
|
||||
receiver = node.children[RECEIVER_INDEX]
|
||||
case receiver.type
|
||||
|
@ -75,7 +71,6 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def receiver_name?(node)
|
||||
name = node.children[NAME_INDEX]
|
||||
name.to_s.eql?(context.unqualified_name)
|
||||
|
|
|
@ -13,7 +13,6 @@ module Mutant
|
|||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def each(&block)
|
||||
return to_enum unless block_given?
|
||||
|
||||
|
@ -24,22 +23,20 @@ module Mutant
|
|||
|
||||
private
|
||||
|
||||
# Return method matcher class
|
||||
# method matcher class
|
||||
#
|
||||
# @return [Class:Matcher::Method]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def matcher
|
||||
self.class::MATCHER
|
||||
end
|
||||
|
||||
# Return methods
|
||||
# Available methods scope
|
||||
#
|
||||
# @return [Enumerable<Method, UnboundMethod>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def methods
|
||||
candidate_names.each_with_object([]) do |name, methods|
|
||||
method = access(name)
|
||||
|
@ -48,12 +45,11 @@ module Mutant
|
|||
end
|
||||
memoize :methods
|
||||
|
||||
# Return subjects
|
||||
# Subjects detected on scope
|
||||
#
|
||||
# @return [Array<Subject>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def subjects
|
||||
methods.map do |method|
|
||||
matcher.build(env, scope, method)
|
||||
|
@ -61,12 +57,11 @@ module Mutant
|
|||
end
|
||||
memoize :subjects
|
||||
|
||||
# Return candidate names
|
||||
# Candidate method names on target scope
|
||||
#
|
||||
# @return [Enumerable<Symbol>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def candidate_names
|
||||
(
|
||||
candidate_scope.public_instance_methods(false) +
|
||||
|
@ -75,12 +70,11 @@ module Mutant
|
|||
).sort
|
||||
end
|
||||
|
||||
# Return candidate scope
|
||||
# Candidate scope
|
||||
#
|
||||
# @return [Class, Module]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
abstract_method :candidate_scope
|
||||
|
||||
# Matcher for singleton methods
|
||||
|
@ -89,24 +83,22 @@ module Mutant
|
|||
|
||||
private
|
||||
|
||||
# Return method for name
|
||||
# Method object on scope
|
||||
#
|
||||
# @param [Symbol] method_name
|
||||
#
|
||||
# @return [Method]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def access(method_name)
|
||||
scope.method(method_name)
|
||||
end
|
||||
|
||||
# Return candidate scope
|
||||
# Candidate scope
|
||||
#
|
||||
# @return [Class]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def candidate_scope
|
||||
scope.singleton_class
|
||||
end
|
||||
|
@ -120,24 +112,22 @@ module Mutant
|
|||
|
||||
private
|
||||
|
||||
# Return method for name
|
||||
# Method object on scope
|
||||
#
|
||||
# @param [Symbol] method_name
|
||||
#
|
||||
# @return [UnboundMethod]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def access(method_name)
|
||||
scope.instance_method(method_name)
|
||||
end
|
||||
|
||||
# Return candidate scope
|
||||
# Candidate scope
|
||||
#
|
||||
# @return [Class, Module]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def candidate_scope
|
||||
scope
|
||||
end
|
||||
|
|
|
@ -14,7 +14,6 @@ module Mutant
|
|||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def each(&block)
|
||||
return to_enum unless block_given?
|
||||
|
||||
|
@ -34,7 +33,6 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def match?(scope)
|
||||
expression.prefix?(scope.expression)
|
||||
end
|
||||
|
|
|
@ -13,7 +13,6 @@ module Mutant
|
|||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def each
|
||||
return to_enum unless block_given?
|
||||
self
|
||||
|
|
|
@ -18,7 +18,6 @@ module Mutant
|
|||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def each(&block)
|
||||
return to_enum unless block_given?
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.add(&block)
|
||||
file = caller.first.split(':in', 2).first
|
||||
ALL << DSL.run(file, block)
|
||||
|
|
|
@ -3,33 +3,30 @@ module Mutant
|
|||
class Example
|
||||
include Adamantium, Concord::Public.new(:file, :node, :mutations)
|
||||
|
||||
# Return a verification instance
|
||||
# Verification instance for example
|
||||
#
|
||||
# @return [Verification]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def verification
|
||||
Verification.new(self, generated)
|
||||
end
|
||||
|
||||
# Return source
|
||||
# Normalized source
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def source
|
||||
Unparser.unparse(node)
|
||||
end
|
||||
memoize :source
|
||||
|
||||
# Return generated mutations
|
||||
# Generated mutations on example source
|
||||
#
|
||||
# @return [Enumerable<Mutant::Mutation>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def generated
|
||||
Mutator.each(node).map do |node|
|
||||
Mutation::Evil.new(self, node)
|
||||
|
@ -46,17 +43,15 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def success?
|
||||
unparser.success? && missing.empty? && unexpected.empty? && no_diffs.empty?
|
||||
end
|
||||
|
||||
# Return error report
|
||||
# Error report
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def error_report
|
||||
unless unparser.success?
|
||||
return unparser.report
|
||||
|
@ -66,34 +61,31 @@ module Mutant
|
|||
|
||||
private
|
||||
|
||||
# Return unexpected mutations
|
||||
# Unexpected mutations
|
||||
#
|
||||
# @return [Array<Parser::AST::Node>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def unexpected
|
||||
mutations.map(&:node) - example.mutations
|
||||
end
|
||||
memoize :unexpected
|
||||
|
||||
# Return mutations with no diff to original
|
||||
# Mutations with no diff to original
|
||||
#
|
||||
# @return [Enumerable<Mutation>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def no_diffs
|
||||
mutations.select { |mutation| mutation.source.eql?(example.source) }
|
||||
end
|
||||
memoize :no_diffs
|
||||
|
||||
# Return mutation report
|
||||
# Mutation report
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutation_report
|
||||
original_node = example.node
|
||||
[
|
||||
|
@ -107,12 +99,11 @@ module Mutant
|
|||
].join("\n======\n")
|
||||
end
|
||||
|
||||
# Return missing report
|
||||
# Missing mutation report
|
||||
#
|
||||
# @return [Array, nil]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def missing_report
|
||||
[
|
||||
'Missing mutations:',
|
||||
|
@ -120,12 +111,11 @@ module Mutant
|
|||
] if missing.any?
|
||||
end
|
||||
|
||||
# Return no diff report
|
||||
# No diff mutation report
|
||||
#
|
||||
# @return [Array, nil]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def no_diff_report
|
||||
[
|
||||
'No source diffs to original:',
|
||||
|
@ -135,12 +125,11 @@ module Mutant
|
|||
] if no_diffs.any?
|
||||
end
|
||||
|
||||
# Return unexpected report
|
||||
# Unexpected mutation report
|
||||
#
|
||||
# @return [Array, nil]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def unexpected_report
|
||||
[
|
||||
'Unexpected mutations:',
|
||||
|
@ -153,7 +142,6 @@ module Mutant
|
|||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def format_mutation(node)
|
||||
[
|
||||
node.inspect,
|
||||
|
@ -161,23 +149,21 @@ module Mutant
|
|||
].join("\n")
|
||||
end
|
||||
|
||||
# Return missing mutations
|
||||
# Missing mutations
|
||||
#
|
||||
# @return [Array<Parser::AST::Node>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def missing
|
||||
example.mutations - mutations.map(&:node)
|
||||
end
|
||||
memoize :missing
|
||||
|
||||
# Return unparser verifier
|
||||
# Unparser verifier
|
||||
#
|
||||
# @return [Unparser::CLI::Source]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def unparser
|
||||
Unparser::CLI::Source::Node.new(Unparser::Preprocessor.run(example.node))
|
||||
end
|
||||
|
|
|
@ -11,7 +11,6 @@ module Mutant
|
|||
# @return [Example]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.run(file, block)
|
||||
instance = new(file)
|
||||
instance.instance_eval(&block)
|
||||
|
@ -23,14 +22,13 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def initialize(file)
|
||||
@file = file
|
||||
@source = nil
|
||||
@expected = []
|
||||
end
|
||||
|
||||
# Return example
|
||||
# Example captured by DSL
|
||||
#
|
||||
# @return [Example]
|
||||
#
|
||||
|
@ -38,7 +36,6 @@ module Mutant
|
|||
# in case example cannot be build
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def example
|
||||
fail 'source not defined' unless @source
|
||||
Example.new(@file, @source, @expected)
|
||||
|
@ -53,7 +50,6 @@ module Mutant
|
|||
# @return [self]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def source(input)
|
||||
fail 'source already defined' if @source
|
||||
@source = node(input)
|
||||
|
@ -68,7 +64,6 @@ module Mutant
|
|||
# @return [self]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutation(input)
|
||||
node = node(input)
|
||||
if @expected.include?(node)
|
||||
|
@ -84,7 +79,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def singleton_mutations
|
||||
mutation('nil')
|
||||
mutation('self')
|
||||
|
@ -100,7 +94,6 @@ module Mutant
|
|||
# in case input cannot be coerced
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def node(input)
|
||||
case input
|
||||
when String
|
||||
|
|
|
@ -7,45 +7,41 @@ module Mutant
|
|||
CODE_DELIMITER = "\0".freeze
|
||||
CODE_RANGE = (0..4).freeze
|
||||
|
||||
# Return identification
|
||||
# Identification string
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def identification
|
||||
"#{self.class::SYMBOL}:#{subject.identification}:#{code}"
|
||||
end
|
||||
memoize :identification
|
||||
|
||||
# Return mutation code
|
||||
# Mutation code
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def code
|
||||
sha1[CODE_RANGE]
|
||||
end
|
||||
memoize :code
|
||||
|
||||
# Return source
|
||||
# Normalized mutation source
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def source
|
||||
Unparser.unparse(node)
|
||||
end
|
||||
memoize :source
|
||||
|
||||
# Return original source
|
||||
# Normalized original source
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def original_source
|
||||
subject.source
|
||||
end
|
||||
|
@ -57,7 +53,6 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.success?(test_result)
|
||||
self::TEST_PASS_SUCCESS.equal?(test_result.passed)
|
||||
end
|
||||
|
@ -71,7 +66,6 @@ module Mutant
|
|||
# @return [self]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def insert
|
||||
subject.public?
|
||||
subject.prepare
|
||||
|
@ -81,23 +75,21 @@ module Mutant
|
|||
|
||||
private
|
||||
|
||||
# Return sha1 sum of source and subject identification
|
||||
# SHA1 sum of source and subject identification
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def sha1
|
||||
Digest::SHA1.hexdigest(subject.identification + CODE_DELIMITER + source)
|
||||
end
|
||||
memoize :sha1
|
||||
|
||||
# Return mutated root node
|
||||
# Mutated root node
|
||||
#
|
||||
# @return [Parser::AST::Node]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def root
|
||||
subject.context.root(node)
|
||||
end
|
||||
|
|
|
@ -13,7 +13,6 @@ module Mutant
|
|||
# @return [self]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.each(input, parent = nil, &block)
|
||||
return to_enum(__method__, input, parent) unless block_given?
|
||||
REGISTRY.lookup(input).new(input, parent, block)
|
||||
|
@ -26,7 +25,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.handle(*types)
|
||||
types.each do |type|
|
||||
REGISTRY.register(type, self)
|
||||
|
@ -34,20 +32,18 @@ module Mutant
|
|||
end
|
||||
private_class_method :handle
|
||||
|
||||
# Return input
|
||||
# Mutation input
|
||||
#
|
||||
# @return [Object]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
attr_reader :input
|
||||
|
||||
# Return input
|
||||
# Parent context of input
|
||||
#
|
||||
# @return [Object]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
attr_reader :parent
|
||||
|
||||
private
|
||||
|
@ -61,7 +57,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def initialize(input, parent, block)
|
||||
@input, @parent, @block = input, parent, block
|
||||
@seen = Set.new
|
||||
|
@ -76,7 +71,6 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def new?(object)
|
||||
!@seen.include?(object)
|
||||
end
|
||||
|
@ -88,7 +82,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def guard(object)
|
||||
@seen << object
|
||||
end
|
||||
|
@ -98,7 +91,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
abstract_method :dispatch
|
||||
|
||||
# Emit generated mutation if object is not equivalent to input
|
||||
|
@ -108,7 +100,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit(object)
|
||||
return unless new?(object)
|
||||
|
||||
|
@ -124,7 +115,6 @@ module Mutant
|
|||
# @return [self]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit!(node)
|
||||
@block.call(node)
|
||||
self
|
||||
|
@ -135,7 +125,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def run(mutator)
|
||||
mutator.new(input, self, method(:emit))
|
||||
end
|
||||
|
@ -145,7 +134,6 @@ module Mutant
|
|||
# @return [Object]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dup_input
|
||||
input.dup
|
||||
end
|
||||
|
|
|
@ -19,7 +19,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.define_named_child(name, index)
|
||||
super
|
||||
|
||||
|
@ -35,28 +34,25 @@ module Mutant
|
|||
|
||||
private
|
||||
|
||||
# Return mutated node
|
||||
# Node to mutate
|
||||
#
|
||||
# @return [Parser::AST::Node]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
alias_method :node, :input
|
||||
|
||||
# Return duplicated node
|
||||
# Duplicate of original
|
||||
#
|
||||
# @return [Parser::AST::Node]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
alias_method :dup_node, :dup_input
|
||||
|
||||
# Return children
|
||||
# Original nodes children
|
||||
#
|
||||
# @return [Array<Parser::AST::Node>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def children
|
||||
node.children
|
||||
end
|
||||
|
@ -68,7 +64,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_child(index, mutator = Mutator, &block)
|
||||
block ||= TAUTOLOGY
|
||||
child = children.at(index)
|
||||
|
@ -85,7 +80,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def delete_child(index)
|
||||
dup_children = children.dup
|
||||
dup_children.delete_at(index)
|
||||
|
@ -100,7 +94,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_child_update(index, node)
|
||||
new_children = children.dup
|
||||
new_children[index] = node
|
||||
|
@ -114,7 +107,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_type(*children)
|
||||
emit(Parser::AST::Node.new(node.type, children))
|
||||
end
|
||||
|
@ -124,7 +116,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_singletons
|
||||
emit_nil
|
||||
emit_self
|
||||
|
@ -135,7 +126,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_self
|
||||
emit(N_SELF)
|
||||
end
|
||||
|
@ -145,7 +135,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_nil
|
||||
emit(N_NIL) unless asgn_left?
|
||||
end
|
||||
|
@ -157,14 +146,13 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_values(values)
|
||||
values.each do |value|
|
||||
emit_type(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Return parent node
|
||||
# Parent node
|
||||
#
|
||||
# @return [Parser::AST::Node] node
|
||||
# if parent with node is present
|
||||
|
@ -173,12 +161,11 @@ module Mutant
|
|||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def parent_node
|
||||
parent.node if parent
|
||||
end
|
||||
|
||||
# Return parent type
|
||||
# Parent type
|
||||
#
|
||||
# @return [Symbol] type
|
||||
# if parent with type is present
|
||||
|
@ -187,7 +174,6 @@ module Mutant
|
|||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def parent_type
|
||||
parent_node.type if parent_node
|
||||
end
|
||||
|
@ -197,19 +183,17 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def asgn_left?
|
||||
AST::Types::OP_ASSIGN.include?(parent_type) && parent.node.children.first.equal?(node)
|
||||
end
|
||||
|
||||
# Return children indices
|
||||
# Children indices
|
||||
#
|
||||
# @param [Range] range
|
||||
#
|
||||
# @return [Enumerable<Fixnum>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def children_indices(range)
|
||||
range_end = range.end
|
||||
last_index = range_end >= 0 ? range_end : children.length + range_end
|
||||
|
|
|
@ -16,7 +16,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
emit_left_mutations do |node|
|
||||
|
|
|
@ -17,7 +17,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_name_mutation
|
||||
end
|
||||
|
@ -27,7 +26,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_name_mutation
|
||||
return if skip?
|
||||
Mutator::Util::Symbol.each(name, self) do |name|
|
||||
|
@ -40,7 +38,6 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def skip?
|
||||
name.to_s.start_with?(UNDERSCORE)
|
||||
end
|
||||
|
@ -59,7 +56,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_name_mutation
|
||||
emit_required_mutation
|
||||
|
@ -71,7 +67,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_required_mutation
|
||||
emit(s(:arg, name))
|
||||
end
|
||||
|
|
|
@ -13,7 +13,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_argument_presence
|
||||
emit_argument_mutations
|
||||
|
@ -25,7 +24,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_argument_presence
|
||||
emit_type
|
||||
Mutator::Util::Array::Presence.each(children, self) do |children|
|
||||
|
@ -38,7 +36,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_argument_mutations
|
||||
children.each_with_index do |child, index|
|
||||
Mutator.each(child) do |mutant|
|
||||
|
@ -55,7 +52,6 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def invalid_argument_replacement?(mutant, index)
|
||||
original = children.fetch(index)
|
||||
|
||||
|
@ -69,7 +65,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_mlhs_expansion
|
||||
mlhs_childs_with_index.each do |child, index|
|
||||
dup_children = children.dup
|
||||
|
@ -79,12 +74,11 @@ module Mutant
|
|||
end
|
||||
end
|
||||
|
||||
# Return mlhs childs
|
||||
# Multiple left hand side childs
|
||||
#
|
||||
# @return [Enumerable<Parser::AST::Node, Fixnum>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mlhs_childs_with_index
|
||||
children.each_with_index.select do |child, _index|
|
||||
n_mlhs?(child)
|
||||
|
|
|
@ -14,7 +14,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
Util::Array.each(children, self, &method(:emit_child_subset))
|
||||
children.each_with_index do |child, index|
|
||||
|
@ -30,7 +29,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_child_subset(children)
|
||||
return if children.length < 2
|
||||
emit_type(*children)
|
||||
|
|
|
@ -20,7 +20,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
emit(left)
|
||||
|
@ -36,7 +35,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_operator
|
||||
emit(s(INVERSE.fetch(node.type), left, right))
|
||||
end
|
||||
|
@ -46,7 +44,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_operands
|
||||
emit(s(node.type, n_not(left), right))
|
||||
emit(n_not(node))
|
||||
|
|
|
@ -15,7 +15,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
emit(send)
|
||||
|
@ -30,7 +29,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_body
|
||||
emit_body(nil)
|
||||
emit_body(N_RAISE)
|
||||
|
|
|
@ -14,7 +14,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
super
|
||||
emit_singletons
|
||||
|
|
|
@ -16,7 +16,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
emit_condition_mutations if condition
|
||||
|
@ -29,7 +28,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_when_mutations
|
||||
indices = children.each_index.drop(1).take(children.length - 2)
|
||||
one = indices.one?
|
||||
|
@ -44,7 +42,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_else_mutations
|
||||
else_branch = children.last
|
||||
else_index = children.length - 1
|
||||
|
|
|
@ -16,7 +16,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
emit_condition_mutations
|
||||
|
|
|
@ -14,7 +14,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons unless parent_node && n_const?(parent_node)
|
||||
emit_type(nil, *children.drop(1))
|
||||
|
|
|
@ -11,7 +11,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_arguments_mutations
|
||||
emit_body(N_RAISE)
|
||||
|
|
|
@ -15,7 +15,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_expression_mutations do |node|
|
||||
!n_self?(node)
|
||||
|
|
|
@ -14,7 +14,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
super
|
||||
emit_singletons
|
||||
|
|
|
@ -14,7 +14,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
super
|
||||
emit_singletons
|
||||
|
|
|
@ -23,7 +23,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
children.each_with_index do |child, index|
|
||||
mutate_child(index) if child.instance_of?(Parser::AST::Node)
|
||||
|
|
|
@ -15,7 +15,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
mutate_condition
|
||||
|
@ -28,7 +27,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_condition
|
||||
emit_condition_mutations do |node|
|
||||
!n_self?(node)
|
||||
|
@ -43,7 +41,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_if_branch
|
||||
emit_type(condition, else_branch, nil) if else_branch
|
||||
return unless if_branch
|
||||
|
@ -57,7 +54,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_else_branch
|
||||
return unless else_branch
|
||||
emit(else_branch)
|
||||
|
|
|
@ -14,7 +14,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
super
|
||||
emit_singletons
|
||||
|
|
|
@ -14,7 +14,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
emit_type
|
||||
|
@ -28,7 +27,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_body
|
||||
children.each_index do |index|
|
||||
dup_children = children.dup
|
||||
|
|
|
@ -19,7 +19,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_nil
|
||||
emit(s(MAP.fetch(node.type)))
|
||||
|
|
|
@ -14,28 +14,25 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
emit_values(values)
|
||||
end
|
||||
|
||||
# Return values to mutate against
|
||||
# Values to mutate to
|
||||
#
|
||||
# @return [Array]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def values
|
||||
[0, 1, -value, value + 1, value - 1]
|
||||
end
|
||||
|
||||
# Return value
|
||||
# Literal original value
|
||||
#
|
||||
# @return [Object]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def value
|
||||
children.first
|
||||
end
|
||||
|
|
|
@ -14,7 +14,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
emit_values(values)
|
||||
|
@ -32,17 +31,15 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_special_cases
|
||||
SPECIAL.each(&method(:emit))
|
||||
end
|
||||
|
||||
# Return values to test against
|
||||
# Values to mutate to
|
||||
#
|
||||
# @return [Array]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def values
|
||||
original = children.first
|
||||
# Work around a bug in RBX/MRI or JRUBY:
|
||||
|
|
|
@ -14,7 +14,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
emit_type
|
||||
|
@ -26,7 +25,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_body
|
||||
children.each_index do |index|
|
||||
mutate_child(index)
|
||||
|
@ -50,7 +48,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_key_mutations
|
||||
emit_value_mutations
|
||||
|
|
|
@ -14,7 +14,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
emit_inverse
|
||||
|
@ -30,12 +29,11 @@ module Mutant
|
|||
emit_upper_bound_mutations
|
||||
end
|
||||
|
||||
# Return inverse node
|
||||
# Inverse node
|
||||
#
|
||||
# @return [Parser::AST::Node]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_inverse
|
||||
emit(s(MAP.fetch(node.type), *children))
|
||||
end
|
||||
|
@ -45,7 +43,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_upper_bound_mutations
|
||||
emit__end_mutations
|
||||
emit_type(N_NAN, _end)
|
||||
|
@ -56,7 +53,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_lower_bound_mutations
|
||||
emit_start_mutations
|
||||
emit_type(start, N_INFINITY)
|
||||
|
|
|
@ -12,12 +12,11 @@ module Mutant
|
|||
|
||||
private
|
||||
|
||||
# Return options
|
||||
# Original regexp options
|
||||
#
|
||||
# @return [Parser::AST::Node]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def options
|
||||
children.last
|
||||
end
|
||||
|
@ -27,7 +26,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons unless parent_node && n_match_current_line?(parent_node)
|
||||
children.each_with_index do |child, index|
|
||||
|
|
|
@ -14,7 +14,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
end
|
||||
|
|
|
@ -18,7 +18,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
Mutator::Util::Symbol.each(value, self) do |value|
|
||||
|
|
|
@ -16,7 +16,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
end
|
||||
|
|
|
@ -15,7 +15,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
emit_regexp_mutations
|
||||
|
|
|
@ -13,7 +13,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
children.each_index do |index|
|
||||
mutate_child(index)
|
||||
|
|
|
@ -15,7 +15,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
end
|
||||
|
|
|
@ -17,7 +17,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
mutate_name
|
||||
emit_value_mutations if value
|
||||
|
@ -28,7 +27,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_name
|
||||
Mutator::Util::Symbol.each(name, self) do |name|
|
||||
emit_name(name.upcase)
|
||||
|
|
|
@ -28,7 +28,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
mutate_name
|
||||
|
@ -40,7 +39,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_name
|
||||
prefix, regexp = MAP.fetch(node.type)
|
||||
stripped = name.to_s.sub(regexp, EMPTY_STRING)
|
||||
|
|
|
@ -14,7 +14,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
super
|
||||
emit_singletons
|
||||
|
|
|
@ -14,7 +14,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
# noop
|
||||
end
|
||||
|
|
|
@ -15,7 +15,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
unless number.equal?(1)
|
||||
emit_number(number - 1)
|
||||
|
|
|
@ -16,7 +16,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
emit_left_mutations do |node|
|
||||
|
|
|
@ -16,7 +16,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
emit_right_mutations
|
||||
|
|
|
@ -15,7 +15,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_assignment(nil)
|
||||
emit_body_mutations if body
|
||||
|
@ -27,7 +26,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_captures
|
||||
return unless captures
|
||||
Util::Array::Element.each(captures.children, self) do |matchers|
|
||||
|
|
|
@ -17,7 +17,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
mutate_body
|
||||
mutate_rescue_bodies
|
||||
|
@ -31,7 +30,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_rescue_bodies
|
||||
children_indices(RESCUE_INDICES).each do |index|
|
||||
rescue_body = children.at(index)
|
||||
|
@ -49,7 +47,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_concat(child)
|
||||
if body
|
||||
emit(s(:begin, body, child))
|
||||
|
@ -63,7 +60,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_body
|
||||
return unless body
|
||||
emit_body_mutations
|
||||
|
@ -75,7 +71,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_else_body
|
||||
return unless else_body
|
||||
emit_else_body_mutations
|
||||
|
|
|
@ -15,7 +15,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
return unless value
|
||||
|
|
|
@ -40,7 +40,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
if meta.index_assignment?
|
||||
|
@ -55,7 +54,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def non_index_dispatch
|
||||
if meta.binary_method_operator?
|
||||
run(Binary)
|
||||
|
@ -66,20 +64,21 @@ module Mutant
|
|||
end
|
||||
end
|
||||
|
||||
# Return AST metadata for node
|
||||
# AST metadata for node
|
||||
#
|
||||
# @return [AST::Meta::Send]
|
||||
#
|
||||
# @api private
|
||||
def meta
|
||||
AST::Meta::Send.new(node)
|
||||
end
|
||||
memoize :meta
|
||||
|
||||
# Return arguments
|
||||
# Arguments being send
|
||||
#
|
||||
# @return [Enumerable<Parser::AST::Node>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
alias_method :arguments, :remaining_children
|
||||
|
||||
# Perform normal, non special case dispatch
|
||||
|
@ -87,7 +86,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def normal_dispatch
|
||||
emit_naked_receiver
|
||||
emit_selector_replacement
|
||||
|
@ -101,7 +99,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_selector_replacement
|
||||
SELECTOR_REPLACEMENTS.fetch(selector, EMPTY_ARRAY).each do |replacement|
|
||||
emit_selector(replacement)
|
||||
|
@ -113,7 +110,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_naked_receiver
|
||||
emit(receiver) if receiver && !NOT_ASSIGNABLE.include?(receiver.type)
|
||||
end
|
||||
|
@ -123,7 +119,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_arguments
|
||||
emit_type(receiver, selector)
|
||||
remaining_children_with_index.each do |_node, index|
|
||||
|
@ -137,7 +132,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_argument_propagation
|
||||
node = arguments.first
|
||||
emit(node) if arguments.one? && !NOT_STANDALONE.include?(node.type)
|
||||
|
@ -148,7 +142,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_receiver
|
||||
return unless receiver
|
||||
emit_implicit_self
|
||||
|
@ -162,7 +155,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_implicit_self
|
||||
emit_receiver(nil) if n_self?(receiver) && !(
|
||||
KEYWORDS.include?(selector) ||
|
||||
|
|
|
@ -12,7 +12,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
normal_dispatch
|
||||
emit_attribute_read
|
||||
|
@ -23,7 +22,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_arguments
|
||||
remaining_children_indices.each do |index|
|
||||
mutate_child(index)
|
||||
|
@ -35,7 +33,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_attribute_read
|
||||
emit_type(receiver, selector.to_s[0..-2].to_sym)
|
||||
end
|
||||
|
|
|
@ -15,7 +15,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit(left)
|
||||
emit_left_mutations
|
||||
|
|
|
@ -19,7 +19,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_naked_receiver
|
||||
emit_value_mutations
|
||||
|
@ -33,7 +32,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_indices
|
||||
children_indices(INDEX_RANGE).each do |index|
|
||||
delete_child(index)
|
||||
|
@ -46,7 +44,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_index_read
|
||||
emit_type(receiver, :[], *children[INDEX_RANGE])
|
||||
end
|
||||
|
|
|
@ -15,7 +15,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
emit_expression_mutations
|
||||
|
|
|
@ -14,7 +14,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
emit(N_ZSUPER)
|
||||
|
|
|
@ -14,7 +14,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
if body
|
||||
mutate_body
|
||||
|
@ -29,7 +28,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_conditions
|
||||
conditions = children.length - 1
|
||||
children[0..-2].each_index do |index|
|
||||
|
@ -43,12 +41,11 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def mutate_body
|
||||
mutate_child(body_index)
|
||||
end
|
||||
|
||||
# Return body node
|
||||
# Body node
|
||||
#
|
||||
# @return [Parser::AST::Node]
|
||||
# if body is present
|
||||
|
@ -57,17 +54,15 @@ module Mutant
|
|||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def body
|
||||
children[body_index]
|
||||
end
|
||||
|
||||
# Return body index
|
||||
# Index of body node
|
||||
#
|
||||
# @return [Fixnum]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def body_index
|
||||
children.length - 1
|
||||
end
|
||||
|
|
|
@ -14,7 +14,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
super
|
||||
emit_singletons
|
||||
|
|
|
@ -14,7 +14,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_singletons
|
||||
end
|
||||
|
|
|
@ -8,7 +8,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def initialize
|
||||
@registry = {}
|
||||
end
|
||||
|
@ -21,10 +20,9 @@ module Mutant
|
|||
# @param [Symbol] type
|
||||
# @param [Class:Mutator] mutator
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
# @return [self]
|
||||
#
|
||||
# @api private
|
||||
def register(type, mutator)
|
||||
fail RegistryError, "Invalid type registration: #{type}" unless AST::Types::ALL.include?(type)
|
||||
fail RegistryError, "Duplicate type registration: #{type}" if @registry.key?(type)
|
||||
|
@ -42,7 +40,6 @@ module Mutant
|
|||
# raises argument error when mutator class cannot be found
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def lookup(node)
|
||||
type = node.type
|
||||
@registry.fetch(type) do
|
||||
|
|
|
@ -15,7 +15,6 @@ module Mutant
|
|||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.each(object, parent, &block)
|
||||
return to_enum(__method__, object, parent) unless block_given?
|
||||
|
||||
|
@ -33,7 +32,6 @@ module Mutant
|
|||
# @return [Boolean]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def new?(generated)
|
||||
!input.eql?(generated)
|
||||
end
|
||||
|
|
|
@ -15,7 +15,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
input.each_index do |index|
|
||||
dup = dup_input
|
||||
|
@ -36,7 +35,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
input.each_with_index do |element, index|
|
||||
Mutator.each(element).each do |mutation|
|
||||
|
@ -56,7 +54,6 @@ module Mutant
|
|||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
run(Element)
|
||||
run(Presence)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue