aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core/thread/backtrace_locations_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/thread/backtrace_locations_spec.rb')
-rw-r--r--spec/ruby/core/thread/backtrace_locations_spec.rb23
1 files changed, 14 insertions, 9 deletions
diff --git a/spec/ruby/core/thread/backtrace_locations_spec.rb b/spec/ruby/core/thread/backtrace_locations_spec.rb
index 211858899c..ead4be2d8c 100644
--- a/spec/ruby/core/thread/backtrace_locations_spec.rb
+++ b/spec/ruby/core/thread/backtrace_locations_spec.rb
@@ -22,28 +22,33 @@ describe "Thread#backtrace_locations" do
it "can be called with a number of locations to omit" do
locations1 = Thread.current.backtrace_locations
locations2 = Thread.current.backtrace_locations(2)
- locations1[2..-1].length.should == locations2.length
- locations1[2..-1].map(&:to_s).should == locations2.map(&:to_s)
+ locations2.length.should == locations1[2..-1].length
+ locations2.map(&:to_s).should == locations1[2..-1].map(&:to_s)
end
it "can be called with a maximum number of locations to return as second parameter" do
locations1 = Thread.current.backtrace_locations
locations2 = Thread.current.backtrace_locations(2, 3)
- locations1[2..4].map(&:to_s).should == locations2.map(&:to_s)
+ locations2.map(&:to_s).should == locations1[2..4].map(&:to_s)
end
it "can be called with a range" do
locations1 = Thread.current.backtrace_locations
locations2 = Thread.current.backtrace_locations(2..4)
- locations1[2..4].map(&:to_s).should == locations2.map(&:to_s)
+ locations2.map(&:to_s).should == locations1[2..4].map(&:to_s)
end
it "can be called with a range whose end is negative" do
- locations1 = Thread.current.backtrace_locations
- locations2 = Thread.current.backtrace_locations(2..-1)
- locations3 = Thread.current.backtrace_locations(2..-2)
- locations1[2..-1].map(&:to_s).should == locations2.map(&:to_s)
- locations1[2..-2].map(&:to_s).should == locations3.map(&:to_s)
+ Thread.current.backtrace_locations(2..-1).map(&:to_s).should == Thread.current.backtrace_locations[2..-1].map(&:to_s)
+ Thread.current.backtrace_locations(2..-2).map(&:to_s).should == Thread.current.backtrace_locations[2..-2].map(&:to_s)
+ end
+
+ ruby_version_is "2.6" do
+ it "can be called with an endless range" do
+ locations1 = Thread.current.backtrace_locations(0)
+ locations2 = Thread.current.backtrace_locations(eval("(2..)"))
+ locations2.map(&:to_s).should == locations1[2..-1].map(&:to_s)
+ end
end
it "returns nil if omitting more locations than available" do