summaryrefslogtreecommitdiffstats
path: root/test
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
commitf256840920c9dac73c05a34a3d5e1e3b6021acc2 (patch)
tree0773e05e5d083bf30c43ecbc558c9f61689a57f3 /test
parent65c68b606e40d75b0a6b5780b54d5b503b8ee810 (diff)
downloadruby-f256840920c9dac73c05a34a3d5e1e3b6021acc2.tar.gz
ruby-f256840920c9dac73c05a34a3d5e1e3b6021acc2.tar.xz
ruby-f256840920c9dac73c05a34a3d5e1e3b6021acc2.zip
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@15118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-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 0d924eea5..b5db362df 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