Skip to content

Supports multi-line constant body with escaped newline #507

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
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions lib/rdoc/parser/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,8 @@ def parse_constant_body container, constant # :nodoc:
end
when TkCOLON2, TkCOLON3 then
rhs_name << '::'
when TkBACKSLASH then
get_tk if TkNL === peek_tk
when nil then
break
end
Expand Down
8 changes: 8 additions & 0 deletions test/test_rdoc_parser_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2286,6 +2286,9 @@ class Foo
SIXTH_CONSTANT = #{sixth_constant}

SEVENTH_CONSTANT = proc { |i| begin i end }

EIGHTH_CONSTANT = "a" \\
"b"
end
EOF

Expand Down Expand Up @@ -2331,6 +2334,11 @@ class Foo
assert_equal 'SEVENTH_CONSTANT', constant.name
assert_equal "proc { |i| begin i end }", constant.value
assert_equal @top_level, constant.file

constant = constants[7]
assert_equal 'EIGHTH_CONSTANT', constant.name
assert_equal "\"a\" \\\n\"b\"", constant.value
assert_equal @top_level, constant.file
end

def test_parse_statements_identifier_attr
Expand Down