Skip to content

Commit 96d1072

Browse files
committed
Add more specs for IO.select
1 parent 218c30a commit 96d1072

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

core/io/select_spec.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,26 @@
5555
end
5656
end
5757

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

67+
it "returns the pipe read end in read set if the pipe write end is closed concurrently" do
68+
main = Thread.current
69+
t = Thread.new {
70+
Thread.pass until main.stop?
71+
@wr.close
72+
}
73+
IO.select([@rd]).should == [[@rd], [], []]
74+
ensure
75+
t.join
76+
end
77+
6778
it "invokes to_io on supplied objects that are not IO and returns the supplied objects" do
6879
# make some data available
6980
@wr.write("foobar")

0 commit comments

Comments
 (0)