Module: Mutant

Defined in:
lib/mutant.rb,
lib/mutant/cli.rb,
lib/mutant/cache.rb,
lib/mutant/color.rb,
lib/mutant/config.rb,
lib/mutant/differ.rb,
lib/mutant/killer.rb,
lib/mutant/loader.rb,
lib/mutant/random.rb,
lib/mutant/runner.rb,
lib/mutant/walker.rb,
lib/mutant/context.rb,
lib/mutant/matcher.rb,
lib/mutant/mutator.rb,
lib/mutant/subject.rb,
lib/mutant/version.rb,
lib/mutant/mutation.rb,
lib/mutant/reporter.rb,
lib/mutant/strategy.rb,
lib/mutant/constants.rb,
lib/mutant/zombifier.rb,
lib/mutant/matcher/null.rb,
lib/mutant/mutator/node.rb,
lib/mutant/mutator/util.rb,
lib/mutant/node_helpers.rb,
lib/mutant/reporter/cli.rb,
lib/mutant/context/scope.rb,
lib/mutant/killer/forked.rb,
lib/mutant/killer/static.rb,
lib/mutant/matcher/chain.rb,
lib/mutant/matcher/scope.rb,
lib/mutant/mutation/evil.rb,
lib/mutant/reporter/null.rb,
lib/mutant/runner/config.rb,
lib/mutant/cli/classifier.rb,
lib/mutant/killer/forking.rb,
lib/mutant/matcher/filter.rb,
lib/mutant/matcher/method.rb,
lib/mutant/runner/subject.rb,
lib/mutant/subject/method.rb,
lib/mutant/matcher/methods.rb,
lib/mutant/mutator/node/if.rb,
lib/mutant/runner/mutation.rb,
lib/mutant/mutation/neutral.rb,
lib/mutant/mutator/registry.rb,
lib/mutant/matcher/namespace.rb,
lib/mutant/mutator/node/case.rb,
lib/mutant/mutator/node/dstr.rb,
lib/mutant/mutator/node/dsym.rb,
lib/mutant/mutator/node/mlhs.rb,
lib/mutant/mutator/node/noop.rb,
lib/mutant/mutator/node/send.rb,
lib/mutant/mutator/node/when.rb,
lib/mutant/singleton_methods.rb,
lib/mutant/mutator/node/begin.rb,
lib/mutant/mutator/node/block.rb,
lib/mutant/mutator/node/const.rb,
lib/mutant/mutator/node/masgn.rb,
lib/mutant/mutator/node/splat.rb,
lib/mutant/mutator/node/super.rb,
lib/mutant/mutator/node/yield.rb,
lib/mutant/mutator/util/array.rb,
lib/mutant/mutator/node/binary.rb,
lib/mutant/mutator/node/define.rb,
lib/mutant/mutator/node/nthref.rb,
lib/mutant/mutator/node/return.rb,
lib/mutant/mutator/node/zsuper.rb,
lib/mutant/mutator/util/symbol.rb,
lib/mutant/mutator/node/generic.rb,
lib/mutant/mutator/node/kwbegin.rb,
lib/mutant/mutator/node/literal.rb,
lib/mutant/mutator/node/op_asgn.rb,
lib/mutant/mutator/node/resbody.rb,
lib/mutant/mutator/node/restarg.rb,
lib/mutant/reporter/cli/printer.rb,
lib/mutant/cli/classifier/method.rb,
lib/mutant/matcher/method/finder.rb,
lib/mutant/mutator/node/argument.rb,
lib/mutant/mutator/node/blockarg.rb,
lib/mutant/mutator/node/arguments.rb,
lib/mutant/matcher/method/instance.rb,
lib/mutant/subject/method/instance.rb,
lib/mutant/cli/classifier/namespace.rb,
lib/mutant/matcher/method/singleton.rb,
lib/mutant/mutator/node/literal/nil.rb,
lib/mutant/mutator/node/send/binary.rb,
lib/mutant/subject/method/singleton.rb,
lib/mutant/mutator/node/literal/hash.rb,
lib/mutant/mutator/node/loop_control.rb,
lib/mutant/mutator/node/literal/array.rb,
lib/mutant/mutator/node/literal/float.rb,
lib/mutant/mutator/node/literal/range.rb,
lib/mutant/mutator/node/literal/regex.rb,
lib/mutant/mutator/node/literal/fixnum.rb,
lib/mutant/mutator/node/literal/string.rb,
lib/mutant/mutator/node/literal/symbol.rb,
lib/mutant/reporter/cli/printer/config.rb,
lib/mutant/reporter/cli/printer/killer.rb,
lib/mutant/mutator/node/literal/boolean.rb,
lib/mutant/mutator/node/literal/dynamic.rb,
lib/mutant/reporter/cli/printer/subject.rb,
lib/mutant/mutator/node/conditional_loop.rb,
lib/mutant/reporter/cli/printer/mutation.rb,
lib/mutant/mutator/node/named_value/access.rb,
lib/mutant/mutator/node/named_value/constant_assignment.rb,
lib/mutant/mutator/node/named_value/variable_assignment.rb

Overview

Singleton methods are defined here so zombie can pick them up

Defined Under Namespace

Modules: NodeHelpers, Random, Zombifier Classes: CLI, Cache, Color, Config, Context, Differ, Killer, Loader, Matcher, Mutation, Mutator, Reporter, Runner, Strategy, Subject, Walker

Constant Summary collapse

EMPTY_STRING =

The empty string used within this namespace

''.freeze
VERSION =

The current mutant version

'0.5.1'.freeze
NOT_ASSIGNABLE =

Set of nodes that cannot be on the LHS of an assignment

symbolset %w(
  int float str dstr class module self
)
OP_ASSIGN =

Set of op-assign types

symbolset %w(or_asgn and_asgn op_asgn)
NOT_STANDALONE =

Set of node types that are not valid when emitted standalone

symbolset %w( splat restarg block_pass)
INDEX_OPERATORS =
symbolset %w([] []=)
UNARY_METHOD_OPERATORS =
symbolset %w(~@ +@ -@ !)
METHOD_OPERATORS =

Operators ruby implementeds as methods

symbolset %w(
  <=> === []= [] <= >= == !~ != =~ <<
  >> ** * % / | ^ & < > + - ~@ +@ -@ !
)
BINARY_METHOD_OPERATORS =
(
  METHOD_OPERATORS - (INDEX_OPERATORS + UNARY_METHOD_OPERATORS)
).to_set.freeze
OPERATOR_METHODS =
(
  METHOD_OPERATORS + INDEX_OPERATORS + UNARY_METHOD_OPERATORS
).to_set.freeze
NODE_BLACKLIST =

Nodes that are NOT handled by mutant.

not - 1.8 only, mutant does not support 1.8

symbolset %w(not)
NODE_EXTRA =

Nodes that are NOT generated by parser but used by mutant / unparser.

symbolset %w(empty)
NODE_TYPES =
((Parser::Meta::NODE_TYPES + NODE_EXTRA) - NODE_BLACKLIST).to_set.freeze

Class Method Summary collapse

Class Method Details

.singleton_subclass_instance(name, superclass, &block) ⇒ self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Define instance of subclassed superclass as constant

Parameters:

  • superclass (Class)
  • name (Symbol)

Returns:

  • (self)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/mutant/singleton_methods.rb', line 15

def self.singleton_subclass_instance(name, superclass, &block)
  klass = Class.new(superclass) do
    def inspect
      self.class.name
    end

    define_singleton_method(:name) do
      "#{superclass.name}::#{name}".freeze
    end
  end
  klass.class_eval(&block)
  superclass.const_set(name, klass.new)
  self
end