diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-15 12:53:06 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-15 12:53:06 +0000 |
commit | 1951c820294e07a3017bf31c341e831491c45db0 (patch) | |
tree | d40b3fa2084e3407067b40e4865667a057464fa9 /test | |
parent | 8d0588dc3dc0dd71155329986dfde536ca02f473 (diff) | |
download | ruby-1951c820294e07a3017bf31c341e831491c45db0.tar.gz |
* enum.c (enum_inject): Consider redefinition of Fixnum#+.
[ruby-dev:49510] [Bug#12178] Reported by usa.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_enum.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb index 6162830b69..3dfbd26929 100644 --- a/test/ruby/test_enum.rb +++ b/test/ruby/test_enum.rb @@ -184,6 +184,18 @@ class TestEnumerable < Test::Unit::TestCase assert_equal(nil, @empty.inject() {9}) end + def test_inject_array_plus + assert_separately([], <<-"end;") + class Fixnum + undef :+ + def +(x) + 0 + end + end + assert_equal(0, [1,2,3].inject(:+), "[ruby-dev:49510] [Bug#12178]") + end; + end + def test_partition assert_equal([[1, 3, 1], [2, 2]], @obj.partition {|x| x % 2 == 1 }) cond = ->(x, i) { x % 2 == 1 } |