Sha256: 061f76bc4f5fb51b8be02fc246d6aced46ece2efad6582c15919402e18e79c93

Contents?: true

Size: 1.49 KB

Versions: 6

Compression:

Stored size: 1.49 KB

Contents

module Mutant
  class Mutator
    class Node
      # Abstract mutator for literal AST nodes
      class Literal < self
        include AbstractType

      private

        # Return new float literal
        #
        # @param [#to_f] value
        #
        # @return [Rubinius::Node::FloatLiteral]
        #
        # @api private
        #
        def new_float(value)
          new(Rubinius::AST::FloatLiteral, value)
        end

        # Emit a new node with wrapping class for each entry in values
        #
        # @param [Array] values
        #
        # @return [undefined]
        #
        # @api private
        #
        def emit_values(values)
          values.each do |value|
            emit_self(value)
          end
        end

        # Return AST representing NaN
        #
        # @return [Rubinius::Node::AST]
        #
        # @api private
        #
        def nan
          zero_float = new_float(0)
          new_send_with_arguments(zero_float, :/, zero_float)
        end

        # Return AST representing negative infinity
        #
        # @return [Rubinius::Node::AST]
        #
        # @api private
        #
        def negative_infinity
          new_send_with_arguments(new_float(-1), :/, new_float(0))
        end

        # Return AST representing infinity
        #
        # @return [Rubinius::Node::AST]
        #
        # @api private
        #
        def infinity
          new_send_with_arguments(new_float(1), :/, new_float(0))
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mutant-0.2.20 lib/mutant/mutator/node/literal.rb
mutant-0.2.17 lib/mutant/mutator/node/literal.rb
mutant-0.2.16 lib/mutant/mutator/node/literal.rb
mutant-0.2.15 lib/mutant/mutator/node/literal.rb
mutant-0.2.14 lib/mutant/mutator/node/literal.rb
mutant-0.2.13 lib/mutant/mutator/node/literal.rb