diff options
| author | Benoit Daloze <eregontp@gmail.com> | 2021-01-28 17:08:57 +0100 |
|---|---|---|
| committer | Benoit Daloze <eregontp@gmail.com> | 2021-01-28 17:08:57 +0100 |
| commit | 2e32b919b4f2f5b7f2e1509d6fa985526ef1f61c (patch) | |
| tree | aedadac3c99ca0097c2bbeaa95830332d6fb9971 /spec/ruby/core/thread/pending_interrupt_spec.rb | |
| parent | 1b377b32c8616f85c0a97e68758c5c2db83f2169 (diff) | |
Update to ruby/spec@8cafaa5
Diffstat (limited to 'spec/ruby/core/thread/pending_interrupt_spec.rb')
| -rw-r--r-- | spec/ruby/core/thread/pending_interrupt_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/ruby/core/thread/pending_interrupt_spec.rb b/spec/ruby/core/thread/pending_interrupt_spec.rb new file mode 100644 index 0000000000..cd565d92a4 --- /dev/null +++ b/spec/ruby/core/thread/pending_interrupt_spec.rb @@ -0,0 +1,32 @@ +require_relative '../../spec_helper' + +describe "Thread.pending_interrupt?" do + it "returns false if there are no pending interrupts, e.g., outside any Thread.handle_interrupt block" do + Thread.pending_interrupt?.should == false + end + + it "returns true if there are pending interrupts, e.g., Thread#raise inside Thread.handle_interrupt" do + executed = false + -> { + Thread.handle_interrupt(RuntimeError => :never) do + Thread.pending_interrupt?.should == false + + current = Thread.current + Thread.new { + current.raise "interrupt" + }.join + + Thread.pending_interrupt?.should == true + executed = true + end + }.should raise_error(RuntimeError, "interrupt") + executed.should == true + Thread.pending_interrupt?.should == false + end +end + +describe "Thread#pending_interrupt?" do + it "returns whether the given threads has pending interrupts" do + Thread.current.pending_interrupt?.should == false + end +end |
