Skip to content

Add tests for lib/rdoc/parser/ruby.rb #456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions test/test_rdoc_parser_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,31 @@ def test_look_for_directives_in_unhandled
assert_equal 'blah', @top_level.metadata['unhandled']
end

def test_parse_for_in
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level

comment = RDoc::Comment.new '', @top_level

util_parser <<ruby
def sum(n)
result = 0
for i in 1..n do
result += i
end
result
end
ruby

tk = @parser.get_tk

@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment

sum = klass.method_list.first
assert_equal 'sum', sum.name
assert_equal @top_level, sum.file
end

def test_parse_alias
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
Expand Down Expand Up @@ -2492,6 +2517,25 @@ def b
assert_equal 'A#b', m_b.full_name
end


def test_parse_symbol_in_paren_arg
util_parser <<RUBY
class Foo
def blah
end
private(:blah)
end
RUBY

@parser.scan

foo = @top_level.classes.first
assert_equal 'Foo', foo.full_name

blah = foo.method_list.first
assert_equal :private, blah.visibility
end

def test_parse_symbol_in_arg
util_parser ':blah "blah" "#{blah}" blah'

Expand Down