diff options
author | ktsj <ktsj@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-09-08 08:56:30 +0000 |
---|---|---|
committer | ktsj <ktsj@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-09-08 08:56:30 +0000 |
commit | 1f8765bb2b62d533c0779c854c2b77cc021093b4 (patch) | |
tree | ff16188ebb98de5f81627826b6707637908c8e21 /test/ruby/test_array.rb | |
parent | 19f624541fd99231689880e11d5be25d51ef3c6b (diff) | |
download | ruby-1f8765bb2b62d533c0779c854c2b77cc021093b4.tar.gz |
* 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/trunk@56111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_array.rb')
-rw-r--r-- | test/ruby/test_array.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index addce0d9ba..a19e22aab4 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -813,6 +813,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 ] @@ -850,6 +859,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 |