summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorStan Lo <stan001212@gmail.com>2024-01-01 17:40:35 +0000
committergit <svn-admin@ruby-lang.org>2024-01-01 17:40:38 +0000
commit676748abcad62c021fc122d137f177d3c0f0f7a8 (patch)
tree4469367d361b5204b1e17e66b8ded3241b6ce03b /test
parent6934a60ab1d68ff89e0088a951a4c205f3c60332 (diff)
[ruby/irb] Make show_source resolve top-level constant names
(https://github.com/ruby/irb/pull/831) https://github.com/ruby/irb/commit/5843616c78
Diffstat (limited to 'test')
-rw-r--r--test/irb/cmd/test_show_source.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/irb/cmd/test_show_source.rb b/test/irb/cmd/test_show_source.rb
index cedec8aa6f..12abae3c72 100644
--- a/test/irb/cmd/test_show_source.rb
+++ b/test/irb/cmd/test_show_source.rb
@@ -272,5 +272,33 @@ module TestIRB
assert_match(%r[#{@ruby_file.to_path}:2\s+def foo\r\n end], out)
end
+
+ def test_show_source_with_double_colons
+ write_ruby <<~RUBY
+ class Foo
+ end
+
+ class Foo
+ class Bar
+ end
+ end
+
+ binding.irb
+ RUBY
+
+ out = run_ruby_file do
+ type "show_source ::Foo"
+ type "exit"
+ end
+
+ assert_match(%r[#{@ruby_file.to_path}:1\s+class Foo\r\nend], out)
+
+ out = run_ruby_file do
+ type "show_source ::Foo::Bar"
+ type "exit"
+ end
+
+ assert_match(%r[#{@ruby_file.to_path}:5\s+class Bar\r\n end], out)
+ end
end
end