2012-07-31 13:45:46 -04:00
|
|
|
module Mutant
|
|
|
|
class Mutator
|
2012-08-09 17:07:22 -04:00
|
|
|
class Literal < self
|
2012-07-31 13:45:46 -04:00
|
|
|
# Represent mutations on fixnum literal
|
2012-08-09 17:07:22 -04:00
|
|
|
class Float < self
|
2012-07-31 13:45:46 -04:00
|
|
|
|
|
|
|
handle(Rubinius::AST::FloatLiteral)
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
# Emit mutants
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
def dispatch
|
|
|
|
emit_nil
|
|
|
|
emit_values(values)
|
2012-08-15 15:03:54 -04:00
|
|
|
emit_special_cases
|
2012-07-31 14:11:37 -04:00
|
|
|
emit_new { new_self(Random.float) }
|
2012-07-31 13:45:46 -04:00
|
|
|
end
|
|
|
|
|
2012-08-15 15:03:54 -04:00
|
|
|
# Emit special cases
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def emit_special_cases
|
|
|
|
[infinity, negative_infinity, nan].each do |value|
|
2012-08-15 15:13:05 -04:00
|
|
|
emit(value)
|
2012-08-15 15:03:54 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-31 13:45:46 -04:00
|
|
|
# Return values to test against
|
|
|
|
#
|
|
|
|
# @return [Array]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def values
|
|
|
|
[0.0, 1.0] << -node.value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|