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

ruby-changes:44339

From: nobu <ko1@a...>
Date: Thu, 13 Oct 2016 11:31:51 +0900 (JST)
Subject: [ruby-changes:44339] nobu:r56412 (trunk): Fix tests depending on sort stability

nobu	2016-10-13 11:31:43 +0900 (Thu, 13 Oct 2016)

  New Revision: 56412

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

  Log:
    Fix tests depending on sort stability
    
    * test/rexml/xpath/test_text.rb (test_ancestors): Array#sort may
      not be stable.  [ruby-core:76088] [Bug #12509]
    * test/rss/test_maker_{0.9,1.0,2.0}.rb (test_items): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/test/rexml/xpath/test_text.rb
    trunk/test/rss/test_maker_0.9.rb
    trunk/test/rss/test_maker_1.0.rb
    trunk/test/rss/test_maker_2.0.rb
Index: test/rexml/xpath/test_text.rb
===================================================================
--- test/rexml/xpath/test_text.rb	(revision 56411)
+++ test/rexml/xpath/test_text.rb	(revision 56412)
@@ -69,7 +69,9 @@ module REXMLTests https://github.com/ruby/ruby/blob/trunk/test/rexml/xpath/test_text.rb#L69
       assert_equal(1, nodes.size, "<b> has one element ancestor")
       nodes = @doc.get_elements('//b/ancestor::node()')
       assert_equal(2, nodes.size, "<b> has two node ancestors")
-      assert_kind_of REXML::Document, nodes[1]
+      nodes.sort_by!(&:name)
+      assert_kind_of REXML::Document, nodes[0]
+      assert_kind_of REXML::Element, nodes[1]
     end
   end
 end
Index: test/rss/test_maker_2.0.rb
===================================================================
--- test/rss/test_maker_2.0.rb	(revision 56411)
+++ test/rss/test_maker_2.0.rb	(revision 56412)
@@ -390,7 +390,7 @@ module RSS https://github.com/ruby/ruby/blob/trunk/test/rss/test_maker_2.0.rb#L390
             item.description = "#{description}#{i}"
             item.author = "#{author}#{i}"
             item.comments = "#{comments}#{i}"
-            item.date = pubDate
+            item.date = pubDate - i
           end
         end
         maker.items.do_sort = true
@@ -402,8 +402,8 @@ module RSS https://github.com/ruby/ruby/blob/trunk/test/rss/test_maker_2.0.rb#L402
         assert_equal("#{description}#{i}", item.description)
         assert_equal("#{author}#{i}", item.author)
         assert_equal("#{comments}#{i}", item.comments)
-        assert_equal(pubDate, item.pubDate)
-        assert_equal(pubDate, item.date)
+        assert_equal(pubDate - i, item.pubDate)
+        assert_equal(pubDate - i, item.date)
       end
 
       rss = RSS::Maker.make("2.0") do |maker|
Index: test/rss/test_maker_1.0.rb
===================================================================
--- test/rss/test_maker_1.0.rb	(revision 56411)
+++ test/rss/test_maker_1.0.rb	(revision 56412)
@@ -269,6 +269,7 @@ module RSS https://github.com/ruby/ruby/blob/trunk/test/rss/test_maker_1.0.rb#L269
       assert_equal(link, item.link)
       assert_nil(item.description)
 
+      pubDate = Time.now
 
       item_size = 5
       rss = RSS::Maker.make("1.0") do |maker|
@@ -279,6 +280,7 @@ module RSS https://github.com/ruby/ruby/blob/trunk/test/rss/test_maker_1.0.rb#L280
             _item.title = "#{title}#{i}"
             _item.link = "#{link}#{i}"
             _item.description = "#{description}#{i}"
+            _item.date = pubDate - i
           end
         end
         maker.items.do_sort = true
Index: test/rss/test_maker_0.9.rb
===================================================================
--- test/rss/test_maker_0.9.rb	(revision 56411)
+++ test/rss/test_maker_0.9.rb	(revision 56412)
@@ -315,6 +315,7 @@ module RSS https://github.com/ruby/ruby/blob/trunk/test/rss/test_maker_0.9.rb#L315
       assert_equal(link, item.link)
       assert_nil(item.description)
 
+      pubDate = Time.now
 
       item_size = 5
       rss = RSS::Maker.make("0.91") do |maker|
@@ -325,6 +326,7 @@ module RSS https://github.com/ruby/ruby/blob/trunk/test/rss/test_maker_0.9.rb#L326
             _item.title = "#{title}#{i}"
             _item.link = "#{link}#{i}"
             _item.description = "#{description}#{i}"
+            _item.date = pubDate - i
           end
         end
         maker.items.do_sort = true
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 56411)
+++ ChangeLog	(revision 56412)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Oct 13 11:31:40 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* test/rexml/xpath/test_text.rb (test_ancestors): Array#sort may
+	  not be stable.  [ruby-core:76088] [Bug #12509]
+
+	* test/rss/test_maker_{0.9,1.0,2.0}.rb (test_items): ditto.
+
 Thu Oct 13 10:37:31 2016  Eric Wong  <e@8...>
 
 	* doc/extension.rdoc: wording fix

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

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