Sha256: 597ff036d255c4fcb4d4283e86336cb317e90d09d8adb6a17916a1409b3234d5
Contents?: true
Size: 764 Bytes
Versions: 2
Compression:
Stored size: 764 Bytes
Contents
require "minitest/autorun" require "shenanigans/array/reductions" class ArrayReductions < Minitest::Test TEST_ARRAY = [*1..4] def test_reductions_without_params_or_block assert_raises(ArgumentError) { TEST_ARRAY.reductions } end def test_reductions_operator_only assert TEST_ARRAY.reductions(:+) == [1, 3, 6, 10] end def test_reductions_initial_only assert TEST_ARRAY.reductions(50) { |acc, b| acc + b } == [50, 51, 53, 56, 60] end def test_reductions_inital_and_operator assert TEST_ARRAY.reductions(50, :+) == [50, 51, 53, 56, 60] end def test_reductions_without_params assert TEST_ARRAY.reductions { |acc, b| acc + b } == [1, 3, 6, 10] assert %w[a b c].reductions { |s1, s2| s1 + s2 } == %w[a ab abc] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
shenanigans-1.0.15 | test/array/reductions_test.rb |
shenanigans-1.0.14 | test/array/reductions_test.rb |