# _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # # for lib/facet/enumerable/each_slice.rb # # Extracted Wed Jan 25 11:25:39 EST 2006 # Unit Tools Reap Test Extractor # require 'facet/enumerable/each_slice.rb' require 'test/unit' class TCEnumerable < Test::Unit::TestCase def test_each_slice x = [] [1,2,3,4].each_slice{ |a,b| x << [a,b] } o = [[1,2],[3,4]] assert_equal( o, x ) 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 ) x = [] [1,2,3,4].each_slice(2){ |a,b| x << [a,b] } o = [[1,2],[3,4]] assert_equal( o, x ) x = [] [1,2,3,4,5,6,7,8].each_slice(4){ |*a| x << a } o = [[1,2,3,4],[5,6,7,8]] assert_equal( o, x ) x = [] [1,2,3,4,5,6].each_slice(3){ |*a| x << a } o = [[1,2,3],[4,5,6]] assert_equal( o, x ) a = [1,2,3,4,5,6] r = [] a.each_slice(2){ |x,y| r << [x,y] } assert_equal( [[1,2],[3,4],[5,6]], r ) r = [] a.each_slice(3){ |*e| r << e } assert_equal( [[1,2,3],[4,5,6]], r ) end end class TC02 < Test::Unit::TestCase def test_each_by x = [] [1,2,3,4].each_by(2){ |a,b| x << [a,b] } o = [[1,2],[3,4]] assert_equal( o, x ) x = [] [1,2,3,4,5].each_by(3){ |*a| x << a } o = [[1,2,3],[4,5]] assert_equal( o, x ) end end