1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Add specs that #caller and #caller_locations include core library methods defined in Ruby

This commit is contained in:
Benoit Daloze 2020-10-11 13:51:34 +02:00
parent 3673c3eafc
commit fbb2d30ee6
Notes: git 2020-10-26 16:48:02 +09:00
2 changed files with 24 additions and 0 deletions

View file

@ -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

View file

@ -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