From f256840920c9dac73c05a34a3d5e1e3b6021acc2 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: http://svn.ruby-lang.org/repos/ruby/trunk@15118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_thread.rb | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'test/ruby') 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 -- cgit