summaryrefslogtreecommitdiff
path: root/test/thread/test_queue.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-17 10:56:53 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-17 10:56:53 +0000
commit06e70ae4f3c64d24539bd434b278e7cd8e7e1002 (patch)
tree86eda07f2c4d54f5a3a2ee7c3707d13f02527464 /test/thread/test_queue.rb
parent25a2e870d4d2bcc7326bbce65998e0f9c96e01a6 (diff)
test_queue.rb: non-blocking pop tests
* test/thread/test_queue.rb (test_queue_pop_non_block): test for non-blocking pop. * test/thread/test_queue.rb (test_sized_queue_pop_non_block): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/thread/test_queue.rb')
-rw-r--r--test/thread/test_queue.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb
index e1ead47197..51da231736 100644
--- a/test/thread/test_queue.rb
+++ b/test/thread/test_queue.rb
@@ -74,6 +74,13 @@ class TestQueue < Test::Unit::TestCase
assert_equal(0, q.num_waiting)
end
+ def test_queue_pop_non_block
+ q = Queue.new
+ assert_raise_with_message(ThreadError, /empty/) do
+ q.pop(true)
+ end
+ end
+
def test_sized_queue_pop_interrupt
q = SizedQueue.new(1)
t1 = Thread.new { q.pop }
@@ -82,6 +89,13 @@ class TestQueue < Test::Unit::TestCase
assert_equal(0, q.num_waiting)
end
+ def test_sized_queue_pop_non_block
+ q = SizedQueue.new(1)
+ assert_raise_with_message(ThreadError, /empty/) do
+ q.pop(true)
+ end
+ end
+
def test_sized_queue_push_interrupt
q = SizedQueue.new(1)
q.push(1)