summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2020-10-11 13:51:34 +0200
committerBenoit Daloze <eregontp@gmail.com>2020-10-26 08:47:33 +0100
commitfbb2d30ee69c68ffad6287c12ca5a43753cd1b9a (patch)
tree2dd83ebfa24b09928506be41695fd5df96a163f1
parent3673c3eafc9defd34f42fab3a468a1520e1cfea0 (diff)
Add specs that #caller and #caller_locations include core library methods defined in Ruby
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3647
-rw-r--r--spec/ruby/core/kernel/caller_locations_spec.rb12
-rw-r--r--spec/ruby/core/kernel/caller_spec.rb12
2 files changed, 24 insertions, 0 deletions
diff --git a/spec/ruby/core/kernel/caller_locations_spec.rb b/spec/ruby/core/kernel/caller_locations_spec.rb
index c4e0084085..8050b5b3ab 100644
--- a/spec/ruby/core/kernel/caller_locations_spec.rb
+++ b/spec/ruby/core/kernel/caller_locations_spec.rb
@@ -65,4 +65,16 @@ describe 'Kernel#caller_locations' do
it "must return the same locations when called with 1..-1 and when called with no arguments" do
caller_locations.map(&:to_s).should == caller_locations(1..-1).map(&:to_s)
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:"
+ end
+ end
end
diff --git a/spec/ruby/core/kernel/caller_spec.rb b/spec/ruby/core/kernel/caller_spec.rb
index b71060770c..06e9ea6fc8 100644
--- a/spec/ruby/core/kernel/caller_spec.rb
+++ b/spec/ruby/core/kernel/caller_spec.rb
@@ -51,4 +51,16 @@ describe 'Kernel#caller' do
locations2.map(&:to_s).should == locations1[2..-1].map(&:to_s)
end
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(1, 1)[0] }
+ loc.should.end_with? "in `tap'"
+ loc.should.start_with? "<internal:"
+ end
+ end
end