============
empty method
============

def foo
end

def foo?
end

def foo!
end

---

(program
  (method (identifier))
  (method (identifier))
  (method (identifier)))

=====================
method with body
=====================

def foo
  bar
end

---

(program (method (identifier) (identifier)))

===========================
method as attribute setter
===========================

def foo=
end

---

(program (method (setter (identifier))))

==============================
method definition of operators
==============================

def `(a)
  "`"
end

def -@(a)
end

def %(a)
end

def ..(a)
end

def !~(a)
end

---

(program
  (method (operator) (method_parameters (identifier)) (string))
  (method (operator) (method_parameters (identifier)))
  (method (operator) (method_parameters (identifier)))
  (method (operator) (method_parameters (identifier)))
  (method (operator) (method_parameters (identifier))))

===================================================
method with forward slash name and regex ambiguity
===================================================

puts /(/

def /(name)
end

def / name
end

---

(program
  (method_call (identifier) (argument_list (regex)))
  (method (operator) (method_parameters (identifier)))
  (method (operator) (method_parameters (identifier))))


===========================
method with call to super
===========================

def foo
  super
end

def foo
  bar.baz { super }
end

def foo
  super.bar a, b
end

---

(program
  (method (identifier) (super))
  (method
    (identifier)
    (method_call (call (identifier) (identifier)) (block (super))))
  (method
    (identifier)
    (method_call (call (super) (identifier)) (argument_list (identifier) (identifier)))))

===========================
method with args
===========================

def foo(bar)
end

def foo(bar); end
def foo(bar) end

---

(program
  (method (identifier) (method_parameters (identifier)))
  (method (identifier) (method_parameters (identifier)))
  (method (identifier) (method_parameters (identifier))))

================================
method with unparenthesized args
================================

def foo bar
end

---

(program (method (identifier) (method_parameters (identifier))))

=========================
method with multiple args
=========================

def foo(bar, quux)
end

---

(program (method (identifier) (method_parameters (identifier) (identifier))))

=========================================
method with multiple unparenthesized args
=========================================

def foo bar, quux
end

---

(program (method (identifier) (method_parameters (identifier) (identifier))))

=========================================
method with keyword parameters
=========================================

def foo(bar: nil, baz:)
end

---

(program
  (method (identifier)
    (method_parameters
      (keyword_parameter (identifier) (nil))
      (keyword_parameter (identifier)))))

=========================================
method with default parameters
=========================================

def foo(bar = nil)
end

def foo(bar=nil)
end

---

(program
  (method (identifier)
    (method_parameters (optional_parameter (identifier) (nil))))
  (method (identifier)
    (method_parameters (optional_parameter (identifier) (nil)))))

=========================================
method with interesting params
=========================================

def foo(*options)
end

def foo(x, *options)
end

def foo(x, *options, y)
end

def foo(**options)
end

def foo(name:, **)
end

def foo(&block)
end

---

(program
  (method (identifier) (method_parameters (splat_parameter (identifier))))
  (method (identifier) (method_parameters (identifier) (splat_parameter (identifier))))
  (method (identifier) (method_parameters (identifier) (splat_parameter (identifier)) (identifier)))
  (method (identifier) (method_parameters (hash_splat_parameter (identifier))))
  (method (identifier) (method_parameters (keyword_parameter (identifier)) (hash_splat_parameter)))
  (method (identifier) (method_parameters (block_parameter (identifier)))))

=========================================
singleton method
=========================================

def self.foo
end

---

(program (singleton_method (self) (identifier)))

=========================================
singleton method with body
=========================================

def self.foo
  bar
end

---

(program (singleton_method (self) (identifier) (identifier)))


=========================================
singleton method with arg
=========================================

def self.foo(bar)
end

---

(program (singleton_method (self) (identifier) (method_parameters (identifier))))

=========================================
singleton method with un-parenthesized arg
=========================================

def self.foo bar
end

---

(program (singleton_method (self) (identifier) (method_parameters (identifier))))

=========================================
singleton method with args
=========================================

def self.foo(bar, baz)
end

---

(program (singleton_method (self) (identifier) (method_parameters (identifier) (identifier))))


=========================================
singleton method with un-parenthesized args
=========================================

def self.foo bar, baz
end

---

(program (singleton_method (self) (identifier) (method_parameters (identifier) (identifier))))

===========
empty class
===========

class Foo
end

class Foo; end

class Foo::Bar
end

class ::Foo::Bar
end

class Cß
end

---

(program
  (class (constant))
  (class (constant))
  (class (scope_resolution (constant) (constant)))
  (class (scope_resolution (scope_resolution (constant)) (constant)))
  (class (constant)))

==============
empty subclass
==============

class Foo < Bar
end

---

(program (class (constant) (superclass (constant))))

==================================
empty subclass of namespaced class
==================================

class Foo < Bar::Quux
end

class Foo < ::Bar
end

class Foo < Bar::Baz.new(foo)
end

---

(program
  (class
    (constant)
    (superclass (scope_resolution (constant) (constant))))
  (class
    (constant)
    (superclass (scope_resolution (constant))))
  (class
    (constant)
    (superclass (method_call (call (scope_resolution (constant) (constant)) (identifier)) (argument_list (identifier))))))

===============
class with body
===============

class Foo
	def bar
	end
end

---

(program (class (constant) (method (identifier))))

=========================================
class within dynamically-computed module
=========================================

class foo()::Bar
end

---

(program (class (scope_resolution (method_call (identifier) (argument_list)) (constant))))

===============
singleton class
===============

class << self
end

class <<self
end

class << Foo
end

class << Foo::Bar
end

---

(program
  (singleton_class (self))
  (singleton_class (self))
  (singleton_class (constant))
  (singleton_class (scope_resolution (constant) (constant))))


============
empty module
============

module Foo
end

module Foo::Bar
end

---

(program
  (module (constant))
  (module (scope_resolution (constant) (constant))))

================
module with body
================

module Foo
	def bar
	end
end

---

(program (module (constant) (method (identifier))))

========================
module without semicolon
========================

module Foo end

---

(program (module (constant)))

=======
__END__
=======

word
__END__
word
x
ab
d

---

(program (identifier) (uninterpreted))

==============================
module with class with methods
==============================

module A
  class B < C
    include D::E.f.g

    attr_reader :h

    # i
    def j
      k
    end

    def self.l
    end
  end
end

---

(program (module (constant)
  (class (constant) (superclass (constant))
    (method_call (identifier) (argument_list
      (call
        (call
          (scope_resolution (constant) (constant))
          (identifier))
        (identifier))))

    (method_call (identifier) (argument_list (symbol)))

    (comment)
    (method (identifier) (identifier))
    (singleton_method (self) (identifier)))))


===========
empty BEGIN block
===========

BEGIN {

}

---

(program (begin_block))

===========
BEGIN block
===========

baz
BEGIN {
foo
}
bar

---

(program (identifier) (begin_block (identifier)) (identifier))

===========
empty END block
===========

END {

}

---

(program (end_block))

===========
END block
===========

baz
END {
foo
}
bar

---

(program (identifier) (end_block (identifier)) (identifier))
