aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-06 06:20:50 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-06 06:20:50 +0000
commit854758c464e6cdba06eed5d05b7fe10c33788c89 (patch)
treecc1e1b36bfab9923b3e962a0c52dc28c58a3f120
parent80ba379c242ce1d92005403423717cf0f74a74db (diff)
downloadruby-854758c464e6cdba06eed5d05b7fe10c33788c89.tar.gz
* lib/rdoc/context.rb: Don't warn for duplicate methods while loading.
* test/rdoc/test_rdoc_context.rb: Test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--lib/rdoc/context.rb12
-rw-r--r--test/rdoc/test_rdoc_context.rb25
3 files changed, 37 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 0b5094d169..bb8cf91eed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Dec 6 15:20:34 2012 Eric Hodel <drbrain@segment7.net>
+
+ * lib/rdoc/context.rb: Don't warn for duplicate methods while loading.
+ * test/rdoc/test_rdoc_context.rb: Test for above.
+
Thu Dec 6 14:26:22 2012 Eric Hodel <drbrain@segment7.net>
* lib/rubygems/command_manager.rb: Removed string concatenation
diff --git a/lib/rdoc/context.rb b/lib/rdoc/context.rb
index 6f9deae4a8..22339bf1c7 100644
--- a/lib/rdoc/context.rb
+++ b/lib/rdoc/context.rb
@@ -447,11 +447,13 @@ class RDoc::Context < RDoc::CodeObject
known = @methods_hash[key]
if known then
- known.comment = method.comment if known.comment.empty?
- previously = ", previously in #{known.file}" unless
- method.file == known.file
- @store.rdoc.options.warn \
- "Duplicate method #{known.full_name} in #{method.file}#{previously}"
+ if @store then # otherwise we are loading
+ known.comment = method.comment if known.comment.empty?
+ previously = ", previously in #{known.file}" unless
+ method.file == known.file
+ @store.rdoc.options.warn \
+ "Duplicate method #{known.full_name} in #{method.file}#{previously}"
+ end
else
@methods_hash[key] = method
method.visibility = @visibility
diff --git a/test/rdoc/test_rdoc_context.rb b/test/rdoc/test_rdoc_context.rb
index a4f42ad206..28b98dfe55 100644
--- a/test/rdoc/test_rdoc_context.rb
+++ b/test/rdoc/test_rdoc_context.rb
@@ -244,6 +244,31 @@ class TestRDocContext < XrefTestCase
assert_equal 'first', method.comment.text
end
+ def test_add_method_duplicate_loading
+ @context.store = nil
+
+ meth1 = RDoc::AnyMethod.new nil, 'name'
+ meth1.record_location @store.add_file 'first.rb'
+ meth1.visibility = nil
+ meth1.comment = comment 'first'
+
+ @context.add_method meth1
+
+ meth2 = RDoc::AnyMethod.new nil, 'name'
+ meth2.record_location @store.add_file 'second.rb'
+ meth2.comment = comment 'second'
+
+ _, err = verbose_capture_io do
+ @context.add_method meth2
+ end
+
+ assert_empty err
+
+ method = @context.method_list.first
+
+ assert_equal 'first', method.comment.text
+ end
+
def test_add_module
@c1.add_module RDoc::NormalModule, 'Mod'