diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2024-02-15 16:00:51 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2024-02-15 19:11:58 +0900 |
commit | 8f2c231642c9f94947b75769d3cc21b1127b2135 (patch) | |
tree | 81e26f9add3eda627f945fb492f791f92dbdb197 /spec/ruby/core/kernel | |
parent | 9d1b000bd1bb747bcc49e2d7677fb7c2b31c5a94 (diff) |
ruby-spec: Accept the receiver in backtraces
Diffstat (limited to 'spec/ruby/core/kernel')
-rw-r--r-- | spec/ruby/core/kernel/caller_locations_spec.rb | 30 | ||||
-rw-r--r-- | spec/ruby/core/kernel/caller_spec.rb | 4 | ||||
-rw-r--r-- | spec/ruby/core/kernel/public_send_spec.rb | 4 |
3 files changed, 26 insertions, 12 deletions
diff --git a/spec/ruby/core/kernel/caller_locations_spec.rb b/spec/ruby/core/kernel/caller_locations_spec.rb index 5994b28fa3..aaacd9a910 100644 --- a/spec/ruby/core/kernel/caller_locations_spec.rb +++ b/spec/ruby/core/kernel/caller_locations_spec.rb @@ -71,14 +71,28 @@ describe 'Kernel#caller_locations' do end guard -> { Kernel.instance_method(:tap).source_location } do - it "includes core library methods defined in Ruby" do - file, line = Kernel.instance_method(:tap).source_location - file.should.start_with?('<internal:') - - loc = nil - tap { loc = caller_locations(1, 1)[0] } - loc.label.should == "tap" - loc.path.should.start_with? "<internal:" + ruby_version_is ""..."3.4" do + it "includes core library methods defined in Ruby" do + file, line = Kernel.instance_method(:tap).source_location + file.should.start_with?('<internal:') + + loc = nil + tap { loc = caller_locations(1, 1)[0] } + loc.label.should == "tap" + loc.path.should.start_with? "<internal:" + end + end + + ruby_version_is "3.4" do + it "includes core library methods defined in Ruby" do + file, line = Kernel.instance_method(:tap).source_location + file.should.start_with?('<internal:') + + loc = nil + tap { loc = caller_locations(1, 1)[0] } + loc.label.should == "Kernel#tap" + loc.path.should.start_with? "<internal:" + end end end end diff --git a/spec/ruby/core/kernel/caller_spec.rb b/spec/ruby/core/kernel/caller_spec.rb index 6f97a2ce07..c3d63ccb00 100644 --- a/spec/ruby/core/kernel/caller_spec.rb +++ b/spec/ruby/core/kernel/caller_spec.rb @@ -39,7 +39,7 @@ describe 'Kernel#caller' do path = fixture(__FILE__, "caller_at_exit.rb") lines = ruby_exe(path).lines lines.size.should == 2 - lines[0].should =~ /\A#{path}:6:in [`']foo'\n\z/ + lines[0].should =~ /\A#{path}:6:in [`'](?:Object#)?foo'\n\z/ lines[1].should =~ /\A#{path}:2:in [`']block in <main>'\n\z/ end @@ -62,7 +62,7 @@ describe 'Kernel#caller' do loc = nil tap { loc = caller(1, 1)[0] } - loc.should =~ /\A<internal:.*in [`']tap'\z/ + loc.should =~ /\A<internal:.*in [`'](?:Kernel#)?tap'\z/ end end end diff --git a/spec/ruby/core/kernel/public_send_spec.rb b/spec/ruby/core/kernel/public_send_spec.rb index 230ef9659c..b684b1729c 100644 --- a/spec/ruby/core/kernel/public_send_spec.rb +++ b/spec/ruby/core/kernel/public_send_spec.rb @@ -105,11 +105,11 @@ describe "Kernel#public_send" do end it "includes `public_send` in the backtrace when passed not enough arguments" do - -> { public_send() }.should raise_error(ArgumentError) { |e| e.backtrace[0].should =~ /[`']public_send'/ } + -> { public_send() }.should raise_error(ArgumentError) { |e| e.backtrace[0].should =~ /[`'](?:Kernel#)?public_send'/ } end it "includes `public_send` in the backtrace when passed a single incorrect argument" do - -> { public_send(Object.new) }.should raise_error(TypeError) { |e| e.backtrace[0].should =~ /[`']public_send'/ } + -> { public_send(Object.new) }.should raise_error(TypeError) { |e| e.backtrace[0].should =~ /[`'](?:Kernel#)?public_send'/ } end it_behaves_like :basicobject_send, :public_send |