Class: Evilution::Mutator::Registry Private

Inherits:
Object
  • Object
show all
Defined in:
lib/evilution/mutator/registry.rb

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

Constant Summary collapse

STRICT_EXTRA_OPERATORS =

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

[
  Evilution::Mutator::Operator::PredicateToNil
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRegistry

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.

Returns a new instance of Registry.



107
108
109
# File 'lib/evilution/mutator/registry.rb', line 107

def initialize
  @operators = []
end

Class Method Details

.defaultObject

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.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/evilution/mutator/registry.rb', line 26

def self.default
  registry = new
  [
    Evilution::Mutator::Operator::ComparisonReplacement,
    Evilution::Mutator::Operator::ArithmeticReplacement,
    Evilution::Mutator::Operator::BooleanOperatorReplacement,
    Evilution::Mutator::Operator::BooleanLiteralReplacement,
    Evilution::Mutator::Operator::NilReplacement,
    Evilution::Mutator::Operator::IntegerLiteral,
    Evilution::Mutator::Operator::FloatLiteral,
    Evilution::Mutator::Operator::StringLiteral,
    Evilution::Mutator::Operator::ArrayLiteral,
    Evilution::Mutator::Operator::HashLiteral,
    Evilution::Mutator::Operator::SymbolLiteral,
    Evilution::Mutator::Operator::ConditionalNegation,
    Evilution::Mutator::Operator::ConditionalBranch,
    Evilution::Mutator::Operator::LastExpressionRemoval,
    Evilution::Mutator::Operator::StatementDeletion,
    Evilution::Mutator::Operator::MethodBodyReplacement,
    Evilution::Mutator::Operator::NegationInsertion,
    Evilution::Mutator::Operator::ReturnValueRemoval,
    Evilution::Mutator::Operator::CollectionReplacement,
    Evilution::Mutator::Operator::ArgumentMethodCallReplacement,
    Evilution::Mutator::Operator::MethodCallRemoval,
    Evilution::Mutator::Operator::ArgumentRemoval,
    Evilution::Mutator::Operator::BlockRemoval,
    Evilution::Mutator::Operator::BlockPassRemoval,
    Evilution::Mutator::Operator::ConditionalFlip,
    Evilution::Mutator::Operator::RangeReplacement,
    Evilution::Mutator::Operator::RegexpMutation,
    Evilution::Mutator::Operator::RegexSimplification,
    Evilution::Mutator::Operator::ReceiverReplacement,
    Evilution::Mutator::Operator::SendMutation,
    Evilution::Mutator::Operator::ArgumentNilSubstitution,
    Evilution::Mutator::Operator::CompoundAssignment,
    Evilution::Mutator::Operator::MixinRemoval,
    Evilution::Mutator::Operator::SuperclassRemoval,
    Evilution::Mutator::Operator::LocalVariableAssignment,
    Evilution::Mutator::Operator::InstanceVariableWrite,
    Evilution::Mutator::Operator::ClassVariableWrite,
    Evilution::Mutator::Operator::GlobalVariableWrite,
    Evilution::Mutator::Operator::RescueRemoval,
    Evilution::Mutator::Operator::RescueBodyReplacement,
    Evilution::Mutator::Operator::InlineRescue,
    Evilution::Mutator::Operator::EnsureRemoval,
    Evilution::Mutator::Operator::BreakStatement,
    Evilution::Mutator::Operator::NextStatement,
    Evilution::Mutator::Operator::RedoStatement,
    Evilution::Mutator::Operator::BangMethod,
    Evilution::Mutator::Operator::BitwiseReplacement,
    Evilution::Mutator::Operator::BitwiseComplement,
    Evilution::Mutator::Operator::ZsuperRemoval,
    Evilution::Mutator::Operator::ExplicitSuperMutation,
    Evilution::Mutator::Operator::IndexToAt,
    Evilution::Mutator::Operator::IndexToFetch,
    Evilution::Mutator::Operator::IndexToDig,
    Evilution::Mutator::Operator::IndexAssignmentRemoval,
    Evilution::Mutator::Operator::PatternMatchingGuard,
    Evilution::Mutator::Operator::PatternMatchingAlternative,
    Evilution::Mutator::Operator::PatternMatchingArray,
    Evilution::Mutator::Operator::CollectionReturn,
    Evilution::Mutator::Operator::ScalarReturn,
    Evilution::Mutator::Operator::KeywordArgument,
    Evilution::Mutator::Operator::MultipleAssignment,
    Evilution::Mutator::Operator::YieldStatement,
    Evilution::Mutator::Operator::SplatOperator,
    Evilution::Mutator::Operator::DefinedCheck,
    Evilution::Mutator::Operator::RegexCapture,
    Evilution::Mutator::Operator::LoopFlip,
    Evilution::Mutator::Operator::StringInterpolation,
    Evilution::Mutator::Operator::RetryRemoval,
    Evilution::Mutator::Operator::CaseWhen,
    Evilution::Mutator::Operator::PredicateReplacement,
    Evilution::Mutator::Operator::EqualityToIdentity,
    Evilution::Mutator::Operator::LambdaBody,
    Evilution::Mutator::Operator::BeginUnwrap,
    Evilution::Mutator::Operator::BlockParamRemoval
  ].each { |op| registry.register(op) }
  registry
end

.for_profile(profile) ⇒ Object

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.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/evilution/mutator/registry.rb', line 10

def self.for_profile(profile)
  unless profile.is_a?(Symbol) || profile.is_a?(String)
    raise ArgumentError, "unknown profile: #{profile.inspect} (expected :default or :strict)"
  end

  case profile.to_sym
  when :default then default
  when :strict
    registry = default
    STRICT_EXTRA_OPERATORS.each { |op| registry.register(op) }
    registry
  else
    raise ArgumentError, "unknown profile: #{profile.inspect} (expected :default or :strict)"
  end
end

Instance Method Details

#mutations_for(subject, filter: nil, operator_options: {}) ⇒ Object

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.



116
117
118
119
120
121
# File 'lib/evilution/mutator/registry.rb', line 116

def mutations_for(subject, filter: nil, operator_options: {})
  @operators.flat_map do |operator_class|
    operator = build_operator(operator_class, operator_options)
    operator.call(subject, filter: filter)
  end
end

#operator_countObject

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.



123
124
125
# File 'lib/evilution/mutator/registry.rb', line 123

def operator_count
  @operators.length
end

#operatorsObject

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.



127
128
129
# File 'lib/evilution/mutator/registry.rb', line 127

def operators
  @operators.dup
end

#register(operator_class) ⇒ Object

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.



111
112
113
114
# File 'lib/evilution/mutator/registry.rb', line 111

def register(operator_class)
  @operators << operator_class
  self
end