Skip to content

Commit 7d8f274

Browse files
committed
Add a spec for Method#source_location for core methods
1 parent 5e5b7b9 commit 7d8f274

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

spec/ruby/core/method/source_location_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,24 @@ def f
8686
method.source_location[1].should == line
8787
end
8888

89+
it "works for core methods where it returns nil or <internal:" do
90+
loc = method(:__id__).source_location
91+
if loc == nil
92+
loc.should == nil
93+
else
94+
loc[0].should.start_with?('<internal:')
95+
loc[1].should be_kind_of(Integer)
96+
end
97+
98+
loc = method(:tap).source_location
99+
if loc == nil
100+
loc.should == nil
101+
else
102+
loc[0].should.start_with?('<internal:')
103+
loc[1].should be_kind_of(Integer)
104+
end
105+
end
106+
89107
describe "for a Method generated by respond_to_missing?" do
90108
it "returns nil" do
91109
m = MethodSpecs::Methods.new

0 commit comments

Comments
 (0)