Sha256: a36080774f93e7aa9475b80a8f30983331b0c2d7b1e603f17dcf891309748abf

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

covers 'facets/array/product'

test_case Array do

  method :product do

    test "single argument" do
      r = [1,2,3].product([4,5,6])
      x = [[1, 4],[1, 5],[1, 6],[2, 4],[2, 5],[2, 6],[3, 4],[3, 5],[3, 6]]
      r.assert == x
    end

    test "multiple arguments" do
      a = %w|a b|
      b = %w|a x|
      c = %w|x y|
      r = a.product(b, c)
      x = [ ["a", "a", "x"],
            ["a", "a", "y"],
            ["a", "x", "x"],
            ["a", "x", "y"],
            ["b", "a", "x"],
            ["b", "a", "y"],
            ["b", "x", "x"],
            ["b", "x", "y"] ]
      r.assert == x
    end

  end

  #def test_product_01
  #  i = [[1,2], [4], ["apple", "banana"]]
  #  o = [[1, 4, "apple"], [1, 4, "banana"], [2, 4, "apple"], [2, 4, "banana"]]
  #  assert_equal( o, Enumerable.product(*i) )
  #end

  #     def test_op_mod
  #       a = [:A,:B,:C]
  #       assert_equal( a[1], a/1 )
  #       assert_equal( :B, a/1 )
  #     end
  #
  #     def test_op_div
  #       a = [:A,:B,:C]
  #       assert_equal( a[1], a/1 )
  #       assert_equal( :B, a/1 )
  #     end


  #def test_op_mod
  #  a = [:A,:B,:C]
  #  assert_equal( a[1], a/1 )
  #  assert_equal( :B, a/1 )
  #end
  #
  #def test_op_div
  #  a = [:A,:B,:C]
  #  assert_equal( a[1], a/1 )
  #  assert_equal( :B, a/1 )
  #end

end


Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-3.0.0 test/core/array/test_product.rb
facets-2.9.3 test/core/array/test_product.rb
facets-2.9.2 test/core/array/test_product.rb