Sha256: 31909fcd1cd960d39031b8130166d330226cd2ba9da441baca10af02d41feac4

Contents?: true

Size: 618 Bytes

Versions: 4

Compression:

Stored size: 618 Bytes

Contents

shared_examples_for "Combinatorics::PowerSet::Mixin" do
  it "the powerset of an empty Set should only contain the empty Set" do
    set = subject[]

    set.powerset.should == [set]
  end

  it "the powerset of a single Set should contain that Set" do
    set = subject[1]

    set.powerset.should == [subject[], set]
  end

  it "the powerset of a Set should all be subsets" do
    set = subject[1,2,3]

    set.powerset.each { |subset| (set & subset).should == subset }
  end

  it "should alias cartesian_product to powerset" do
    set = subject[1,2,3]

    set.cartesian_product.should == set.powerset
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
combinatorics-0.3.1 spec/power_set/mixin_examples.rb
combinatorics-0.3.0 spec/power_set/mixin_examples.rb
combinatorics-0.2.0 spec/power_set/mixin_examples.rb
combinatorics-0.1.0 spec/power_set/mixin_examples.rb