Permalink
Browse files

Make comment handler handle dynamic symbols with embedded code

  • Loading branch information...
1 parent 605fcf0 commit 7318a7e6a6ef1ce19739667021ae738a7b3f5bff @mvz committed Jun 22, 2012
Showing with 19 additions and 0 deletions.
  1. +5 −0 lib/ripper_ruby_parser/commenting_sexp_builder.rb
  2. +14 −0 test/unit/commenting_sexp_builder_test.rb
View
5 lib/ripper_ruby_parser/commenting_sexp_builder.rb
@@ -57,6 +57,11 @@ def on_symbol *args
super
end
+ def on_embexpr_beg *args
+ @in_symbol = false
+ super
+ end
+
def on_dyna_symbol *args
@in_symbol = false
super
View
14 test/unit/commenting_sexp_builder_test.rb
@@ -94,6 +94,20 @@ def parse_with_builder str
[:params, nil, nil, nil, nil, nil],
[:bodystmt, [[:void_stmt]], nil, nil, nil]]]]]
end
+
+ it "is not confused by a dynamic symbol containing a class definition" do
+ result = parse_with_builder ":\"foo\#{class Bar;end}\""
+ result.must_equal [:program,
+ [[:dyna_symbol,
+ [[:@tstring_content, "foo", [1, 2]],
+ [:string_embexpr,
+ [[:comment,
+ "",
+ [:class,
+ [:const_ref, [:@const, "Bar", [1, 13]]],
+ nil,
+ [:bodystmt, [[:void_stmt]], nil, nil, nil]]]]]]]]]
+ end
end
end

0 comments on commit 7318a7e

Please sign in to comment.