Skip to content

Commit 27a9c41

Browse files
authored
Merge pull request #456 from aycabta/add-test
Add tests for lib/rdoc/parser/ruby.rb
2 parents d0a599f + 9045833 commit 27a9c41

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

test/test_rdoc_parser_ruby.rb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,31 @@ def test_look_for_directives_in_unhandled
282282
assert_equal 'blah', @top_level.metadata['unhandled']
283283
end
284284

285+
def test_parse_for_in
286+
klass = RDoc::NormalClass.new 'Foo'
287+
klass.parent = @top_level
288+
289+
comment = RDoc::Comment.new '', @top_level
290+
291+
util_parser <<ruby
292+
def sum(n)
293+
result = 0
294+
for i in 1..n do
295+
result += i
296+
end
297+
result
298+
end
299+
ruby
300+
301+
tk = @parser.get_tk
302+
303+
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
304+
305+
sum = klass.method_list.first
306+
assert_equal 'sum', sum.name
307+
assert_equal @top_level, sum.file
308+
end
309+
285310
def test_parse_alias
286311
klass = RDoc::NormalClass.new 'Foo'
287312
klass.parent = @top_level
@@ -2492,6 +2517,25 @@ def b
24922517
assert_equal 'A#b', m_b.full_name
24932518
end
24942519

2520+
2521+
def test_parse_symbol_in_paren_arg
2522+
util_parser <<RUBY
2523+
class Foo
2524+
def blah
2525+
end
2526+
private(:blah)
2527+
end
2528+
RUBY
2529+
2530+
@parser.scan
2531+
2532+
foo = @top_level.classes.first
2533+
assert_equal 'Foo', foo.full_name
2534+
2535+
blah = foo.method_list.first
2536+
assert_equal :private, blah.visibility
2537+
end
2538+
24952539
def test_parse_symbol_in_arg
24962540
util_parser ':blah "blah" "#{blah}" blah'
24972541

0 commit comments

Comments
 (0)