summaryrefslogtreecommitdiff
path: root/test/ruby/test_thread.rb
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-18 18:48:12 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-18 18:48:12 +0000
commit4920980d17f0dce5e338513d1ae75fa2c4bf9c83 (patch)
tree0773e05e5d083bf30c43ecbc558c9f61689a57f3 /test/ruby/test_thread.rb
parent2a11c7f62a021a3fd6f991182e2ed30642a5c854 (diff)
* thread.c (thread_create_core): prohibit thread creation in the
frozen thread group. a patch in [ruby-dev:33176] from sheepman <sheepman AT sheepman.sakura.ne.jp>. * thread.c (thread_create_core): should inherit ThreadGroup from the current thread. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_thread.rb')
-rw-r--r--test/ruby/test_thread.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index 0d924eea57..b5db362df4 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -22,3 +22,36 @@ class TestThread < Test::Unit::TestCase
end
end
+class TestThreadGroup < Test::Unit::TestCase
+ def test_thread_init
+ thgrp = ThreadGroup.new
+ Thread.new{
+ thgrp.add(Thread.current)
+ assert_equal(thgrp, Thread.new{sleep 1}.group)
+ }.join
+ end
+
+ def test_frozen_thgroup
+ thgrp = ThreadGroup.new
+ Thread.new{
+ thgrp.add(Thread.current)
+ thgrp.freeze
+ assert_raise(ThreadError) do
+ Thread.new{1}.join
+ end
+ }.join
+ end
+
+ def test_enclosed_thgroup
+ thgrp = ThreadGroup.new
+ thgrp.enclose
+ Thread.new{
+ assert_raise(ThreadError) do
+ thgrp.add(Thread.current)
+ end
+ assert_nothing_raised do
+ Thread.new{1}.join
+ end
+ }.join
+ end
+end