class Mutest::AST::Meta::Send

Metadata for send nodes

Constants

ATTRIBUTE_ASSIGNMENT_SELECTOR_SUFFIX
INDEX_ASSIGNMENT_SELECTOR
METHOD_METHOD_SELECTORS

Public Instance Methods

attribute_assignment?() click to toggle source

Test if AST node is a valid attribute assignment

@return [Boolean]

# File lib/mutest/ast/meta/send.rb, line 36
def attribute_assignment?
  !Types::METHOD_OPERATORS.include?(selector) &&
    selector.to_s.end_with?(ATTRIBUTE_ASSIGNMENT_SELECTOR_SUFFIX)
end
binary_method_operator?() click to toggle source

Test for binary operator implemented as method

@return [Boolean]

# File lib/mutest/ast/meta/send.rb, line 44
def binary_method_operator?
  Types::BINARY_METHOD_OPERATORS.include?(selector)
end
method_object_selector?() click to toggle source

Test if this is a selector that returns a method object

# File lib/mutest/ast/meta/send.rb, line 58
def method_object_selector?
  METHOD_METHOD_SELECTORS.include?(selector)
end
proc?() click to toggle source

Test if node is defining a proc

@return [Boolean]

# File lib/mutest/ast/meta/send.rb, line 29
def proc?
  naked_proc? || proc_new?
end
receiver_possible_top_level_const?() click to toggle source

Test if receiver is possibly a top level constant

@return [Boolean]

# File lib/mutest/ast/meta/send.rb, line 51
def receiver_possible_top_level_const?
  return false unless receiver && n_const?(receiver)

  Const.new(receiver).possible_top_level?
end

Private Instance Methods

naked_proc?() click to toggle source

Test if node is `proc { … }`

@return [Boolean]

# File lib/mutest/ast/meta/send.rb, line 67
def naked_proc?
  !receiver && selector.equal?(:proc)
end
proc_new?() click to toggle source

Test if node is `Proc.new { … }`

@return [Boolean]

# File lib/mutest/ast/meta/send.rb, line 74
def proc_new?
  receiver                &&
    selector.equal?(:new) &&
    n_const?(receiver)    &&
    Const.new(receiver).name.equal?(:Proc)
end