diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-30 13:12:22 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-30 13:12:22 +0000 |
commit | e4cc791f87700ea6d59d358e2f688fcc85c45676 (patch) | |
tree | 32659abb3ce0c13650098010675cb6fa498c618d /test | |
parent | 7cdb2840dfa66de6455a3a3034229047de54bdd1 (diff) | |
download | ruby-e4cc791f87700ea6d59d358e2f688fcc85c45676.tar.gz |
enum.c: check if reentered
* enum.c (cmpint_reenter_check): extract from nmin_cmp and
nmin_block_cmp.
* enum.c (nmin_cmp): check if reentered before rb_cmpint.
[Feature #13437]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_enum.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb index 57616791bb..991bda9b3f 100644 --- a/test/ruby/test_enum.rb +++ b/test/ruby/test_enum.rb @@ -604,6 +604,22 @@ class TestEnumerable < Test::Unit::TestCase [o, o, o].sort_by {|x| x } c.call end + + assert_raise_with_message(RuntimeError, /reentered/) do + i = 0 + c = nil + o = Object.new + class << o; self; end.class_eval do + define_method(:<=>) do |x| + callcc {|c2| c ||= c2 } + i += 1 + 0 + end + end + [o, o].min(1) + assert_operator(i, :<=, 5, "infinite loop") + c.call + end end def test_reverse_each |