Sha256: 1e6b1b4b5f77ca56cfdd38cd0727157cdd38a088eea3e1b8c03a3cefae10486b

Contents?: true

Size: 907 Bytes

Versions: 1

Compression:

Stored size: 907 Bytes

Contents

require "spec_helper"

require "hamster/list"

describe Hamster::List do

  [:at, :[]].each do |method|

    describe "##{method}" do

      describe "on a really big list" do

        before do
          @list = Hamster.interval(0, STACK_OVERFLOW_DEPTH)
        end

        it "doesn't run out of stack" do
          -> { @list.send(method, STACK_OVERFLOW_DEPTH) }.should_not raise_error
        end

      end

      [
        [[], 10, nil],
        [["A"], 10, nil],
        [%w[A B C], 0, "A"],
        [%w[A B C], 2, "C"],
      ].each do |values, number, expected|

        describe "#{values.inspect} with #{number}" do

          before do
            @original = Hamster.list(*values)
            @result = @original.send(method, number)
          end

          it "returns #{expected.inspect}" do
            @result.should == expected
          end

        end

      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hamster-1.0.1.pre.rc.1 spec/hamster/list/at_spec.rb