File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ def initialize(irb_context)
1919 def find_source ( signature , super_level = 0 )
2020 context_binding = @irb_context . workspace . binding
2121 case signature
22- when /\A [A-Z]\w *(::[A-Z]\w *)*\z / # Const::Name
22+ when /\A (::)? [A-Z]\w *(::[A-Z]\w *)*\z / # Const::Name
2323 eval ( signature , context_binding ) # trigger autoload
2424 base = context_binding . receiver . yield_self { |r | r . is_a? ( Module ) ? r : Object }
2525 file , line = base . const_source_location ( signature )
Original file line number Diff line number Diff line change @@ -272,5 +272,33 @@ def foo
272272
273273 assert_match ( %r[#{ @ruby_file . to_path } :2\s +def foo\r \n end] , out )
274274 end
275+
276+ def test_show_source_with_double_colons
277+ write_ruby <<~RUBY
278+ class Foo
279+ end
280+
281+ class Foo
282+ class Bar
283+ end
284+ end
285+
286+ binding.irb
287+ RUBY
288+
289+ out = run_ruby_file do
290+ type "show_source ::Foo"
291+ type "exit"
292+ end
293+
294+ assert_match ( %r[#{ @ruby_file . to_path } :1\s +class Foo\r \n end] , out )
295+
296+ out = run_ruby_file do
297+ type "show_source ::Foo::Bar"
298+ type "exit"
299+ end
300+
301+ assert_match ( %r[#{ @ruby_file . to_path } :5\s +class Bar\r \n end] , out )
302+ end
275303 end
276304end
You can’t perform that action at this time.
0 commit comments