aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_array.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_array.rb')
-rw-r--r--test/ruby/test_array.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index fb6b2a42ad..4ae5f9f820 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -1,6 +1,7 @@
# coding: US-ASCII
# frozen_string_literal: false
require 'test/unit'
+require "delegate"
require "rbconfig/sizeof"
class TestArray < Test::Unit::TestCase
@@ -2769,6 +2770,12 @@ class TestArray < Test::Unit::TestCase
assert_int_equal(13, [1, 2].sum(10))
assert_int_equal(16, [1, 2].sum(10) {|v| v * 2 })
+ yielded = []
+ three = SimpleDelegator.new(3)
+ ary = [1, 2.0, three]
+ assert_float_equal(12.0, ary.sum {|x| yielded << x; x * 2 })
+ assert_equal(ary, yielded)
+
assert_raise(TypeError) { [Object.new].sum }
large_number = 100000000