Sha256: fcacb0ac4cc6cf4d4d6ad30adcc8e5fb8c5bebe8c9fa17f1a589cb396181895b
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
# _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # # for lib/facets/core/enumerable/each_slice.rb # # Extracted Mon Jun 05 08:14:29 EDT 2006 # Unit Tools Reap Test Extractor # require 'facets/core/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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
facets-1.4.0 | test/lib/facets/core/enumerable/test_each_slice.rb |