summaryrefslogtreecommitdiff
path: root/spec/ruby/library/io-wait/wait_readable_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/io-wait/wait_readable_spec.rb')
-rw-r--r--spec/ruby/library/io-wait/wait_readable_spec.rb23
1 files changed, 19 insertions, 4 deletions
diff --git a/spec/ruby/library/io-wait/wait_readable_spec.rb b/spec/ruby/library/io-wait/wait_readable_spec.rb
index 06ffbda5c8..d7473f029f 100644
--- a/spec/ruby/library/io-wait/wait_readable_spec.rb
+++ b/spec/ruby/library/io-wait/wait_readable_spec.rb
@@ -1,9 +1,5 @@
require_relative '../../spec_helper'
-ruby_version_is ''...'3.2' do
- require 'io/wait'
-end
-
describe "IO#wait_readable" do
before :each do
@io = File.new(__FILE__ )
@@ -24,4 +20,23 @@ describe "IO#wait_readable" do
it "waits for the IO to become readable with the given large timeout" do
@io.wait_readable(365 * 24 * 60 * 60).should == @io
end
+
+ it "can be interrupted" do
+ rd, wr = IO.pipe
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
+
+ t = Thread.new do
+ rd.wait_readable(10)
+ end
+
+ Thread.pass until t.stop?
+ t.kill
+ t.join
+
+ finish = Process.clock_gettime(Process::CLOCK_MONOTONIC)
+ (finish - start).should < 9
+ ensure
+ rd.close
+ wr.close
+ end
end