1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Tests of Enumerator::Yielder#yield with multiple arguments

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2018-09-18 08:30:24 +00:00
parent 32fd8649d8
commit 3367daf716
2 changed files with 13 additions and 0 deletions

View file

@ -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

View file

@ -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