free_mutant/lib/mutant/mutator/literal/float.rb
Markus Schirp 75e6a229f8 Create namespace for literal mutations
* Do not follow rubinius names anymore.
  An explict declaration now declares a mutator handles
  specific AST node.

* Has a nice impact on metrics.
2012-07-31 19:45:46 +02:00

36 lines
710 B
Ruby

module Mutant
class Mutator
class Literal < Mutator
# Represent mutations on fixnum literal
class Float < Literal
handle(Rubinius::AST::FloatLiteral)
private
# Emit mutants
#
# @return [undefined]
#
def dispatch
emit_nil
emit_values(values)
emit_safe(infinity)
emit_safe(negative_infinity)
emit_safe(nan)
emit_new { new_self(Mutant.random_float) }
end
# Return values to test against
#
# @return [Array]
#
# @api private
#
def values
[0.0, 1.0] << -node.value
end
end
end
end
end