From 8833bfbd0bd46809144199fd5d9141e60b4ec3e2 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 25 Sep 2016 07:36:06 +0000 Subject: merge revision(s) 56111: [Backport #12738] * array.c (flatten): use rb_obj_class instead of rb_class_of because rb_class_of may return a singleton class. [ruby-dev:49781] [Bug #12738] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@56233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_array.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test') diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index eacc0b007b..f27b8a5724 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -805,6 +805,15 @@ class TestArray < Test::Unit::TestCase assert_nothing_raised(RuntimeError, bug10748) {a.flatten(1)} end + def test_flattern_singleton_class + bug12738 = '[ruby-dev:49781] [Bug #12738]' + a = [[0]] + class << a + def m; end + end + assert_raise(NoMethodError, bug12738) { a.flatten.m } + end + def test_flatten! a1 = @cls[ 1, 2, 3] a2 = @cls[ 5, 6 ] @@ -842,6 +851,15 @@ class TestArray < Test::Unit::TestCase assert_nothing_raised(RuntimeError, bug10748) {a.flatten!(1)} end + def test_flattern_singleton_class! + bug12738 = '[ruby-dev:49781] [Bug #12738]' + a = [[0]] + class << a + def m; end + end + assert_nothing_raised(NameError, bug12738) { a.flatten!.m } + end + def test_flatten_with_callcc need_continuation o = Object.new -- cgit v1.2.3