Class: Mutiny::Mutants::Mutation::Method::UnaryArithmeticOperatorDeletion

Inherits:
Mutiny::Mutants::Mutation show all
Defined in:
lib/mutiny/mutants/mutation/method/unary_arithmetic_operator_deletion.rb

Instance Method Summary collapse

Methods inherited from Mutiny::Mutants::Mutation

#name, #short_name

Instance Method Details

#patternObject

rubocop:disable Metrics/AbcSize



8
9
10
11
12
13
14
# File 'lib/mutiny/mutants/mutation/method/unary_arithmetic_operator_deletion.rb', line 8

def pattern # rubocop:disable Metrics/AbcSize
  builder.either!(
    builder.literal!(:int, builder.VAL { |val| val.name < 0 }),
    builder.literal!(:float, builder.VAL { |val| val.name < 0 }),
    builder.literal!(:send, builder.VAL, :-@)
  )
end

#replacementObject



16
17
18
19
20
21
22
23
24
# File 'lib/mutiny/mutants/mutation/method/unary_arithmetic_operator_deletion.rb', line 16

def replacement
  builder.derivation! :val, :& do |val, root|
    if val.name.is_a?(Numeric)
      builder.literal!(root.name, -val.name)
    else
      val
    end
  end
end