1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/-ext-/test_enumerator_kw.rb
Jeremy Evans 3073404e74 Add rb_enumeratorize_with_size_kw and related macros
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.
2019-09-30 07:06:42 -07:00

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