free_mutant/lib/mutant/mutator/node/literal/range.rb

71 lines
1.4 KiB
Ruby
Raw Normal View History

module Mutant
class Mutator
class Node
class Literal
# Abstract literal range mutator
class Range < self
2013-06-14 12:22:34 -04:00
MAP = {
irange: :erange,
erange: :irange
2013-06-14 12:22:34 -04:00
}.freeze
children :start, :_end
2013-06-14 12:22:34 -04:00
handle(*MAP.keys)
private
# Emit mutants
#
# @return [undefined]
#
# @api private
#
def dispatch
emit_singletons
2013-06-14 12:22:34 -04:00
emit_inverse
2013-09-02 14:38:54 -04:00
emit_lower_bound_mutations
emit_upper_bound_mutations
end
# Return inverse node
#
# @return [Parser::AST::Node]
#
# @api private
#
2013-06-14 12:22:34 -04:00
def emit_inverse
emit(s(MAP.fetch(node.type), *children))
end
# Emit range start mutations
#
# @return [undefined]
#
# @api private
#
2013-09-02 14:38:54 -04:00
def emit_upper_bound_mutations
emit__end_mutations
2014-06-16 06:56:27 -04:00
emit_type(N_NAN, _end)
end
# Emit start mutations
#
# @return [undefined]
#
# @api private
#
2013-09-02 14:38:54 -04:00
def emit_lower_bound_mutations
emit_start_mutations
2014-06-16 06:56:27 -04:00
emit_type(start, N_INFINITY)
emit_type(start, N_NAN)
end
end # Range
end # Literal
end # Node
end # Mutator
end # Mutant