summaryrefslogtreecommitdiff
path: root/test/thread
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-03 09:46:51 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-03 09:46:51 +0000
commita46d29bb4e232064b68f54e46be8a44216570563 (patch)
tree944cb06297f44a151a417e0c2ececa0012fd111d /test/thread
parentb31c817782531fa0f3657af692e4a83b5f30f068 (diff)
* lib/thread.rb (SizedQueue#max=) raise ArgumentError if max is not
positive number. patch by Masaki Matsushita. [ruby-dev:44449] [Bug #5259] * test/thread/test_queue.rb (test_sized_queue_initialize, test_sized_queue_assign_max): add tests for it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/thread')
-rw-r--r--test/thread/test_queue.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb
index b0ffe08..685b41a 100644
--- a/test/thread/test_queue.rb
+++ b/test/thread/test_queue.rb
@@ -35,4 +35,22 @@ class TestQueue < Test::Unit::TestCase
assert_equal 0, from_workers.size
assert_equal 0, to_workers.size
end
+
+ def test_sized_queue_initialize
+ q = SizedQueue.new(1)
+ assert_equal 1, q.max
+ assert_raise(ArgumentError) { SizedQueue.new(0) }
+ assert_raise(ArgumentError) { SizedQueue.new(-1) }
+ end
+
+ def test_sized_queue_assign_max
+ q = SizedQueue.new(2)
+ assert_equal(2, q.max)
+ q.max = 1
+ assert_equal(1, q.max)
+ assert_raise(ArgumentError) { q.max = 0 }
+ assert_equal(1, q.max)
+ assert_raise(ArgumentError) { q.max = -1 }
+ assert_equal(1, q.max)
+ end
end