diff --git a/lib/rdoc/ruby_lex.rb b/lib/rdoc/ruby_lex.rb index 495ac80eea..6e68040db1 100644 --- a/lib/rdoc/ruby_lex.rb +++ b/lib/rdoc/ruby_lex.rb @@ -1045,7 +1045,7 @@ def identify_identifier if @lex_state == :EXPR_FNAME @lex_state = :EXPR_END - if peek(0) == '=' + if peek(0) == '=' and peek(1) != '>' token.concat getc end elsif @lex_state == :EXPR_BEG || @lex_state == :EXPR_DOT || diff --git a/test/test_rdoc_ruby_lex.rb b/test/test_rdoc_ruby_lex.rb index 10279389f3..9284143ab1 100644 --- a/test/test_rdoc_ruby_lex.rb +++ b/test/test_rdoc_ruby_lex.rb @@ -331,6 +331,24 @@ def test_class_tokenize_percent_w_quote assert_equal expected, tokens end + def test_class_tokenize_hash_rocket + tokens = RDoc::RubyLex.tokenize "{ :foo=> 1 }", nil + + expected = [ + @TK::TkLBRACE .new( 0, 1, 0, '{'), + @TK::TkSPACE .new( 1, 1, 1, ' '), + @TK::TkSYMBOL .new( 2, 1, 2, ':foo'), + @TK::TkHASHROCKET.new( 6, 1, 6, '=>'), + @TK::TkSPACE .new( 8, 1, 8, ' '), + @TK::TkINTEGER .new( 9, 1, 9, '1'), + @TK::TkSPACE .new(10, 1, 10, ' '), + @TK::TkRBRACE .new(11, 1, 11, '}'), + @TK::TkNL .new(12, 1, 12, "\n") + ] + + assert_equal expected, tokens + end + def test_class_tokenize_percent_sign_quote tokens = RDoc::RubyLex.tokenize '%%hi%', nil