Sha256: 23ed4f3d14e1ef2ffbdeafeca0fc3b96d0c4dc31805ef99eaf132b603f7249b6

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
# for lib/facets/core/enumerable/each_by.rb
#
# Extracted Fri Sep 08 20:20:32 EDT 2006
# Unit Tools Reap Test Extractor
#

require 'facets/core/enumerable/each_by.rb'


  require 'test/unit'

  class TCEnumerable < Test::Unit::TestCase

    def test_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_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_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_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_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_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_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

1 entries across 1 versions & 1 rubygems

Version Path
facets-1.7.46 test/lib/facets/core/enumerable/test_each_by.rb