2018-03-04 10:09:32 -05:00
|
|
|
require_relative '../../spec_helper'
|
2017-05-07 08:04:49 -04:00
|
|
|
|
|
|
|
describe "ThreadGroup#enclose" do
|
|
|
|
before :each do
|
2019-07-27 06:40:09 -04:00
|
|
|
@q1, @q2 = Queue.new, Queue.new
|
|
|
|
@thread = Thread.new { @q1 << :go; @q2.pop }
|
|
|
|
@q1.pop
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
after :each do
|
2019-07-27 06:40:09 -04:00
|
|
|
@q2 << :done
|
2017-05-07 08:04:49 -04:00
|
|
|
@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
|
2019-07-27 06:40:09 -04:00
|
|
|
-> do
|
2017-05-07 08:04:49 -04:00
|
|
|
default_group.add(@thread)
|
|
|
|
end.should raise_error(ThreadError)
|
|
|
|
end
|
|
|
|
end
|