Sha256: 006390a94ac5394694436fc91681ca807457cd4a14d64168ce0198e951edfc6f

Contents?: true

Size: 596 Bytes

Versions: 5

Compression:

Stored size: 596 Bytes

Contents

#require 'epitools/core_ext'
#require 'epitools/permutations'
require 'epitools'

describe "Permutations" do
  
  it "a*b" do
    ([1,2] * [3,4]).should == [ [1,3], [1,4], [2,3], [2,4] ]
  end    

  it "a**2" do
    ([1,2] ** 2).should == [ [1,1], [1,2], [2,1], [2,2] ]
  end    
  
  it "all_pairses" do
    [1,2,3,4].all_pairs.to_a.should == [ 
      [1,2], 
      [1,3], 
      [1,4], 
      [2,3],
      [2,4],
      [3,4],
    ]

    # reflexive    
    [1,2,3].all_pairs(true).to_a.should == [
      [1,1],
      [1,2],
      [1,3],
      [2,2],
      [2,3],
      [3,3],
    ]
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
epitools-0.5.6 spec/permutations_spec.rb
epitools-0.5.5 spec/permutations_spec.rb
epitools-0.5.4 spec/permutations_spec.rb
epitools-0.5.3 spec/permutations_spec.rb
epitools-0.5.2 spec/permutations_spec.rb