mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
24 lines
560 B
Ruby
24 lines
560 B
Ruby
require_relative '../../spec_helper'
|
|
|
|
describe "ThreadGroup#enclose" do
|
|
before :each do
|
|
@q1, @q2 = Queue.new, Queue.new
|
|
@thread = Thread.new { @q1 << :go; @q2.pop }
|
|
@q1.pop
|
|
end
|
|
|
|
after :each do
|
|
@q2 << :done
|
|
@thread.join
|
|
end
|
|
|
|
it "raises a ThreadError if attempting to move a Thread from an enclosed ThreadGroup" do
|
|
thread_group = ThreadGroup.new
|
|
default_group = @thread.group
|
|
thread_group.add(@thread)
|
|
thread_group.enclose
|
|
-> do
|
|
default_group.add(@thread)
|
|
end.should raise_error(ThreadError)
|
|
end
|
|
end
|