Permalink
Browse files

Fixed parsing of `def self.&() end`. Fixes #148

  • Loading branch information...
1 parent 640e6d7 commit 8b25c18fd2dab74fc30f61fc798538f92129ec45 @drbrain drbrain committed Nov 19, 2012
Showing with 55 additions and 3 deletions.
  1. +2 −0 History.rdoc
  2. +1 −0 Manifest.txt
  3. +2 −2 lib/rdoc/ruby_token.rb
  4. +31 −1 test/test_rdoc_parser_ruby.rb
  5. +19 −0 test/test_rdoc_ruby_token.rb
View
@@ -95,6 +95,8 @@
Noria.
* Add license to gem spec. Issue #144 by pivotalcommon
* Fixed comment selection for classes. Pull request #146 by pioz
+ * Fixed parsing of <code>def self.&() end</code>. Issue #148 by Michael
+ Lucy
=== 3.12 / 2011-12-15
View
@@ -267,6 +267,7 @@ test/test_rdoc_require.rb
test/test_rdoc_ri_driver.rb
test/test_rdoc_ri_paths.rb
test/test_rdoc_ruby_lex.rb
+test/test_rdoc_ruby_token.rb
test/test_rdoc_rubygems_hook.rb
test/test_rdoc_servlet.rb
test/test_rdoc_single_class.rb
View
@@ -370,13 +370,13 @@ def Token(token, value = nil)
[:TkfLPAREN, Token, "("], # func( #
[:TkfLBRACK, Token, "["], # func[ #
[:TkfLBRACE, Token, "{"], # func{ #
- [:TkSTAR, Token, "*"], # *arg
- [:TkAMPER, Token, "&"], # &arg #
[:TkSYMBEG, Token, ":"], # :SYMBOL
+ [:TkAMPER, TkOp, "&"],
[:TkGT, TkOp, ">"],
[:TkLT, TkOp, "<"],
[:TkPLUS, TkOp, "+"],
+ [:TkSTAR, TkOp, "*"],
[:TkMINUS, TkOp, "-"],
[:TkMULT, TkOp, "*"],
[:TkDIV, TkOp, "/"],
@@ -1339,6 +1339,21 @@ def test_parse_method_alias
assert klass.aliases.empty?
end
+ def test_parse_method_ampersand
+ klass = RDoc::NormalClass.new 'Foo'
+ klass.parent = @top_level
+
+ util_parser "def self.&\nend"
+
+ tk = @parser.get_tk
+
+ @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
+
+ ampersand = klass.method_list.first
+ assert_equal '&', ampersand.name
+ assert ampersand.singleton
+ end
+
def test_parse_method_false
util_parser "def false.foo() :bar end"
@@ -1362,7 +1377,7 @@ def test_parse_method_funky
@parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
- assert klass.method_list.empty?
+ assert_empty klass.method_list
end
def test_parse_method_gvar
@@ -1470,6 +1485,21 @@ def test_parse_method_parameters_comment_continue
assert_equal '(arg1, arg2, arg3)', foo.params
end
+ def test_parse_method_star
+ klass = RDoc::NormalClass.new 'Foo'
+ klass.parent = @top_level
+
+ util_parser "def self.*\nend"
+
+ tk = @parser.get_tk
+
+ @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
+
+ ampersand = klass.method_list.first
+ assert_equal '*', ampersand.name
+ assert ampersand.singleton
+ end
+
def test_parse_method_stopdoc
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
@@ -0,0 +1,19 @@
+require 'rdoc/test_case'
+
+class TestRDocRubyToken < RDoc::TestCase
+
+ def test_Token_text
+ token = RDoc::RubyToken::Token.new 0, 0, 0, 'text'
+
+ assert_equal 'text', token.text
+ end
+
+ def test_TkOp_name
+ token = RDoc::RubyToken::TkOp.new 0, 0, 0, '&'
+
+ assert_equal '&', token.text
+ assert_equal '&', token.name
+ end
+
+end
+

0 comments on commit 8b25c18

Please sign in to comment.