diff options
author | Mike Dalessio <mike.dalessio@gmail.com> | 2021-09-20 10:09:14 -0400 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2021-10-16 06:31:11 +0900 |
commit | 4ffc3fb019bd1373991ca9278299f6d7c44c3024 (patch) | |
tree | 7feb4734a102253db807c6a2eb4eab6ec9ff5f84 /test/rdoc/test_rdoc_any_method.rb | |
parent | 5d975684da6d7b8ce309c2b176698b37eac5cabb (diff) | |
download | ruby-4ffc3fb019bd1373991ca9278299f6d7c44c3024.tar.gz |
[ruby/rdoc] fix: alias to method with call-seq
This change fixes alias call-seq to return nil if the method's
call-seq does not specify the alias.
Previously, the alias's call-seq would be an empty string in this case
which broke darkfish rendering.
This change also backfills test coverage for 0ead786 which moved
call-seq deduplication into AnyMethod.
https://github.com/ruby/rdoc/commit/5ce2789b6f
Diffstat (limited to 'test/rdoc/test_rdoc_any_method.rb')
-rw-r--r-- | test/rdoc/test_rdoc_any_method.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/rdoc/test_rdoc_any_method.rb b/test/rdoc/test_rdoc_any_method.rb index 615789dfb3..caff86b059 100644 --- a/test/rdoc/test_rdoc_any_method.rb +++ b/test/rdoc/test_rdoc_any_method.rb @@ -72,6 +72,54 @@ method(a, b) { |c, d| ... } assert_nil m1.is_alias_for, 'missing alias' end + def test_call_seq_handles_aliases + # see 0ead786 + @store.path = Dir.tmpdir + top_level = @store.add_file 'file.rb' + cm = top_level.add_class RDoc::ClassModule, 'Klass' + + method_with_call_seq = RDoc::AnyMethod.new(nil, "method_with_call_seq") + method_with_call_seq.call_seq = <<~SEQ + method_with_call_seq(a) + method_with_call_seq(a, b) + alias_to_method(a) + alias_to_method(a, b) + SEQ + cm.add_method(method_with_call_seq) + + alias_to_method = method_with_call_seq.add_alias( + RDoc::Alias.new(nil, "method_with_call_seq", "alias_to_method", "comment"), + cm + ) + + assert_equal("method_with_call_seq(a)\nmethod_with_call_seq(a, b)", + method_with_call_seq.call_seq) + assert_equal("alias_to_method(a)\nalias_to_method(a, b)", + alias_to_method.call_seq) + end + + def test_call_seq_returns_nil_if_alias_is_missing_from_call_seq + @store.path = Dir.tmpdir + top_level = @store.add_file 'file.rb' + cm = top_level.add_class RDoc::ClassModule, 'Klass' + + method_with_call_seq = RDoc::AnyMethod.new(nil, "method_with_call_seq") + method_with_call_seq.call_seq = <<~SEQ + method_with_call_seq(a) + method_with_call_seq(a, b) + SEQ + cm.add_method(method_with_call_seq) + + alias_to_method = method_with_call_seq.add_alias( + RDoc::Alias.new(nil, "method_with_call_seq", "alias_to_method", "comment"), + cm + ) + + assert_equal("method_with_call_seq(a)\nmethod_with_call_seq(a, b)", + method_with_call_seq.call_seq) + assert_nil(alias_to_method.call_seq) + end + def test_markup_code tokens = [ { :line_no => 0, :char_no => 0, :kind => :on_const, :text => 'CONSTANT' }, |