ruby-changes:63442
From: Benoit <ko1@a...>
Date: Mon, 26 Oct 2020 16:47:51 +0900 (JST)
Subject: [ruby-changes:63442] fbb2d30ee6 (master): Add specs that #caller and #caller_locations include core library methods defined in Ruby
https://git.ruby-lang.org/ruby.git/commit/?id=fbb2d30ee6 From fbb2d30ee69c68ffad6287c12ca5a43753cd1b9a Mon Sep 17 00:00:00 2001 From: Benoit Daloze <eregontp@g...> Date: Sun, 11 Oct 2020 13:51:34 +0200 Subject: Add specs that #caller and #caller_locations include core library methods defined in Ruby diff --git a/spec/ruby/core/kernel/caller_locations_spec.rb b/spec/ruby/core/kernel/caller_locations_spec.rb index c4e0084..8050b5b 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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/caller_locations_spec.rb#L65 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 b710607..06e9ea6 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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/caller_spec.rb#L51 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/