Sha256: 12fdd9c345e29205af6d953bb3b40baf482562820a9f33a08b3e2703544b817f

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 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
            emit_new { new_self(Random.float) }
          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
            [0.0, 1.0, -children.first]
          end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mutant-0.3.0.rc3 lib/mutant/mutator/node/literal/float.rb
mutant-0.3.0.rc2 lib/mutant/mutator/node/literal/float.rb
mutant-0.3.0.rc1 lib/mutant/mutator/node/literal/float.rb