diff options
author | Benoit Daloze <eregontp@gmail.com> | 2023-06-26 15:55:11 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2023-06-26 15:55:11 +0200 |
commit | 515bd4214497b3af02f6eef51b496ad9a0cf6b3b (patch) | |
tree | 4554360d275a3bb9dc696f952b8f3d1bcd88f18a /spec/ruby/library/io-wait/wait_spec.rb | |
parent | f73fa299279ac322bd921691d1ba0e8bf2b39b5f (diff) |
Update to ruby/spec@30e1c35
Diffstat (limited to 'spec/ruby/library/io-wait/wait_spec.rb')
-rw-r--r-- | spec/ruby/library/io-wait/wait_spec.rb | 100 |
1 files changed, 48 insertions, 52 deletions
diff --git a/spec/ruby/library/io-wait/wait_spec.rb b/spec/ruby/library/io-wait/wait_spec.rb index d968c38774..3861281277 100644 --- a/spec/ruby/library/io-wait/wait_spec.rb +++ b/spec/ruby/library/io-wait/wait_spec.rb @@ -24,73 +24,69 @@ describe "IO#wait" do @w.close unless @w.closed? end - ruby_version_is "3.0" do - context "[events, timeout] passed" do - ruby_version_is "3.0"..."3.2" do - it "returns self when the READABLE event is ready during the timeout" do - @w.write('data to read') - @r.wait(IO::READABLE, 2).should.equal?(@r) - end - - it "returns self when the WRITABLE event is ready during the timeout" do - @w.wait(IO::WRITABLE, 0).should.equal?(@w) - end + context "[events, timeout] passed" do + ruby_version_is ""..."3.2" do + it "returns self when the READABLE event is ready during the timeout" do + @w.write('data to read') + @r.wait(IO::READABLE, 2).should.equal?(@r) end - ruby_version_is "3.2" do - it "returns events mask when the READABLE event is ready during the timeout" do - @w.write('data to read') - @r.wait(IO::READABLE, 2).should == IO::READABLE - end + it "returns self when the WRITABLE event is ready during the timeout" do + @w.wait(IO::WRITABLE, 0).should.equal?(@w) + end + end + + ruby_version_is "3.2" do + it "returns events mask when the READABLE event is ready during the timeout" do + @w.write('data to read') + @r.wait(IO::READABLE, 2).should == IO::READABLE + end - it "returns events mask when the WRITABLE event is ready during the timeout" do - @w.wait(IO::WRITABLE, 0).should == IO::WRITABLE - end + it "returns events mask when the WRITABLE event is ready during the timeout" do + @w.wait(IO::WRITABLE, 0).should == IO::WRITABLE end + end - ruby_version_is "3.0" do - it "waits for the READABLE event to be ready" do - queue = Queue.new - thread = Thread.new { queue.pop; sleep 1; @w.write('data to read') }; + it "waits for the READABLE event to be ready" do + queue = Queue.new + thread = Thread.new { queue.pop; sleep 1; @w.write('data to read') }; - queue.push('signal'); - @r.wait(IO::READABLE, 2).should_not == nil + queue.push('signal'); + @r.wait(IO::READABLE, 2).should_not == nil - thread.join - end + thread.join + end - it "waits for the WRITABLE event to be ready" do - written_bytes = IOWaitSpec.exhaust_write_buffer(@w) + it "waits for the WRITABLE event to be ready" do + written_bytes = IOWaitSpec.exhaust_write_buffer(@w) - queue = Queue.new - thread = Thread.new { queue.pop; sleep 1; @r.read(written_bytes) }; + queue = Queue.new + thread = Thread.new { queue.pop; sleep 1; @r.read(written_bytes) }; - queue.push('signal'); - @w.wait(IO::WRITABLE, 2).should_not == nil + queue.push('signal'); + @w.wait(IO::WRITABLE, 2).should_not == nil - thread.join - end + thread.join + end - it "returns nil when the READABLE event is not ready during the timeout" do - @w.wait(IO::READABLE, 0).should == nil - end + it "returns nil when the READABLE event is not ready during the timeout" do + @w.wait(IO::READABLE, 0).should == nil + end - it "returns nil when the WRITABLE event is not ready during the timeout" do - IOWaitSpec.exhaust_write_buffer(@w) - @w.wait(IO::WRITABLE, 0).should == nil - end + it "returns nil when the WRITABLE event is not ready during the timeout" do + IOWaitSpec.exhaust_write_buffer(@w) + @w.wait(IO::WRITABLE, 0).should == nil + end - it "raises IOError when io is closed (closed stream (IOError))" do - @io.close - -> { @io.wait(IO::READABLE, 0) }.should raise_error(IOError, "closed stream") - end + it "raises IOError when io is closed (closed stream (IOError))" do + @io.close + -> { @io.wait(IO::READABLE, 0) }.should raise_error(IOError, "closed stream") + end - ruby_version_is "3.2" do - it "raises ArgumentError when events is not positive" do - -> { @w.wait(0, 0) }.should raise_error(ArgumentError, "Events must be positive integer!") - -> { @w.wait(-1, 0) }.should raise_error(ArgumentError, "Events must be positive integer!") - end - end + ruby_version_is "3.2" do + it "raises ArgumentError when events is not positive" do + -> { @w.wait(0, 0) }.should raise_error(ArgumentError, "Events must be positive integer!") + -> { @w.wait(-1, 0) }.should raise_error(ArgumentError, "Events must be positive integer!") end end end |