From 4920980d17f0dce5e338513d1ae75fa2c4bf9c83 Mon Sep 17 00:00:00 2001 From: matz Date: Fri, 18 Jan 2008 18:48:12 +0000 Subject: * thread.c (thread_create_core): prohibit thread creation in the frozen thread group. a patch in [ruby-dev:33176] from sheepman . * 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 --- test/ruby/test_thread.rb | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'test') 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 -- cgit v1.2.3