75e6a229f8
* Do not follow rubinius names anymore. An explict declaration now declares a mutator handles specific AST node. * Has a nice impact on metrics.
51 lines
995 B
Ruby
51 lines
995 B
Ruby
module Mutant
|
|
class Mutator
|
|
# Abstract mutator for literal AST nodes
|
|
class Literal < Mutator
|
|
|
|
private
|
|
|
|
# Return new float literal
|
|
#
|
|
# @param [#to_f] value
|
|
#
|
|
# @return [Rubinius::Node::FloatLiteral]
|
|
#
|
|
# @api private
|
|
#
|
|
def new_float(value)
|
|
new(Rubinius::AST::FloatLiteral, value)
|
|
end
|
|
|
|
# Return AST representing NaN
|
|
#
|
|
# @return [Rubinius::Node::AST]
|
|
#
|
|
# @api private
|
|
#
|
|
def nan
|
|
new_call(new_float(0), :/, new_float(0))
|
|
end
|
|
|
|
# Return AST representing negative infinity
|
|
#
|
|
# @return [Rubinius::Node::AST]
|
|
#
|
|
# @api private
|
|
#
|
|
def negative_infinity
|
|
new(Rubinius::AST::Negate, infinity)
|
|
end
|
|
|
|
# Return AST representing infinity
|
|
#
|
|
# @return [Rubinius::Node::AST]
|
|
#
|
|
# @api private
|
|
#
|
|
def infinity
|
|
new_call(new_float(1), :/, new_float(0))
|
|
end
|
|
end
|
|
end
|
|
end
|