Sha256: e3ccbc2f7b276e99b7cda5a8cf1aa82e90590cd2de8b66f13227b51493ca19ff

Contents?: true

Size: 1.26 KB

Versions: 6

Compression:

Stored size: 1.26 KB

Contents

# encoding: utf-8

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_nil
            emit_values(values)
            emit_special_cases
          end

          SPECIAL = [
            NodeHelpers::NAN,
            NodeHelpers::NEGATIVE_INFINITY,
            NodeHelpers::INFINITY
          ].freeze

          # Emit special cases
          #
          # @return [undefined]
          #
          # @api private
          #
          def emit_special_cases
            SPECIAL.each do |value|
              emit(value)
            end
          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

6 entries across 6 versions & 1 rubygems

Version Path
mutant-0.5.18 lib/mutant/mutator/node/literal/float.rb
mutant-0.5.17 lib/mutant/mutator/node/literal/float.rb
mutant-0.5.16 lib/mutant/mutator/node/literal/float.rb
mutant-0.5.15 lib/mutant/mutator/node/literal/float.rb
mutant-0.5.14 lib/mutant/mutator/node/literal/float.rb
mutant-0.5.13 lib/mutant/mutator/node/literal/float.rb