1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/spec/ruby/core/threadgroup/enclose_spec.rb

25 lines
560 B
Ruby
Raw Normal View History

require_relative '../../spec_helper'
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
end
after :each do
2019-07-27 06:40:09 -04:00
@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
2019-07-27 06:40:09 -04:00
-> do
default_group.add(@thread)
end.should raise_error(ThreadError)
end
end