13f3c2f119
This occurance was a leftover and abstract type gained the ability to prevent instantiation of non base classes lately.
72 lines
1.4 KiB
Ruby
72 lines
1.4 KiB
Ruby
# encoding: utf-8
|
|
|
|
module Mutant
|
|
class Mutator
|
|
class Node
|
|
class Literal
|
|
|
|
# Abstract literal range mutator
|
|
class Range < self
|
|
|
|
MAP = {
|
|
irange: :erange,
|
|
erange: :irange
|
|
}.freeze
|
|
|
|
children :start, :_end
|
|
|
|
handle(*MAP.keys)
|
|
|
|
private
|
|
|
|
# Emit mutants
|
|
#
|
|
# @return [undefined]
|
|
#
|
|
# @api private
|
|
#
|
|
def dispatch
|
|
emit_nil
|
|
emit_inverse
|
|
emit_lower_bound_mutations
|
|
emit_upper_bound_mutations
|
|
end
|
|
|
|
# Return inverse node
|
|
#
|
|
# @return [Parser::AST::Node]
|
|
#
|
|
# @api private
|
|
#
|
|
def emit_inverse
|
|
emit(s(MAP.fetch(node.type), *children))
|
|
end
|
|
|
|
# Emit range start mutations
|
|
#
|
|
# @return [undefined]
|
|
#
|
|
# @api private
|
|
#
|
|
def emit_upper_bound_mutations
|
|
emit__end_mutations
|
|
emit_self(NAN, _end)
|
|
end
|
|
|
|
# Emit start mutations
|
|
#
|
|
# @return [undefined]
|
|
#
|
|
# @api private
|
|
#
|
|
def emit_lower_bound_mutations
|
|
emit_start_mutations
|
|
emit_self(start, INFINITY)
|
|
emit_self(start, NAN)
|
|
end
|
|
|
|
end # Range
|
|
end # Literal
|
|
end # Node
|
|
end # Mutator
|
|
end # Mutant
|