summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-09-25 07:36:06 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-09-25 07:36:06 +0000
commit8833bfbd0bd46809144199fd5d9141e60b4ec3e2 (patch)
tree7ef9763bedbff2133245c8fa4130940742cedcb8 /test
parent0b519785284bdd3be48ac157a4da95c8c01d2029 (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_3@56233 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 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