File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -240,7 +240,15 @@ def param_list
240240 return [ ]
241241 end
242242
243- params = params . gsub ( /\s +/ , '' ) . split ','
243+ if @block_params then
244+ # If this method has explicit block parameters, remove any explicit
245+ # &block
246+ params . sub! ( /,?\s *&\w +/ , '' )
247+ else
248+ params . sub! ( /\& (\w +)/ , '\1' )
249+ end
250+
251+ params = params . gsub ( /\s +/ , '' ) . split ( ',' ) . reject ( &:empty? )
244252
245253 params . map { |param | param . sub ( /=.*/ , '' ) }
246254 end
Original file line number Diff line number Diff line change @@ -334,6 +334,35 @@ def test_param_list_params_block_params
334334 assert_equal %w[ a b c d ] , m . param_list
335335 end
336336
337+ def test_param_list_empty_params_with_block
338+ m = RDoc ::AnyMethod . new nil , 'method'
339+ m . parent = @c1
340+
341+ m . params = '()'
342+ m . block_params = 'a, b'
343+
344+ assert_equal %w[ a b ] , m . param_list
345+ end
346+
347+ def test_param_list_ampersand_param_block_params
348+ m = RDoc ::AnyMethod . new nil , 'method'
349+ m . parent = @c1
350+
351+ m . params = '(a, b, &block)'
352+ m . block_params = 'c, d'
353+
354+ assert_equal %w[ a b c d ] , m . param_list
355+ end
356+
357+ def test_param_list_ampersand_param
358+ m = RDoc ::AnyMethod . new nil , 'method'
359+ m . parent = @c1
360+
361+ m . params = '(a, b, &block)'
362+
363+ assert_equal %w[ a b block ] , m . param_list
364+ end
365+
337366 def test_param_seq
338367 m = RDoc ::AnyMethod . new nil , 'method'
339368 m . parent = @c1
You can’t perform that action at this time.
0 commit comments