Sha256: 73e14f8d96d3da604694ddc5df4dc73199c60953c6a9b55f3c2bc805cfd63eba

Contents?: true

Size: 1.06 KB

Versions: 16

Compression:

Stored size: 1.06 KB

Contents

require 'facets/enumerable/each_by'
require 'test/unit'

class TC_Enumerable_EachBy < Test::Unit::TestCase

  def test_each_by_01
    x = []
    [1,2,3,4].each_by{ |a,b| x << [a,b] }
    o = [[1,2],[3,4]]
    assert_equal( o, x )
  end

  def test_each_by_02
    x = []
    [1,2,3,4,5].each_by{ |a,b,c| x << [a,b,c] }
    o = [[1,2,3],[4,5,nil]]
    assert_equal( o, x )
  end

  def test_each_by_03
    x = []
    [1,2,3,4].each_by(2){ |a,b| x << [a,b] }
    o = [[1,2],[3,4]]
    assert_equal( o, x )
  end

  def test_each_by_04
    x = []
    [1,2,3,4,5,6,7,8].each_by(4){ |*a| x << a }
    o = [ [[1,2,3,4]],[[5,6,7,8]] ]
    assert_equal( o, x )
  end

  def test_each_by_05
    x = []
    [1,2,3,4,5,6].each_by(3){ |*a| x << a }
    o = [ [[1,2,3]],[[4,5,6]] ]
    assert_equal( o, x )
  end

  def test_each_by_06
    a = [1,2,3,4,5,6]
    r = []
    a.each_by(2){ |x,y| r << [x,y] }
    assert_equal( [[1,2],[3,4],[5,6]], r )
  end

  def test_each_by_07
    a = [1,2,3,4,5,6]
    r = []
    a.each_by(3){ |*e| r << e }
    assert_equal( [ [[1,2,3]], [[4,5,6]] ], r )
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
facets-2.8.4 test/core/enumerable/test_each_by.rb
facets-2.8.3 test/core/enumerable/test_each_by.rb
facets-2.8.2 test/core/enumerable/test_each_by.rb
facets-2.8.1 test/core/enumerable/test_each_by.rb
facets-2.8.0 test/core/enumerable/test_each_by.rb
facets-2.7.0 test/core/enumerable/test_each_by.rb
facets-2.6.0 test/core/enumerable/test_each_by.rb
facets-2.4.0 test/enumerable/test_each_by.rb
facets-2.4.1 test/enumerable/test_each_by.rb
facets-2.4.4 test/core/enumerable/test_each_by.rb
facets-2.4.2 test/core/enumerable/test_each_by.rb
facets-2.4.3 test/core/enumerable/test_each_by.rb
facets-2.5.0 test/core/enumerable/test_each_by.rb
facets-2.4.5 test/core/enumerable/test_each_by.rb
facets-2.5.1 test/core/enumerable/test_each_by.rb
facets-2.5.2 test/core/enumerable/test_each_by.rb