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

ruby-changes:47525

From: hsbt <ko1@a...>
Date: Tue, 22 Aug 2017 15:34:33 +0900 (JST)
Subject: [ruby-changes:47525] hsbt:r59641 (trunk): Fixed equality method fails when given the object that doesn't support table method.

hsbt	2017-08-22 15:34:27 +0900 (Tue, 22 Aug 2017)

  New Revision: 59641

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59641

  Log:
    Fixed equality method fails when given the object that doesn't support table method.
    
      [Bug #12422][ruby-core:75707]

  Modified files:
    trunk/lib/csv.rb
    trunk/test/csv/test_features.rb
Index: lib/csv.rb
===================================================================
--- lib/csv.rb	(revision 59640)
+++ lib/csv.rb	(revision 59641)
@@ -870,7 +870,8 @@ class CSV https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L870
 
     # Returns +true+ if all rows of this table ==() +other+'s rows.
     def ==(other)
-      @table == other.table
+      return @table == other.table if other.is_a? CSV::Table
+      @table == other
     end
 
     #
Index: test/csv/test_features.rb
===================================================================
--- test/csv/test_features.rb	(revision 59640)
+++ test/csv/test_features.rb	(revision 59641)
@@ -374,4 +374,7 @@ class TestCSV::Features < TestCSV https://github.com/ruby/ruby/blob/trunk/test/csv/test_features.rb#L374
     assert_equal [["line", "1", "a"], ["line", "2", "b"]], c.each.to_a
   end
 
+  def test_table_nil_equality
+    assert_nothing_raised(NoMethodError) { CSV.parse("test", headers: true) == nil }
+  end
 end

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

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