enum.c: check argument first

* enum.c (enum_cycle_size): check an argument before the size of
  the receiver, if it is given.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60668 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-11-05 23:32:50 +00:00
parent 6c1f11592c
commit 4b7f531553
3 changed files with 13 additions and 8 deletions

View file

@ -590,6 +590,8 @@ class TestEnumerator < Test::Unit::TestCase
assert_equal 126, @sized.cycle(3).size
assert_equal Float::INFINITY, [].to_enum { 42 }.cycle.size
assert_equal 0, [].to_enum { 0 }.cycle.size
assert_raise(TypeError) {[].to_enum { 0 }.cycle("").size}
end
def test_size_for_loops