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

ruby-changes:27661

From: kosaki <ko1@a...>
Date: Mon, 11 Mar 2013 08:01:37 +0900 (JST)
Subject: [ruby-changes:27661] kosaki:r39713 (trunk): * lib/thread.rb (Queue#push): return self.

kosaki	2013-03-11 08:01:21 +0900 (Mon, 11 Mar 2013)

  New Revision: 39713

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

  Log:
    * lib/thread.rb (Queue#push): return self.
    * lib/thread.rb (Queue#clear): ditto.
    * lib/thread.rb (SizedQueue#push): ditto.
    * test/thread/test_queue.rb: add tests for the above.

  Modified files:
    trunk/ChangeLog
    trunk/lib/thread.rb
    trunk/test/thread/test_queue.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 39712)
+++ ChangeLog	(revision 39713)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Mar  7 10:42:28 2013  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* lib/thread.rb (Queue#push): return self.
+	* lib/thread.rb (Queue#clear): ditto.
+	* lib/thread.rb (SizedQueue#push): ditto.
+	* test/thread/test_queue.rb: add tests for the above.
+
 Thu Mar  7 10:40:49 2013  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* tool/change_maker.rb (#diff2index): check Encoding::BINARY.
Index: lib/thread.rb
===================================================================
--- lib/thread.rb	(revision 39712)
+++ lib/thread.rb	(revision 39713)
@@ -165,6 +165,7 @@ class Queue https://github.com/ruby/ruby/blob/trunk/lib/thread.rb#L165
         @que.push obj
         @cond.signal
       end
+      self
     end
   end
 
@@ -228,6 +229,7 @@ class Queue https://github.com/ruby/ruby/blob/trunk/lib/thread.rb#L229
   #
   def clear
     @que.clear
+    self
   end
 
   #
@@ -315,6 +317,7 @@ class SizedQueue < Queue https://github.com/ruby/ruby/blob/trunk/lib/thread.rb#L317
         @que.push obj
         @cond.signal
       end
+      self
     end
   end
 
Index: test/thread/test_queue.rb
===================================================================
--- test/thread/test_queue.rb	(revision 39712)
+++ test/thread/test_queue.rb	(revision 39713)
@@ -108,4 +108,29 @@ class TestQueue < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/thread/test_queue.rb#L108
       end
     }
   end
+
+  def test_queue_push_return_value
+    q = Queue.new
+    retval = q.push(1)
+    assert_same q, retval
+  end 
+
+  def test_queue_clear_return_value
+    q = Queue.new
+    retval = q.clear
+    assert_same q, retval
+  end
+
+  def test_sized_queue_push_return_value
+    q = SizedQueue.new(1)
+    retval = q.push(1)
+    assert_same q, retval
+  end
+
+  def test_sized_queue_clear_return_value
+    q = SizedQueue.new(1)
+    retval = q.clear
+    assert_same q, retval
+  end
+
 end

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

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