aboutsummaryrefslogtreecommitdiffstats
path: root/test/rdoc/test_rdoc_parser_ruby.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-29 21:17:31 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-29 21:17:31 +0000
commite75e7fcc9f90d41ae14019c0f3b5d5048badbb5a (patch)
tree3611123592f58ecbf7c0ff8d54b22b5fcdeb60f1 /test/rdoc/test_rdoc_parser_ruby.rb
parent6f1ce28d624007f1d7688865a782c3ba4ad376a0 (diff)
downloadruby-e75e7fcc9f90d41ae14019c0f3b5d5048badbb5a.tar.gz
* lib/rdoc: Update to RDoc 3.8 which contains fixes for documentation
in trunk. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rdoc/test_rdoc_parser_ruby.rb')
-rw-r--r--test/rdoc/test_rdoc_parser_ruby.rb292
1 files changed, 289 insertions, 3 deletions
diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb
index e02ed56beb..4904d5dfca 100644
--- a/test/rdoc/test_rdoc_parser_ruby.rb
+++ b/test/rdoc/test_rdoc_parser_ruby.rb
@@ -437,6 +437,21 @@ class C; end
assert alas.singleton
end
+ def test_parse_alias_stopdoc
+ klass = RDoc::NormalClass.new 'Foo'
+ klass.parent = @top_level
+ klass.stop_doc
+
+ util_parser "alias :next= :bar"
+
+ tk = @parser.get_tk
+
+ @parser.parse_alias klass, RDoc::Parser::Ruby::NORMAL, tk, 'comment'
+
+ assert_empty klass.aliases
+ assert_empty klass.unmatched_alias_lists
+ end
+
def test_parse_alias_meta
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
@@ -472,6 +487,22 @@ class C; end
assert_equal 1, foo.line
end
+ def test_parse_attr_stopdoc
+ klass = RDoc::NormalClass.new 'Foo'
+ klass.parent = @top_level
+ klass.stop_doc
+
+ comment = "##\n# my attr\n"
+
+ util_parser "attr :foo, :bar"
+
+ tk = @parser.get_tk
+
+ @parser.parse_attr klass, RDoc::Parser::Ruby::NORMAL, tk, comment
+
+ assert_empty klass.attributes
+ end
+
def test_parse_attr_accessor
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
@@ -515,6 +546,22 @@ class C; end
assert_equal 0, klass.attributes.length
end
+ def test_parse_attr_accessor_stopdoc
+ klass = RDoc::NormalClass.new 'Foo'
+ klass.parent = @top_level
+ klass.stop_doc
+
+ comment = "##\n# my attr\n"
+
+ util_parser "attr_accessor :foo, :bar"
+
+ tk = @parser.get_tk
+
+ @parser.parse_attr_accessor klass, RDoc::Parser::Ruby::NORMAL, tk, comment
+
+ assert_empty klass.attributes
+ end
+
def test_parse_attr_accessor_writer
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
@@ -620,6 +667,22 @@ class C; end
assert_equal @top_level, foo.file
end
+ def test_parse_meta_attr_stopdoc
+ klass = RDoc::NormalClass.new 'Foo'
+ klass.parent = @top_level
+ klass.stop_doc
+
+ comment = "##\n# :attr: \n# my method\n"
+
+ util_parser "add_my_method :foo, :bar"
+
+ tk = @parser.get_tk
+
+ @parser.parse_meta_attr klass, RDoc::Parser::Ruby::NORMAL, tk, comment
+
+ assert_empty klass.attributes
+ end
+
def test_parse_meta_attr_writer
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
@@ -640,7 +703,7 @@ class C; end
end
def test_parse_class
- comment = "##\n# my method\n"
+ comment = "##\n# my class\n"
util_parser "class Foo\nend"
@@ -650,7 +713,7 @@ class C; end
foo = @top_level.classes.first
assert_equal 'Foo', foo.full_name
- assert_equal 'my method', foo.comment
+ assert_equal 'my class', foo.comment
assert_equal [@top_level], foo.in_files
assert_equal 0, foo.offset
assert_equal 1, foo.line
@@ -706,6 +769,42 @@ end
assert_equal 2, foo.method_list.length
end
+ def test_parse_class_nodoc
+ comment = "##\n# my class\n"
+
+ util_parser "class Foo # :nodoc:\nend"
+
+ tk = @parser.get_tk
+
+ @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment
+
+ foo = @top_level.classes.first
+ assert_equal 'Foo', foo.full_name
+ assert_empty foo.comment
+ assert_equal [@top_level], foo.in_files
+ assert_equal 0, foo.offset
+ assert_equal 1, foo.line
+ end
+
+ def test_parse_class_stopdoc
+ @top_level.stop_doc
+
+ comment = "##\n# my class\n"
+
+ util_parser "class Foo\nend"
+
+ tk = @parser.get_tk
+
+ @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment
+
+ foo = @top_level.classes.first
+ assert_equal 'Foo', foo.full_name
+ assert_equal 'my class', foo.comment
+ assert_equal [@top_level], foo.in_files
+ assert_equal 0, foo.offset
+ assert_equal 1, foo.line
+ end
+
def test_parse_multi_ghost_methods
util_parser <<-'CLASS'
class Foo
@@ -785,6 +884,38 @@ end
assert_equal 'my module', foo.comment
end
+ def test_parse_module_nodoc
+ @top_level.stop_doc
+
+ comment = "##\n# my module\n"
+
+ util_parser "module Foo # :nodoc:\nend"
+
+ tk = @parser.get_tk
+
+ @parser.parse_module @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment
+
+ foo = @top_level.modules.first
+ assert_equal 'Foo', foo.full_name
+ assert_empty foo.comment
+ end
+
+ def test_parse_module_stopdoc
+ @top_level.stop_doc
+
+ comment = "##\n# my module\n"
+
+ util_parser "module Foo\nend"
+
+ tk = @parser.get_tk
+
+ @parser.parse_module @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment
+
+ foo = @top_level.modules.first
+ assert_equal 'Foo', foo.full_name
+ assert_equal 'my module', foo.comment
+ end
+
def test_parse_class_colon3
code = <<-CODE
class A
@@ -976,6 +1107,22 @@ EOF
assert_equal klass.current_section, foo.section
end
+ def test_parse_comment_attr_stopdoc
+ klass = RDoc::NormalClass.new 'Foo'
+ klass.parent = @top_level
+ klass.stop_doc
+
+ comment = "##\n# :attr: foo\n# my attr\n"
+
+ util_parser "\n"
+
+ tk = @parser.get_tk
+
+ @parser.parse_comment klass, tk, comment
+
+ assert_empty klass.attributes
+ end
+
def test_parse_comment_method
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
@@ -1021,6 +1168,22 @@ EOF
assert_equal stream, foo.token_stream
end
+ def test_parse_comment_method_stopdoc
+ klass = RDoc::NormalClass.new 'Foo'
+ klass.parent = @top_level
+ klass.stop_doc
+
+ comment = "##\n# :method: foo\n# my method\n"
+
+ util_parser "\n"
+
+ tk = @parser.get_tk
+
+ @parser.parse_comment klass, tk, comment
+
+ assert_empty klass.method_list
+ end
+
def test_parse_constant
util_top_level
@@ -1084,6 +1247,21 @@ EOF
assert_equal top_bar, bar.find_module_named('A')
end
+ def test_parse_constant_stopdoc
+ util_top_level
+
+ klass = @top_level.add_class RDoc::NormalClass, 'Foo'
+ klass.stop_doc
+
+ util_parser "A = v"
+
+ tk = @parser.get_tk
+
+ @parser.parse_constant klass, tk, ''
+
+ assert_empty klass.constants
+ end
+
def test_parse_include
klass = RDoc::NormalClass.new 'C'
klass.parent = @top_level
@@ -1249,6 +1427,22 @@ end
assert_equal @top_level, foo.file
end
+ def test_parse_meta_method_stopdoc
+ klass = RDoc::NormalClass.new 'Foo'
+ klass.parent = @top_level
+ klass.stop_doc
+
+ comment = "##\n# my method\n"
+
+ util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
+
+ tk = @parser.get_tk
+
+ @parser.parse_meta_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
+
+ assert_empty klass.method_list
+ end
+
def test_parse_meta_method_unknown
klass = RDoc::NormalClass.new 'Foo'
comment = "##\n# my method\n"
@@ -1464,6 +1658,22 @@ end
assert_equal '(arg1, arg2, arg3)', foo.params
end
+ def test_parse_method_stopdoc
+ klass = RDoc::NormalClass.new 'Foo'
+ klass.parent = @top_level
+ klass.stop_doc
+
+ comment = "##\n# my method\n"
+
+ util_parser "def foo() :bar end"
+
+ tk = @parser.get_tk
+
+ @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment
+
+ assert_empty klass.method_list
+ end
+
def test_parse_method_toplevel
klass = @top_level
@@ -1879,6 +2089,69 @@ end
assert_equal 1, @top_level.requires.length
end
+ def test_parse_statements_stopdoc_TkALIAS
+ util_top_level
+
+ klass = @top_level.add_class RDoc::NormalClass, 'Foo'
+
+ util_parser "\n# :stopdoc:\nalias old new"
+
+ @parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
+
+ assert_empty klass.aliases
+ assert_empty klass.unmatched_alias_lists
+ end
+
+ def test_parse_statements_stopdoc_TkIDENTIFIER_alias_method
+ util_top_level
+
+ klass = @top_level.add_class RDoc::NormalClass, 'Foo'
+
+ util_parser "\n# :stopdoc:\nalias_method :old :new"
+
+ @parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
+
+ assert_empty klass.aliases
+ assert_empty klass.unmatched_alias_lists
+ end
+
+ def test_parse_statements_stopdoc_TkIDENTIFIER_metaprogrammed
+ util_top_level
+
+ klass = @top_level.add_class RDoc::NormalClass, 'Foo'
+
+ util_parser "\n# :stopdoc:\n# attr :meta"
+
+ @parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
+
+ assert_empty klass.method_list
+ assert_empty klass.attributes
+ end
+
+ def test_parse_statements_stopdoc_TkCONSTANT
+ util_top_level
+
+ klass = @top_level.add_class RDoc::NormalClass, 'Foo'
+
+ util_parser "\n# :stopdoc:\nA = v"
+
+ @parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
+
+ assert_empty klass.constants
+ end
+
+ def test_parse_statements_stopdoc_TkDEF
+ util_top_level
+
+ klass = @top_level.add_class RDoc::NormalClass, 'Foo'
+
+ util_parser "\n# :stopdoc:\ndef m\n end"
+
+ @parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
+
+ assert_empty klass.method_list
+ end
+
def test_parse_statements_while_begin
util_parser <<-RUBY
class A
@@ -1924,7 +2197,7 @@ end
assert_equal nil, @parser.parse_symbol_in_arg
end
- def test_parse_top_level_statements_alias_method
+ def test_parse_statements_alias_method
content = <<-CONTENT
class A
alias_method :a, :[] unless c
@@ -1939,6 +2212,19 @@ end
util_parser content
@parser.parse_statements @top_level
+
+ # HACK where are the assertions?
+ end
+
+ def test_parse_top_level_statements_stopdoc
+ @top_level.stop_doc
+ content = "# this is the top-level comment"
+
+ util_parser content
+
+ @parser.parse_top_level_statements @top_level
+
+ assert_empty @top_level.comment
end
def test_parse_yield_in_braces_with_parens