diff --git a/spec/ruby/core/enumerator/yielder/yield_spec.rb b/spec/ruby/core/enumerator/yielder/yield_spec.rb index 94cce7652d..58fc8e007a 100644 --- a/spec/ruby/core/enumerator/yielder/yield_spec.rb +++ b/spec/ruby/core/enumerator/yielder/yield_spec.rb @@ -9,6 +9,13 @@ describe "Enumerator::Yielder#yield" do ary.should == [1] end + it "yields with passed arguments" do + yields = [] + y = Enumerator::Yielder.new {|*args| yields << args } + y.yield 1, 2 + yields.should == [[1, 2]] + end + it "returns the result of the block for the given value" do y = Enumerator::Yielder.new {|x| x + 1} y.yield(1).should == 2 diff --git a/test/ruby/test_enumerator.rb b/test/ruby/test_enumerator.rb index 22ec62e252..a24ff00d96 100644 --- a/test/ruby/test_enumerator.rb +++ b/test/ruby/test_enumerator.rb @@ -476,6 +476,12 @@ class TestEnumerator < Test::Unit::TestCase assert_equal([1], y.yield(1)) assert_equal([1, 2], y.yield(2)) assert_equal([1, 2, 3], y.yield(3)) + assert_equal([1, 2, 3, 4], y.yield(4, 5)) + + a = [] + y = Enumerator::Yielder.new {|*x| a.concat(x) } + assert_equal([1], y.yield(1)) + assert_equal([1, 2, 3], y.yield(2, 3)) assert_raise(LocalJumpError) { Enumerator::Yielder.new } end