[前][次][番号順一覧][スレッド一覧]

ruby-changes:26174

From: drbrain <ko1@a...>
Date: Thu, 6 Dec 2012 15:20:58 +0900 (JST)
Subject: [ruby-changes:26174] drbrain:r38231 (trunk): * lib/rdoc/context.rb: Don't warn for duplicate methods while loading.

drbrain	2012-12-06 15:20:50 +0900 (Thu, 06 Dec 2012)

  New Revision: 38231

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38231

  Log:
    * lib/rdoc/context.rb:  Don't warn for duplicate methods while loading.
    * test/rdoc/test_rdoc_context.rb:  Test for above.

  Modified files:
    trunk/ChangeLog
    trunk/lib/rdoc/context.rb
    trunk/test/rdoc/test_rdoc_context.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38230)
+++ ChangeLog	(revision 38231)
@@ -1,3 +1,8 @@
+Thu Dec  6 15:20:34 2012  Eric Hodel  <drbrain@s...>
+
+	* 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@s...>
 
 	* lib/rubygems/command_manager.rb:  Removed string concatenation
Index: lib/rdoc/context.rb
===================================================================
--- lib/rdoc/context.rb	(revision 38230)
+++ lib/rdoc/context.rb	(revision 38231)
@@ -447,11 +447,13 @@
     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
Index: test/rdoc/test_rdoc_context.rb
===================================================================
--- test/rdoc/test_rdoc_context.rb	(revision 38230)
+++ test/rdoc/test_rdoc_context.rb	(revision 38231)
@@ -244,6 +244,31 @@
     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'
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]