summaryrefslogtreecommitdiff
path: root/test/rdoc
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-10 06:36:13 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-10 06:36:13 +0000
commit1325437297539bf433904b64db63a3186e62177e (patch)
tree01608a107ec3939b1013152d961b6407a5ba9c25 /test/rdoc
parentce2b574017cacc2c3f2b0e92f82a7f250639fc34 (diff)
* lib/rdoc: Import RDoc 2.5.2
* lib/rdoc/parser/ruby.rb (RDoc::Parser::Ruby): Don't parse rdoc files, reverts r24976 in favor of include directive support in C parser. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rdoc')
-rw-r--r--test/rdoc/README1
-rw-r--r--test/rdoc/test_rdoc_any_method.rb56
-rw-r--r--test/rdoc/test_rdoc_attr.rb8
-rw-r--r--test/rdoc/test_rdoc_markup_parser.rb18
-rw-r--r--test/rdoc/test_rdoc_markup_pre_process.rb42
-rw-r--r--test/rdoc/test_rdoc_parser.rb5
-rw-r--r--test/rdoc/test_rdoc_parser_c.rb20
-rw-r--r--test/rdoc/test_rdoc_parser_ruby.rb12
-rw-r--r--test/rdoc/test_rdoc_parser_simple.rb19
-rw-r--r--test/rdoc/test_rdoc_rdoc.rb4
-rw-r--r--test/rdoc/test_rdoc_ri_driver.rb18
-rw-r--r--test/rdoc/xref_data.rb2
12 files changed, 188 insertions, 17 deletions
diff --git a/test/rdoc/README b/test/rdoc/README
new file mode 100644
index 0000000000..4ef17a77f7
--- /dev/null
+++ b/test/rdoc/README
@@ -0,0 +1 @@
+you don't have to
diff --git a/test/rdoc/test_rdoc_any_method.rb b/test/rdoc/test_rdoc_any_method.rb
index 00af7703e5..69df4b1133 100644
--- a/test/rdoc/test_rdoc_any_method.rb
+++ b/test/rdoc/test_rdoc_any_method.rb
@@ -2,25 +2,42 @@ require File.expand_path '../xref_test_case', __FILE__
class RDocAnyMethodTest < XrefTestCase
- def test_full_name
- assert_equal 'C1::m', @c1.method_list.first.full_name
+ def test_arglists
+ m = RDoc::AnyMethod.new nil, 'method'
+
+ assert_nil m.arglists
+
+ m.params = "(a, b)"
+ m.block_params = "c, d"
+
+ assert_equal "method(a, b) { |c, d| ... }", m.arglists
+
+ call_seq = <<-SEQ
+method(a) { |c| ... }
+method(a, b) { |c, d| ... }
+ SEQ
+
+ m.call_seq = call_seq.dup
+
+ assert_equal call_seq, m.arglists
end
- def test_parent_name
- assert_equal 'C1', @c1.method_list.first.parent_name
- assert_equal 'C1', @c1.method_list.last.parent_name
+ def test_full_name
+ assert_equal 'C1::m', @c1.method_list.first.full_name
end
def test_marshal_load
instance_method = Marshal.load Marshal.dump(@c1.method_list.last)
- assert_equal 'C1#m', instance_method.full_name
- assert_equal 'C1', instance_method.parent_name
+ assert_equal 'C1#m', instance_method.full_name
+ assert_equal 'C1', instance_method.parent_name
+ assert_equal '(foo)', instance_method.params
class_method = Marshal.load Marshal.dump(@c1.method_list.first)
assert_equal 'C1::m', class_method.full_name
assert_equal 'C1', class_method.parent_name
+ assert_equal '()', class_method.params
end
def test_name
@@ -29,5 +46,30 @@ class RDocAnyMethodTest < XrefTestCase
assert_nil m.name
end
+ def test_param_seq
+ m = RDoc::AnyMethod.new nil, 'method'
+ m.parent = @c1
+ m.params = 'a'
+
+ assert_equal '(a)', m.param_seq
+
+ m.params = '(a)'
+
+ assert_equal '(a)', m.param_seq
+
+ m.params = "(a,\n b)"
+
+ assert_equal '(a, b)', m.param_seq
+
+ m.block_params = "c,\n d"
+
+ assert_equal '(a, b) { |c, d| ... }', m.param_seq
+ end
+
+ def test_parent_name
+ assert_equal 'C1', @c1.method_list.first.parent_name
+ assert_equal 'C1', @c1.method_list.last.parent_name
+ end
+
end
diff --git a/test/rdoc/test_rdoc_attr.rb b/test/rdoc/test_rdoc_attr.rb
index 362326186b..10965d00b6 100644
--- a/test/rdoc/test_rdoc_attr.rb
+++ b/test/rdoc/test_rdoc_attr.rb
@@ -8,6 +8,10 @@ class TestRDocAttr < MiniTest::Unit::TestCase
@a = RDoc::Attr.new nil, 'attr', 'RW', ''
end
+ def test_arglists
+ assert_nil @a.arglists
+ end
+
def test_block_params
assert_nil @a.block_params
end
@@ -20,6 +24,10 @@ class TestRDocAttr < MiniTest::Unit::TestCase
assert_equal '(unknown)#attr', @a.full_name
end
+ def test_params
+ assert_nil @a.params
+ end
+
def test_singleton
refute @a.singleton
end
diff --git a/test/rdoc/test_rdoc_markup_parser.rb b/test/rdoc/test_rdoc_markup_parser.rb
index 656e2c9831..d418900116 100644
--- a/test/rdoc/test_rdoc_markup_parser.rb
+++ b/test/rdoc/test_rdoc_markup_parser.rb
@@ -1004,6 +1004,24 @@ the time
assert_equal expected, @RMP.tokenize(str)
end
+ def test_tokenize_heading_no_space
+ str = <<-STR
+=Heading
+==Heading 2
+ STR
+
+ expected = [
+ [:HEADER, 1, 0, 0],
+ [:TEXT, 'Heading', 1, 0],
+ [:NEWLINE, "\n", 8, 0],
+ [:HEADER, 2, 0, 1],
+ [:TEXT, 'Heading 2', 2, 1],
+ [:NEWLINE, "\n", 11, 1],
+ ]
+
+ assert_equal expected, @RMP.tokenize(str)
+ end
+
def test_tokenize_label
str = <<-STR
[cat] l1
diff --git a/test/rdoc/test_rdoc_markup_pre_process.rb b/test/rdoc/test_rdoc_markup_pre_process.rb
new file mode 100644
index 0000000000..5f1b22db4d
--- /dev/null
+++ b/test/rdoc/test_rdoc_markup_pre_process.rb
@@ -0,0 +1,42 @@
+require 'tempfile'
+require 'rubygems'
+require 'minitest/autorun'
+require 'rdoc/markup/preprocess'
+
+class TestRDocMarkupPreProcess < MiniTest::Unit::TestCase
+
+ def setup
+ @tempfile = Tempfile.new 'test_rdoc_markup_pre_process'
+ @name = File.basename @tempfile.path
+ @dir = File.dirname @tempfile.path
+
+ @pp = RDoc::Markup::PreProcess.new __FILE__, [@dir]
+ end
+
+ def teardown
+ @tempfile.close
+ end
+
+ def test_include_file
+ @tempfile.write <<-INCLUDE
+# -*- mode: rdoc; coding: utf-8; fill-column: 74; -*-
+
+Regular expressions (<i>regexp</i>s) are patterns which describe the
+contents of a string.
+ INCLUDE
+
+ @tempfile.flush
+ @tempfile.rewind
+
+ content = @pp.include_file @name, ''
+
+ expected = <<-EXPECTED
+Regular expressions (<i>regexp</i>s) are patterns which describe the
+contents of a string.
+ EXPECTED
+
+ assert_equal expected, content
+ end
+
+end
+
diff --git a/test/rdoc/test_rdoc_parser.rb b/test/rdoc/test_rdoc_parser.rb
index 4146d1ee35..ebb520032d 100644
--- a/test/rdoc/test_rdoc_parser.rb
+++ b/test/rdoc/test_rdoc_parser.rb
@@ -55,7 +55,10 @@ class TestRDocParser < MiniTest::Unit::TestCase
assert_equal @RP::Simple, @RP.can_parse(jtest_file_name)
jtest_rdoc_file_name = File.expand_path '../test.ja.rdoc', __FILE__
- assert_equal @RP::Ruby, @RP.can_parse(jtest_rdoc_file_name)
+ assert_equal @RP::Simple, @RP.can_parse(jtest_rdoc_file_name)
+
+ readme_file_name = File.expand_path '../README', __FILE__
+ assert_equal @RP::Simple, @RP.can_parse(readme_file_name)
end
##
diff --git a/test/rdoc/test_rdoc_parser_c.rb b/test/rdoc/test_rdoc_parser_c.rb
index 301e042bcc..38fb908492 100644
--- a/test/rdoc/test_rdoc_parser_c.rb
+++ b/test/rdoc/test_rdoc_parser_c.rb
@@ -201,6 +201,26 @@ Multiline comment goes here because this comment spans multiple lines.
assert constants.empty?, constants.inspect
end
+ def test_find_class_comment_include
+ @options.rdoc_include << File.dirname(__FILE__)
+
+ content = <<-EOF
+/*
+ * a comment for class Foo
+ *
+ * :include: test.txt
+ */
+void
+Init_Foo(void) {
+ VALUE foo = rb_define_class("Foo", rb_cObject);
+}
+ EOF
+
+ klass = util_get_class content, 'foo'
+
+ assert_equal "a comment for class Foo\n\ntest file", klass.comment
+ end
+
def test_find_class_comment_init
content = <<-EOF
/*
diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb
index f9d932e7fd..629bca0c83 100644
--- a/test/rdoc/test_rdoc_parser_ruby.rb
+++ b/test/rdoc/test_rdoc_parser_ruby.rb
@@ -1246,11 +1246,19 @@ end
# If you're writing code like this you're doing it wrong
- def x_test_sanity_interpolation_crazy
+ def test_sanity_interpolation_crazy
last_tk = nil
util_parser '"#{"#{"a")}" if b}"'
- assert_equal RDoc::RubyToken::TkDSTRING, tk.class
+ assert_equal '"#{"#{"a")}" if b}"', @parser.get_tk.text
+ assert_equal RDoc::RubyToken::TkNL, @parser.get_tk.class
+ end
+
+ def test_sanity_interpolation_curly
+ last_tk = nil
+ util_parser '%{ #{} }'
+
+ assert_equal '%{ #{} }', @parser.get_tk.text
assert_equal RDoc::RubyToken::TkNL, @parser.get_tk.class
end
diff --git a/test/rdoc/test_rdoc_parser_simple.rb b/test/rdoc/test_rdoc_parser_simple.rb
index 0b35a66c5e..6edb51481a 100644
--- a/test/rdoc/test_rdoc_parser_simple.rb
+++ b/test/rdoc/test_rdoc_parser_simple.rb
@@ -22,6 +22,25 @@ class TestRDocParserSimple < MiniTest::Unit::TestCase
@tempfile.close
end
+ def test_remove_coding_comment
+ parser = util_parser <<-TEXT
+# -*- mode: rdoc; coding: utf-8; fill-column: 74; -*-
+
+Regular expressions (<i>regexp</i>s) are patterns which describe the
+contents of a string.
+ TEXT
+
+ parser.scan
+
+ expected = <<-TEXT.strip
+
+Regular expressions (<i>regexp</i>s) are patterns which describe the
+contents of a string.
+ TEXT
+
+ assert_equal expected, @top_level.comment
+ end
+
def test_remove_private_comments
parser = util_parser ''
text = "foo\n\n--\nbar\n++\n\nbaz\n"
diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb
index 51aff52714..7c8f7778d8 100644
--- a/test/rdoc/test_rdoc_rdoc.rb
+++ b/test/rdoc/test_rdoc_rdoc.rb
@@ -15,8 +15,8 @@ class TestRDocRDoc < MiniTest::Unit::TestCase
end
def test_gather_files
- file = File.expand_path("../../../lib/rdoc.rb", __FILE__)
- assert_equal([file], @rdoc.gather_files([file, file]))
+ file = File.expand_path __FILE__
+ assert_equal [file], @rdoc.gather_files([file, file])
end
def test_read_file_contents
diff --git a/test/rdoc/test_rdoc_ri_driver.rb b/test/rdoc/test_rdoc_ri_driver.rb
index c41a130e77..2e89c70d19 100644
--- a/test/rdoc/test_rdoc_ri_driver.rb
+++ b/test/rdoc/test_rdoc_ri_driver.rb
@@ -366,7 +366,6 @@ class TestRDocRIDriver < MiniTest::Unit::TestCase
assert_match %r%Foo::Bar#blah%, out
assert_match %r%blah.5%, out
assert_match %r%blah.6%, out
- assert_match %r%yields: stuff%, out
end
def test_display_method_attribute
@@ -425,6 +424,16 @@ Foo::Bar#bother
assert_equal expected, out
end
+ def test_display_method_params
+ util_store
+
+ out, err = capture_io do
+ @driver.display_method 'Foo::Bar#bother'
+ end
+
+ assert_match %r%things.*stuff%, out
+ end
+
def test_expand_class
util_store
@@ -511,7 +520,7 @@ Foo::Bar#bother
util_store
out, err = capture_io do
- @driver.list_known_classes
+ @driver.list_known_classes
end
assert_equal "Ambiguous\nFoo\nFoo::Bar\nFoo::Baz\nInc\n", out
@@ -675,7 +684,7 @@ Foo::Bar#bother
def test_setup_pager
@driver.use_stdout = false
- pager = with_dummy_pager {@driver.setup_pager}
+ pager = with_dummy_pager do @driver.setup_pager end
skip "couldn't find a standard pager" unless pager
@@ -776,9 +785,10 @@ Foo::Bar#bother
@blah = RDoc::AnyMethod.new nil, 'blah'
@blah.call_seq = "blah(5) => 5\nblah(6) => 6\n"
- @blah.block_params = "stuff"
@bother = RDoc::AnyMethod.new nil, 'bother'
+ @bother.params = "(things)"
+ @bother.block_params = "stuff"
@new = RDoc::AnyMethod.new nil, 'new'
@new.singleton = true
diff --git a/test/rdoc/xref_data.rb b/test/rdoc/xref_data.rb
index 38b2a0b2e2..ac1c39a915 100644
--- a/test/rdoc/xref_data.rb
+++ b/test/rdoc/xref_data.rb
@@ -11,7 +11,7 @@ class C1
def self.m
end
- def m
+ def m foo
end
end