2013-07-28 19:03:06 -04:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2012-12-06 15:30:28 -05:00
|
|
|
module Mutant
|
|
|
|
class Mutator
|
|
|
|
class Node
|
|
|
|
class Literal
|
2013-06-04 04:25:13 -04:00
|
|
|
|
2012-12-06 15:30:28 -05:00
|
|
|
# Abstract literal range mutator
|
|
|
|
class Range < self
|
|
|
|
|
2013-06-14 12:22:34 -04:00
|
|
|
MAP = {
|
2013-09-07 14:27:06 -04:00
|
|
|
irange: :erange,
|
|
|
|
erange: :irange
|
2013-06-14 12:22:34 -04:00
|
|
|
}.freeze
|
|
|
|
|
2013-06-21 09:31:20 -04:00
|
|
|
children :start, :_end
|
2013-06-14 12:22:34 -04:00
|
|
|
|
|
|
|
handle(*MAP.keys)
|
|
|
|
|
2012-12-06 15:30:28 -05:00
|
|
|
private
|
|
|
|
|
|
|
|
# Emit mutants
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def dispatch
|
|
|
|
emit_nil
|
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
|
2012-12-06 15:30:28 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
# Return inverse node
|
|
|
|
#
|
2013-06-04 04:25:13 -04:00
|
|
|
# @return [Parser::AST::Node]
|
2012-12-06 15:30:28 -05:00
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2013-06-14 12:22:34 -04:00
|
|
|
def emit_inverse
|
|
|
|
emit(s(MAP.fetch(node.type), *children))
|
2012-12-06 15:30:28 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
# Emit range start mutations
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2013-09-02 14:38:54 -04:00
|
|
|
def emit_upper_bound_mutations
|
2013-09-02 14:49:52 -04:00
|
|
|
emit__end_mutations
|
2013-06-21 09:31:20 -04:00
|
|
|
emit_self(NAN, _end)
|
2012-12-06 15:30:28 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
# Emit start mutations
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2013-09-02 14:38:54 -04:00
|
|
|
def emit_lower_bound_mutations
|
2013-09-02 14:49:52 -04:00
|
|
|
emit_start_mutations
|
2013-06-14 12:22:34 -04:00
|
|
|
emit_self(start, INFINITY)
|
|
|
|
emit_self(start, NAN)
|
2012-12-06 15:30:28 -05:00
|
|
|
end
|
|
|
|
|
2013-06-04 04:25:13 -04:00
|
|
|
end # Range
|
|
|
|
end # Literal
|
|
|
|
end # Node
|
|
|
|
end # Mutator
|
|
|
|
end # Mutant
|