Skip to content

Commit

Permalink
Add test_parse_statements_complex_condition_in_for
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Aug 5, 2017
1 parent 7d99dc7 commit 1917d08
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/test_rdoc_parser_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2446,6 +2446,38 @@ class DateTime < Date
assert_equal :private, date_time_now.visibility, date_time_now.full_name
end

def test_parse_statements_complex_condition_in_for
util_parser <<RUBY
class Foo
def blah()
for i in (k+1)...n do
end
for i in (k+1)...n
end
end
end
RUBY

expected = <<EXPTECTED
<span class="ruby-keyword">def</span> <span class="ruby-identifier">blah</span>()
<span class="ruby-keyword">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword">in</span> (<span class="ruby-identifier">k</span><span class="ruby-operator">+</span><span class="ruby-value">1</span>)<span class="ruby-operator">...</span><span class="ruby-identifier">n</span> <span class="ruby-keyword">do</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword">in</span> (<span class="ruby-identifier">k</span><span class="ruby-operator">+</span><span class="ruby-value">1</span>)<span class="ruby-operator">...</span><span class="ruby-identifier">n</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
EXPTECTED
expected = expected.rstrip

@parser.scan

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

blah = foo.method_list.first
markup_code = blah.markup_code.sub(/^.*\n/, '')
assert_equal markup_code, expected
end

def test_parse_require_dynamic_string
content = <<-RUBY
prefix = 'path'
Expand Down

0 comments on commit 1917d08

Please sign in to comment.