Sha256: 91d951ce5471efde5bda74251317c7c029fb2a56e218a84bce86301ca80d4d7e

Contents?: true

Size: 1.3 KB

Versions: 22

Compression:

Stored size: 1.3 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
            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

22 entries across 22 versions & 1 rubygems

Version Path
mutant-0.5.12 lib/mutant/mutator/node/literal/float.rb
mutant-0.5.11 lib/mutant/mutator/node/literal/float.rb
mutant-0.5.10 lib/mutant/mutator/node/literal/float.rb
mutant-0.5.9 lib/mutant/mutator/node/literal/float.rb
mutant-0.5.8 lib/mutant/mutator/node/literal/float.rb
mutant-0.5.7 lib/mutant/mutator/node/literal/float.rb
mutant-0.5.6 lib/mutant/mutator/node/literal/float.rb
mutant-0.5.5 lib/mutant/mutator/node/literal/float.rb
mutant-0.5.4 lib/mutant/mutator/node/literal/float.rb
mutant-0.5.3 lib/mutant/mutator/node/literal/float.rb
mutant-0.5.2 lib/mutant/mutator/node/literal/float.rb
mutant-0.5.1 lib/mutant/mutator/node/literal/float.rb
mutant-0.5.0 lib/mutant/mutator/node/literal/float.rb
mutant-0.3.6 lib/mutant/mutator/node/literal/float.rb
mutant-0.3.5 lib/mutant/mutator/node/literal/float.rb
mutant-0.3.4 lib/mutant/mutator/node/literal/float.rb
mutant-0.3.3 lib/mutant/mutator/node/literal/float.rb
mutant-0.3.2 lib/mutant/mutator/node/literal/float.rb
mutant-0.3.1 lib/mutant/mutator/node/literal/float.rb
mutant-0.3.0 lib/mutant/mutator/node/literal/float.rb