summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-09-30 15:54:16 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-09-30 15:54:16 +0000
commit4af941c708415371bf09e9ce7c695f0a55af11ae (patch)
treef36fbff2da224661a8c05c305457eb6e5e6939bf /test
parentf0608fca8c9195bea1b5aba65b22e8d65d985953 (diff)
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_2@56305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_array.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index 8c8b63c4e2..32080bb756 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -784,6 +784,15 @@ class TestArray < Test::Unit::TestCase
assert_not_same(a8, a9)
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 ]
@@ -804,6 +813,15 @@ class TestArray < Test::Unit::TestCase
assert_nil(@cls[].flatten!(0), '[ruby-core:23382]')
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