Skip to content

Commit 039300d

Browse files
committed
inject
1 parent 15e9218 commit 039300d

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

test/vecmath_spec_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@ def test_array_reduce
226226
assert_equal(sum, Vec2D.new(12, 6))
227227
end
228228

229+
def test_array_inject
230+
array = [Vec2D.new(1, 2), Vec2D.new(10, 2), Vec2D.new(1, 2)]
231+
sum = array.inject(Vec2D.new, &:+)
232+
assert_equal(sum, Vec2D.new(12, 6))
233+
end
234+
229235
def test_array_zip
230236
one = [Vec2D.new(1, 2), Vec2D.new(10, 2), Vec2D.new(1, 2)]
231237
two = [Vec2D.new(1, 2), Vec2D.new(10, 2), Vec2D.new(1, 2)]

0 commit comments

Comments
 (0)