From 32674b167bddc0d737c38f84722986b0f228b44b Mon Sep 17 00:00:00 2001 From: akr Date: Tue, 15 Mar 2016 12:53:06 +0000 Subject: * 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 --- test/ruby/test_enum.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') 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 } -- cgit v1.2.3