Sha256: bd6520c9d9971d2b29f1ac4562db1b10e9c632e2f8985345d859a8a6c43eb1c1

Contents?: true

Size: 971 Bytes

Versions: 2

Compression:

Stored size: 971 Bytes

Contents

require File.expand_path('../../spec_helper', File.dirname(__FILE__))

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
          lambda { @list.send(method, STACK_OVERFLOW_DEPTH) }.should_not raise_error
        end

      end

      [
        [[], 10, nil],
        [["A"], 10, nil],
        [["A", "B", "C"], 0, "A"],
        [["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

2 entries across 2 versions & 1 rubygems

Version Path
hamster-0.2.7 spec/hamster/list/at_spec.rb
hamster-0.2.6 spec/hamster/list/at_spec.rb