Skip to content

Commit 91ab714

Browse files
herwinweregon
authored andcommitted
Remove duplication from IO.select with infinite timeout
1 parent f61a676 commit 91ab714

1 file changed

Lines changed: 13 additions & 17 deletions

File tree

core/io/select_spec.rb

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -149,25 +149,11 @@
149149
end
150150
end
151151

152-
describe "IO.select when passed nil for timeout" do
153-
it "sleeps forever and sets the thread status to 'sleep'" do
154-
t = Thread.new do
155-
IO.select(nil, nil, nil, nil)
156-
end
157-
158-
Thread.pass while t.status && t.status != "sleep"
159-
t.join unless t.status
160-
t.status.should == "sleep"
161-
t.kill
162-
t.join
163-
end
164-
end
165-
166-
ruby_version_is "4.0" do
167-
describe "IO.select when passed Float::INFINITY for timeout" do
152+
describe "IO.select with infinite timeout" do
153+
describe :io_select_infinite_timeout, shared: true do
168154
it "sleeps forever and sets the thread status to 'sleep'" do
169155
t = Thread.new do
170-
IO.select(nil, nil, nil, Float::INFINITY)
156+
IO.select(nil, nil, nil, @method)
171157
end
172158

173159
Thread.pass while t.status && t.status != "sleep"
@@ -177,4 +163,14 @@
177163
t.join
178164
end
179165
end
166+
167+
describe "IO.select when passed nil for timeout" do
168+
it_behaves_like :io_select_infinite_timeout, nil
169+
end
170+
171+
ruby_version_is "4.0" do
172+
describe "IO.select when passed Float::INFINITY for timeout" do
173+
it_behaves_like :io_select_infinite_timeout, Float::INFINITY
174+
end
175+
end
180176
end

0 commit comments

Comments
 (0)