Sha256: cbe6743d2bb469d1c33614788bda5636e970983eec7a16a7fe6545e92999e495

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

require 'spec_helper'

require 'combinatorics/permute'

shared_examples_for "Permute::Mixin" do
  describe "#permute" do
    it "should return [[]] for [].permute(0).to_a" do
      set     = subject[]
      results = set.permute(0).to_a
      
      expect(results).to eq([[]])
    end

    it "should return [[]] for [1].permute(0).to_a" do
      set     = subject[1]
      results = set.permute(0).to_a
      
      expect(results).to eq([[]])
    end

    it "should return [[1]] for [1].permute(1).to_a" do
      set     = subject[1]
      results = set.permute(1).to_a
      
      expect(results).to eq([[1]])
    end

    it "should return [[1], [2]] for [1, 2].permute(1).to_a" do
      set     = subject[1, 2]
      results = set.permute(1).to_a
      
      expect(results).to match_array([[1], [2]])
    end

    it "should return [[1, 2]] for [1, 2].permute(2).to_a" do
      set     = subject[1, 2]
      results = set.permute(2).to_a
      
      expect(results).to match_array([[1, 2], [2, 1]])
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
combinatorics-0.5.0 spec/permute/mixin_examples.rb
combinatorics-0.4.4 spec/permute/mixin_examples.rb