From a2fac1d72c225192018f8f3f3dfcfcc46f66c08a Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Fri, 27 Dec 2019 16:46:08 +0100 Subject: Update to ruby/spec@d419e74 --- spec/ruby/core/exception/errno_spec.rb | 4 ---- spec/ruby/core/exception/exit_value_spec.rb | 7 ++++++- spec/ruby/core/exception/frozen_error_spec.rb | 8 -------- spec/ruby/core/exception/incomplete_input_spec.rb | 4 +++- spec/ruby/core/exception/io_error_spec.rb | 6 ------ spec/ruby/core/exception/name_error_spec.rb | 18 ++++++++++++------ spec/ruby/core/exception/no_method_error_spec.rb | 14 ++++++++++++++ spec/ruby/core/exception/range_error_spec.rb | 7 ------- spec/ruby/core/exception/reason_spec.rb | 7 ++++++- spec/ruby/core/exception/result_spec.rb | 6 ------ spec/ruby/core/exception/signm_spec.rb | 6 +++++- spec/ruby/core/exception/signo_spec.rb | 6 +++++- spec/ruby/core/exception/status_spec.rb | 6 +++++- spec/ruby/core/exception/success_spec.rb | 12 +++++++++++- spec/ruby/core/exception/system_call_error_spec.rb | 13 +++++++++++++ spec/ruby/core/exception/system_stack_error_spec.rb | 7 ------- spec/ruby/core/exception/uncaught_throw_error_spec.rb | 6 ------ 17 files changed, 80 insertions(+), 57 deletions(-) delete mode 100644 spec/ruby/core/exception/range_error_spec.rb delete mode 100644 spec/ruby/core/exception/system_stack_error_spec.rb (limited to 'spec/ruby/core/exception') diff --git a/spec/ruby/core/exception/errno_spec.rb b/spec/ruby/core/exception/errno_spec.rb index 9e0bf0086a..e76b29349e 100644 --- a/spec/ruby/core/exception/errno_spec.rb +++ b/spec/ruby/core/exception/errno_spec.rb @@ -1,10 +1,6 @@ require_relative '../../spec_helper' require_relative 'fixtures/common' -describe "SystemCallError#errno" do - it "needs to be reviewed for spec completeness" -end - describe "Errno::EINVAL.new" do it "can be called with no arguments" do exc = Errno::EINVAL.new diff --git a/spec/ruby/core/exception/exit_value_spec.rb b/spec/ruby/core/exception/exit_value_spec.rb index 43de56af8b..8bb3cf898d 100644 --- a/spec/ruby/core/exception/exit_value_spec.rb +++ b/spec/ruby/core/exception/exit_value_spec.rb @@ -1,5 +1,10 @@ require_relative '../../spec_helper' describe "LocalJumpError#exit_value" do - it "needs to be reviewed for spec completeness" + def get_me_a_return + Proc.new { return 42 } + end + -> { get_me_a_return.call }.should raise_error(LocalJumpError) { |e| + e.exit_value.should == 42 + } end diff --git a/spec/ruby/core/exception/frozen_error_spec.rb b/spec/ruby/core/exception/frozen_error_spec.rb index 1b5ea71148..f27b33295c 100644 --- a/spec/ruby/core/exception/frozen_error_spec.rb +++ b/spec/ruby/core/exception/frozen_error_spec.rb @@ -1,13 +1,5 @@ require_relative '../../spec_helper' -describe "FrozenError" do - ruby_version_is "2.5" do - it "is a subclass of RuntimeError" do - RuntimeError.should be_ancestor_of(FrozenError) - end - end -end - describe "FrozenError.new" do ruby_version_is "2.7" do it "should take optional receiver argument" do diff --git a/spec/ruby/core/exception/incomplete_input_spec.rb b/spec/ruby/core/exception/incomplete_input_spec.rb index b033b33f56..930a3f01d5 100644 --- a/spec/ruby/core/exception/incomplete_input_spec.rb +++ b/spec/ruby/core/exception/incomplete_input_spec.rb @@ -1,5 +1,7 @@ require_relative '../../spec_helper' describe "Encoding::InvalidByteSequenceError#incomplete_input?" do - it "needs to be reviewed for spec completeness" + -> {"abc\xa4def".encode("ISO-8859-1", "EUC-JP") }.should raise_error(Encoding::InvalidByteSequenceError) { |e| + e.incomplete_input?.should == false + } end diff --git a/spec/ruby/core/exception/io_error_spec.rb b/spec/ruby/core/exception/io_error_spec.rb index 8dc10cc6ce..ab8a72518f 100644 --- a/spec/ruby/core/exception/io_error_spec.rb +++ b/spec/ruby/core/exception/io_error_spec.rb @@ -1,11 +1,5 @@ require_relative '../../spec_helper' -describe "IOError" do - it "is a superclass of EOFError" do - IOError.should be_ancestor_of(EOFError) - end -end - describe "IO::EAGAINWaitReadable" do it "combines Errno::EAGAIN and IO::WaitReadable" do IO::EAGAINWaitReadable.superclass.should == Errno::EAGAIN diff --git a/spec/ruby/core/exception/name_error_spec.rb b/spec/ruby/core/exception/name_error_spec.rb index d0a810029b..e901a80c42 100644 --- a/spec/ruby/core/exception/name_error_spec.rb +++ b/spec/ruby/core/exception/name_error_spec.rb @@ -1,11 +1,5 @@ require_relative '../../spec_helper' -describe "NameError" do - it "is a superclass of NoMethodError" do - NameError.should be_ancestor_of(NoMethodError) - end -end - describe "NameError.new" do it "should take optional name argument" do NameError.new("msg","name").name.should == "name" @@ -22,3 +16,15 @@ describe "NameError.new" do end end end + +describe "NameError#dup" do + it "copies the name and receiver" do + begin + foo + rescue NameError => ne + name_error_dup = ne.dup + name_error_dup.name.should == :foo + name_error_dup.receiver.should == self + end + end +end diff --git a/spec/ruby/core/exception/no_method_error_spec.rb b/spec/ruby/core/exception/no_method_error_spec.rb index 28c3549562..93224c0740 100644 --- a/spec/ruby/core/exception/no_method_error_spec.rb +++ b/spec/ruby/core/exception/no_method_error_spec.rb @@ -104,3 +104,17 @@ describe "NoMethodError#message" do end end end + +describe "NoMethodError#dup" do + it "copies the name, arguments and receiver" do + begin + receiver = Object.new + receiver.foo(:one, :two) + rescue NoMethodError => nme + no_method_error_dup = nme.dup + no_method_error_dup.name.should == :foo + no_method_error_dup.receiver.should == receiver + no_method_error_dup.args.should == [:one, :two] + end + end +end diff --git a/spec/ruby/core/exception/range_error_spec.rb b/spec/ruby/core/exception/range_error_spec.rb deleted file mode 100644 index 7cfbd0f1ec..0000000000 --- a/spec/ruby/core/exception/range_error_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require_relative '../../spec_helper' - -describe "RangeError" do - it "is a superclass of FloatDomainError" do - RangeError.should be_ancestor_of(FloatDomainError) - end -end diff --git a/spec/ruby/core/exception/reason_spec.rb b/spec/ruby/core/exception/reason_spec.rb index 6f18aaae13..b28cbde8d9 100644 --- a/spec/ruby/core/exception/reason_spec.rb +++ b/spec/ruby/core/exception/reason_spec.rb @@ -1,5 +1,10 @@ require_relative '../../spec_helper' describe "LocalJumpError#reason" do - it "needs to be reviewed for spec completeness" + def get_me_a_return + Proc.new { return 42 } + end + -> { get_me_a_return.call }.should raise_error(LocalJumpError) { |e| + e.reason.should == :return + } end diff --git a/spec/ruby/core/exception/result_spec.rb b/spec/ruby/core/exception/result_spec.rb index 5ba26ebab1..2f12673295 100644 --- a/spec/ruby/core/exception/result_spec.rb +++ b/spec/ruby/core/exception/result_spec.rb @@ -1,11 +1,5 @@ require_relative '../../spec_helper' -describe "StopIteration" do - it "is a subclass of IndexError" do - StopIteration.superclass.should equal(IndexError) - end -end - describe "StopIteration#result" do before :each do obj = Object.new diff --git a/spec/ruby/core/exception/signm_spec.rb b/spec/ruby/core/exception/signm_spec.rb index 8e3adcddae..4adff3b5ee 100644 --- a/spec/ruby/core/exception/signm_spec.rb +++ b/spec/ruby/core/exception/signm_spec.rb @@ -1,5 +1,9 @@ require_relative '../../spec_helper' describe "SignalException#signm" do - it "needs to be reviewed for spec completeness" + it "returns the signal name" do + -> { Process.kill(:TERM, Process.pid) }.should raise_error(SignalException) { |e| + e.signm.should == 'SIGTERM' + } + end end diff --git a/spec/ruby/core/exception/signo_spec.rb b/spec/ruby/core/exception/signo_spec.rb index 2d04cd7805..62fc321516 100644 --- a/spec/ruby/core/exception/signo_spec.rb +++ b/spec/ruby/core/exception/signo_spec.rb @@ -1,5 +1,9 @@ require_relative '../../spec_helper' describe "SignalException#signo" do - it "needs to be reviewed for spec completeness" + it "returns the signal number" do + -> { Process.kill(:TERM, Process.pid) }.should raise_error(SignalException) { |e| + e.signo.should == Signal.list['TERM'] + } + end end diff --git a/spec/ruby/core/exception/status_spec.rb b/spec/ruby/core/exception/status_spec.rb index 1609bff3a5..8ace00fe10 100644 --- a/spec/ruby/core/exception/status_spec.rb +++ b/spec/ruby/core/exception/status_spec.rb @@ -1,5 +1,9 @@ require_relative '../../spec_helper' describe "SystemExit#status" do - it "needs to be reviewed for spec completeness" + it "returns the exit status" do + -> { exit 42 }.should raise_error(SystemExit) { |e| + e.status.should == 42 + } + end end diff --git a/spec/ruby/core/exception/success_spec.rb b/spec/ruby/core/exception/success_spec.rb index 82e3df92c6..70af9c74eb 100644 --- a/spec/ruby/core/exception/success_spec.rb +++ b/spec/ruby/core/exception/success_spec.rb @@ -1,5 +1,15 @@ require_relative '../../spec_helper' describe "SystemExit#success?" do - it "needs to be reviewed for spec completeness" + it "returns true if the process exited successfully" do + -> { exit 0 }.should raise_error(SystemExit) { |e| + e.success?.should == true + } + end + + it "returns false if the process exited unsuccessfully" do + -> { exit(-1) }.should raise_error(SystemExit) { |e| + e.success?.should == false + } + end end diff --git a/spec/ruby/core/exception/system_call_error_spec.rb b/spec/ruby/core/exception/system_call_error_spec.rb index c510ae440f..f27977a547 100644 --- a/spec/ruby/core/exception/system_call_error_spec.rb +++ b/spec/ruby/core/exception/system_call_error_spec.rb @@ -128,3 +128,16 @@ describe "SystemCallError#message" do SystemCallError.new("XXX").message.should =~ /XXX/ end end + +describe "SystemCallError#dup" do + it "copies the errno" do + dup_sce = SystemCallError.new("message", 42).dup + dup_sce.errno.should == 42 + end +end + +describe "SystemCallError#backtrace" do + it "is nil if not raised" do + SystemCallError.new("message", 42).backtrace.should == nil + end +end diff --git a/spec/ruby/core/exception/system_stack_error_spec.rb b/spec/ruby/core/exception/system_stack_error_spec.rb deleted file mode 100644 index 0343d2da59..0000000000 --- a/spec/ruby/core/exception/system_stack_error_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require_relative '../../spec_helper' - -describe "SystemStackError" do - it "is a subclass of Exception" do - SystemStackError.superclass.should == Exception - end -end diff --git a/spec/ruby/core/exception/uncaught_throw_error_spec.rb b/spec/ruby/core/exception/uncaught_throw_error_spec.rb index 57f391d755..9267df6670 100644 --- a/spec/ruby/core/exception/uncaught_throw_error_spec.rb +++ b/spec/ruby/core/exception/uncaught_throw_error_spec.rb @@ -1,11 +1,5 @@ require_relative '../../spec_helper' -describe "UncaughtThrowError" do - it "is a subclass of ArgumentError" do - ArgumentError.should be_ancestor_of(UncaughtThrowError) - end -end - describe "UncaughtThrowError#tag" do it "returns the object thrown" do begin -- cgit v1.2.3