diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-24 08:00:42 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-24 08:00:42 +0000 |
commit | 5e25bfa2fbd659c7e0fe8c244633dc847218cee5 (patch) | |
tree | 0d9db068642ea6cd430e8c9a87e6dbc860bef5a7 /test/ruby/test_enum.rb | |
parent | da9d5db8bd14c2e2ed7ad32481f0937f6fc47c46 (diff) | |
download | ruby-5e25bfa2fbd659c7e0fe8c244633dc847218cee5.tar.gz |
enum.c: respect method visibility
* enum.c (ary_inject_op): should respect method visibility, do not
optimize uncallable method. [ruby-core:81349] [Bug #13592]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_enum.rb')
-rw-r--r-- | test/ruby/test_enum.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb index 86998eef60..57616791bb 100644 --- a/test/ruby/test_enum.rb +++ b/test/ruby/test_enum.rb @@ -234,6 +234,25 @@ class TestEnumerable < Test::Unit::TestCase end; end + def test_inject_array_op_private + assert_separately([], "#{<<~"end;"}\n""end") + all_assertions_foreach("", *%i[+ * / - %]) do |op| + bug = '[ruby-core:81349] [Bug #13592] should respect visibility' + assert_raise_with_message(NoMethodError, /private method/, bug) do + begin + Integer.class_eval do + private op + end + [1,2,3].inject(op) + ensure + Integer.class_eval do + public op + end + end + end + end; + end + def test_partition assert_equal([[1, 3, 1], [2, 2]], @obj.partition {|x| x % 2 == 1 }) cond = ->(x, i) { x % 2 == 1 } |