Sha256: 270dddae226b0358e9f94962354709a0e39f2224d68e7ef1440f3c52ebdf5297

Contents?: true

Size: 1.18 KB

Versions: 21

Compression:

Stored size: 1.18 KB

Contents

module Mutant
  class Mutator
    class Node
      class Literal < self
        # Mutator for float literals
        class Float < self

          handle(:float)

        private

          # Emit mutants
          #
          # @return [undefined]
          #
          # @api private
          #
          def dispatch
            emit_singletons
            emit_values(values)
            emit_special_cases
          end

          SPECIAL = [
            N_NAN,
            N_NEGATIVE_INFINITY,
            N_INFINITY
          ].freeze

          # Emit special cases
          #
          # @return [undefined]
          #
          # @api private
          #
          def emit_special_cases
            SPECIAL.each(&method(:emit))
          end

          # Return values to test against
          #
          # @return [Array]
          #
          # @api private
          #
          def values
            original = children.first
            # Work around a bug in RBX/MRI or JRUBY:
            [0.0, 1.0, -original].delete_if do |value|
              value.eql?(original)
            end
          end

        end # Float
      end # Literal
    end # Node
  end # Mutator
end # Mutant

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
mutant-0.5.23 lib/mutant/mutator/node/literal/float.rb