mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	Currently, there is not a way to create a sized enumerator in C with a different set of arguments than provided by Ruby, and correctly handle keyword arguments. This function allows that. The need for this is fairly uncommon, but it occurs at least in Enumerator.produce, which takes arugments from Ruby but calls rb_enumeratorize_with_size with a different set of arguments.
		
			
				
	
	
		
			11 lines
		
	
	
	
		
			322 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			11 lines
		
	
	
	
		
			322 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
require 'test/unit'
 | 
						|
require '-test-/enumerator_kw'
 | 
						|
 | 
						|
class TestEnumeratorKw < Test::Unit::TestCase
 | 
						|
  def test_enumerator_kw
 | 
						|
    o = Object.new
 | 
						|
    o.extend Bug::EnumeratorKw
 | 
						|
    assert_equal([nil, [], {:a=>1}, o], o.m(a: 1) { |*a| a })
 | 
						|
    assert_equal([nil, [[], {:a=>1}, o], nil, o], o.m(a: 1).each { |*a| a })
 | 
						|
  end
 | 
						|
end
 |