diff options
author | Benoit Daloze <eregontp@gmail.com> | 2020-11-13 13:17:24 +0100 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2020-11-13 13:17:24 +0100 |
commit | 6d05967468ea58ba481259718f07b3cb5a386945 (patch) | |
tree | e21976cdae28f91bcac002dc463a099ca64d111d /spec/ruby/optional | |
parent | acbe7aa19705905e7ad1952395e98e8bfe583a97 (diff) | |
download | ruby-6d05967468ea58ba481259718f07b3cb5a386945.tar.gz |
Update to ruby/spec@b0b7f53
Diffstat (limited to 'spec/ruby/optional')
-rw-r--r-- | spec/ruby/optional/capi/kernel_spec.rb | 12 | ||||
-rw-r--r-- | spec/ruby/optional/capi/module_spec.rb | 6 | ||||
-rw-r--r-- | spec/ruby/optional/capi/struct_spec.rb | 2 |
3 files changed, 14 insertions, 6 deletions
diff --git a/spec/ruby/optional/capi/kernel_spec.rb b/spec/ruby/optional/capi/kernel_spec.rb index 44cf311895..7539e0c01c 100644 --- a/spec/ruby/optional/capi/kernel_spec.rb +++ b/spec/ruby/optional/capi/kernel_spec.rb @@ -396,12 +396,20 @@ describe "C-API Kernel function" do proc = -> x { x } arg_error_proc = -> *_ { raise ArgumentError, '' } run_error_proc = -> *_ { raise RuntimeError, '' } - type_error_proc = -> *_ { raise TypeError, '' } + type_error_proc = -> *_ { raise Exception, 'custom error' } @s.rb_rescue2(arg_error_proc, :no_exc, proc, :exc, ArgumentError, RuntimeError).should == :exc @s.rb_rescue2(run_error_proc, :no_exc, proc, :exc, ArgumentError, RuntimeError).should == :exc -> { @s.rb_rescue2(type_error_proc, :no_exc, proc, :exc, ArgumentError, RuntimeError) - }.should raise_error(TypeError) + }.should raise_error(Exception, 'custom error') + end + + ruby_bug "#17305", ""..."2.7" do + it "raises TypeError if one of the passed exceptions is not a Module" do + -> { + @s.rb_rescue2(-> *_ { raise RuntimeError, "foo" }, :no_exc, -> x { x }, :exc, Object.new, 42) + }.should raise_error(TypeError, /class or module required/) + end end end diff --git a/spec/ruby/optional/capi/module_spec.rb b/spec/ruby/optional/capi/module_spec.rb index f5ce7ed8de..fde86d2223 100644 --- a/spec/ruby/optional/capi/module_spec.rb +++ b/spec/ruby/optional/capi/module_spec.rb @@ -135,7 +135,7 @@ describe "CApiModule" do end it "returns a constant defined at toplevel" do - @m.rb_const_get(CApiModuleSpecs::A, :Fixnum).should == Fixnum + @m.rb_const_get(CApiModuleSpecs::A, :Integer).should == Integer end it "returns a constant defined in a superclass" do @@ -176,8 +176,8 @@ describe "CApiModule" do end it "calls #const_missing if the constant is not defined in the class or ancestors" do - CApiModuleSpecs::M.should_receive(:const_missing).with(:Fixnum) - @m.rb_const_get_from(CApiModuleSpecs::M, :Fixnum) + CApiModuleSpecs::M.should_receive(:const_missing).with(:Integer) + @m.rb_const_get_from(CApiModuleSpecs::M, :Integer) end it "resolves autoload constants" do diff --git a/spec/ruby/optional/capi/struct_spec.rb b/spec/ruby/optional/capi/struct_spec.rb index c071203673..0e9e366908 100644 --- a/spec/ruby/optional/capi/struct_spec.rb +++ b/spec/ruby/optional/capi/struct_spec.rb @@ -62,7 +62,7 @@ describe "C-API Struct function" do end describe "C-API Struct function" do - before :each do + before :all do @s = CApiStructSpecs.new @struct = @s.rb_struct_define_under(CApiStructSpecs, "CAPIStructUnder", "a", "b", "c") end |