diff options
Diffstat (limited to 'spec/ruby/core')
-rw-r--r-- | spec/ruby/core/exception/backtrace_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/exception/top_level_spec.rb | 12 | ||||
-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 | ||||
-rw-r--r-- | spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/thread/backtrace/location/label_spec.rb | 10 | ||||
-rw-r--r-- | spec/ruby/core/thread/backtrace_locations_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/thread/backtrace_spec.rb | 2 |
9 files changed, 41 insertions, 27 deletions
diff --git a/spec/ruby/core/exception/backtrace_spec.rb b/spec/ruby/core/exception/backtrace_spec.rb index bce6c95175..9a65ea3820 100644 --- a/spec/ruby/core/exception/backtrace_spec.rb +++ b/spec/ruby/core/exception/backtrace_spec.rb @@ -27,7 +27,7 @@ describe "Exception#backtrace" do end it "includes the name of the method from where self raised in the first element" do - @backtrace.first.should =~ /in [`']backtrace'/ + @backtrace.first.should =~ /in [`'](?:ExceptionSpecs::Backtrace\.)?backtrace'/ end it "includes the filename of the location immediately prior to where self raised in the second element" do diff --git a/spec/ruby/core/exception/top_level_spec.rb b/spec/ruby/core/exception/top_level_spec.rb index 8a1e3b92f9..6ef7539598 100644 --- a/spec/ruby/core/exception/top_level_spec.rb +++ b/spec/ruby/core/exception/top_level_spec.rb @@ -20,13 +20,13 @@ describe "An Exception reaching the top level" do end RUBY lines = ruby_exe(code, args: "2>&1", exit_status: 1).lines - lines.reject! { |l| l.include?('rescue in') } lines.map! { |l| l.chomp[/:(in.+)/, 1] } - lines.size.should == 4 - lines[0].should =~ /\Ain [`']raise_wrapped': wrapped \(RuntimeError\)\z/ - lines[1].should =~ /\Ain [`']<main>'\z/ - lines[2].should =~ /\Ain [`']raise_cause': the cause \(RuntimeError\)\z/ - lines[3].should =~ /\Ain [`']<main>'\z/ + lines.size.should == 5 + lines[0].should =~ /\Ain [`'](?:Object#)?raise_wrapped': wrapped \(RuntimeError\)\z/ + lines[1].should =~ /\Ain [`'](?:rescue in )?<main>'\z/ + lines[2].should =~ /\Ain [`']<main>'\z/ + lines[3].should =~ /\Ain [`'](?:Object#)?raise_cause': the cause \(RuntimeError\)\z/ + lines[4].should =~ /\Ain [`']<main>'\z/ end describe "with a custom backtrace" do 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 diff --git a/spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb b/spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb index e35e1fc0b4..6e381e4868 100644 --- a/spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb +++ b/spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb @@ -59,7 +59,7 @@ describe 'Thread::Backtrace::Location#absolute_path' do it "returns nil" do location = nil tap { location = caller_locations(1, 1)[0] } - location.label.should == "tap" + location.label.should =~ /\A(?:Kernel#)?tap\z/ if location.path.start_with?("<internal:") location.absolute_path.should == nil else diff --git a/spec/ruby/core/thread/backtrace/location/label_spec.rb b/spec/ruby/core/thread/backtrace/location/label_spec.rb index 7312d017e5..85ddccc8e3 100644 --- a/spec/ruby/core/thread/backtrace/location/label_spec.rb +++ b/spec/ruby/core/thread/backtrace/location/label_spec.rb @@ -7,11 +7,11 @@ describe 'Thread::Backtrace::Location#label' do end it 'returns the method name for a method location' do - ThreadBacktraceLocationSpecs.method_location[0].label.should == "method_location" + ThreadBacktraceLocationSpecs.method_location[0].label.should =~ /\A(?:ThreadBacktraceLocationSpecs\.)?method_location\z/ end it 'returns the block name for a block location' do - ThreadBacktraceLocationSpecs.block_location[0].label.should == "block in block_location" + ThreadBacktraceLocationSpecs.block_location[0].label.should =~ /\Ablock in (?:ThreadBacktraceLocationSpecs\.)?block_location\z/ end it 'returns the module name for a module location' do @@ -22,9 +22,9 @@ describe 'Thread::Backtrace::Location#label' do first_level_location, second_level_location, third_level_location = ThreadBacktraceLocationSpecs.locations_inside_nested_blocks - first_level_location.label.should == 'block in locations_inside_nested_blocks' - second_level_location.label.should == 'block (2 levels) in locations_inside_nested_blocks' - third_level_location.label.should == 'block (3 levels) in locations_inside_nested_blocks' + first_level_location.label.should =~ /\Ablock in (?:ThreadBacktraceLocationSpecs\.)?locations_inside_nested_blocks\z/ + second_level_location.label.should =~ /\Ablock \(2 levels\) in (?:ThreadBacktraceLocationSpecs\.)?locations_inside_nested_blocks\z/ + third_level_location.label.should =~ /\Ablock \(3 levels\) in (?:ThreadBacktraceLocationSpecs\.)?locations_inside_nested_blocks\z/ end it 'sets the location label for a top-level block differently depending on it being in the main file or a required file' do diff --git a/spec/ruby/core/thread/backtrace_locations_spec.rb b/spec/ruby/core/thread/backtrace_locations_spec.rb index 1d1a9cd0aa..09fe622e0d 100644 --- a/spec/ruby/core/thread/backtrace_locations_spec.rb +++ b/spec/ruby/core/thread/backtrace_locations_spec.rb @@ -70,7 +70,7 @@ describe "Thread#backtrace_locations" do end it "the first location reports the call to #backtrace_locations" do - Thread.current.backtrace_locations(0..0)[0].to_s.should =~ /\A#{__FILE__ }:#{__LINE__ }:in [`']backtrace_locations'\z/ + Thread.current.backtrace_locations(0..0)[0].to_s.should =~ /\A#{__FILE__ }:#{__LINE__ }:in [`'](?:Thread#)?backtrace_locations'\z/ end it "[1..-1] is the same as #caller_locations(0..-1) for Thread.current" do diff --git a/spec/ruby/core/thread/backtrace_spec.rb b/spec/ruby/core/thread/backtrace_spec.rb index 69e39139f8..15bb29a349 100644 --- a/spec/ruby/core/thread/backtrace_spec.rb +++ b/spec/ruby/core/thread/backtrace_spec.rb @@ -13,7 +13,7 @@ describe "Thread#backtrace" do backtrace = t.backtrace backtrace.should be_kind_of(Array) - backtrace.first.should =~ /[`']sleep'/ + backtrace.first.should =~ /[`'](?:Kernel#)?sleep'/ t.raise 'finish the thread' t.join |