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