From 1243255c3a36433041012b6107a5ac48658a0895 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 30 Nov 2019 21:26:52 +0100 Subject: Update to ruby/spec@4eec3dc --- spec/ruby/core/exception/signal_exception_spec.rb | 51 +++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'spec/ruby/core/exception/signal_exception_spec.rb') diff --git a/spec/ruby/core/exception/signal_exception_spec.rb b/spec/ruby/core/exception/signal_exception_spec.rb index e0b30236f7..e494e18cde 100644 --- a/spec/ruby/core/exception/signal_exception_spec.rb +++ b/spec/ruby/core/exception/signal_exception_spec.rb @@ -30,6 +30,12 @@ describe "SignalException.new" do -> { SignalException.new("NONEXISTENT") }.should raise_error(ArgumentError) end + ruby_version_is "2.6" do + it "raises an exception with an invalid first argument type" do + -> { SignalException.new(Object.new) }.should raise_error(ArgumentError) + end + end + it "takes a signal symbol without SIG prefix as the first argument" do exc = SignalException.new(:INT) exc.signo.should == Signal.list["INT"] @@ -72,3 +78,48 @@ describe "rescuing SignalException" do end end end + +describe "SignalException" do + it "can be rescued" do + ruby_exe(<<-RUBY) + begin + raise SignalException, 'SIGKILL' + rescue SignalException + exit(0) + end + exit(1) + RUBY + + $?.exitstatus.should == 0 + end + + platform_is_not :windows do + it "runs after at_exit" do + output = ruby_exe(<<-RUBY) + at_exit do + puts "hello" + $stdout.flush + end + + raise SignalException, 'SIGKILL' + RUBY + + $?.termsig.should == Signal.list.fetch("KILL") + output.should == "hello\n" + end + + it "cannot be trapped with Signal.trap" do + ruby_exe(<<-RUBY) + Signal.trap("PROF") {} + raise(SignalException, "PROF") + RUBY + + $?.termsig.should == Signal.list.fetch("PROF") + end + + it "self-signals for USR1" do + ruby_exe("raise(SignalException, 'USR1')") + $?.termsig.should == Signal.list.fetch('USR1') + end + end +end -- cgit v1.2.3