Skip to content

Commit

Permalink
Add more specs for IO.select
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Sep 4, 2023
1 parent 218c30a commit 96d1072
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions core/io/select_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,26 @@
end
end

it "returns supplied objects correctly even when monitoring the same object in different arrays" do
filename = tmp("IO_select_pipe_file") + $$.to_s
it "returns supplied objects correctly when monitoring the same object in different arrays" do
filename = tmp("IO_select_pipe_file")
io = File.open(filename, 'w+')
result = IO.select [io], [io], nil, 0
result.should == [[io], [io], []]
io.close
rm_r filename
end

it "returns the pipe read end in read set if the pipe write end is closed concurrently" do
main = Thread.current
t = Thread.new {
Thread.pass until main.stop?
@wr.close
}
IO.select([@rd]).should == [[@rd], [], []]
ensure
t.join
end

it "invokes to_io on supplied objects that are not IO and returns the supplied objects" do
# make some data available
@wr.write("foobar")
Expand Down

0 comments on commit 96d1072

Please sign in to comment.