summaryrefslogtreecommitdiff
path: root/test/ruby/test_thread.rb
diff options
context:
space:
mode:
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