# _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # # for lib/facets/yore/enumerable/cross.rb # # Extracted Fri Feb 16 02:00:37 EST 2007 # Project.rb Test Extraction # require 'facets/yore/enumerable/cross.rb' require 'test/unit' class TCEnumerableClass < Test::Unit::TestCase def test_cross i = [[1,2], [3,4]] o = [[1, 3], [1, 4], [2, 3], [2, 4]] assert_equal( o, Enumerable.cross(*i) ) i = [[1,2], [4], ["apple", "banana"]] o = [[1, 4, "apple"], [1, 4, "banana"], [2, 4, "apple"], [2, 4, "banana"]] assert_equal( o, Enumerable.cross(*i) ) end end class TCEnumerable < Test::Unit::TestCase def test_cross a = [1,2,3].cross([4,5,6]) assert_equal( [[1, 4],[1, 5],[1, 6],[2, 4],[2, 5],[2, 6],[3, 4],[3, 5],[3, 6]], a ) a = [] [1,2,3].cross([4,5,6]) {|elem| a << elem } assert_equal( [[1, 4],[1, 5],[1, 6],[2, 4],[2, 5],[2, 6],[3, 4],[3, 5],[3, 6]], a ) end end